From 3e3f74a01b759d33d890b8d40d2c1d871ded4021 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 2 Mar 2023 13:17:02 +0100 Subject: [PATCH 1/6] Use cmake support for testing boost package Signed-off-by: Uilian Ries --- recipes/boost/all/test_package/CMakeLists.txt | 1 + recipes/boost/all/test_package/conanfile.py | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/recipes/boost/all/test_package/CMakeLists.txt b/recipes/boost/all/test_package/CMakeLists.txt index 769ce4cdc3ba2..9735204bef3db 100644 --- a/recipes/boost/all/test_package/CMakeLists.txt +++ b/recipes/boost/all/test_package/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) +include(CTest) enable_testing() if(BOOST_NAMESPACE) diff --git a/recipes/boost/all/test_package/conanfile.py b/recipes/boost/all/test_package/conanfile.py index 66ee2b0e2d276..bb9d7ae966081 100644 --- a/recipes/boost/all/test_package/conanfile.py +++ b/recipes/boost/all/test_package/conanfile.py @@ -3,8 +3,6 @@ from conan.tools.build import can_run from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.files import chdir -from conan.tools.scm import Version - class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" @@ -56,7 +54,6 @@ def build(self): cmake.build() def test(self): - if not can_run(self): - return - with chdir(self, self.folders.build_folder): - self.run(f"ctest --output-on-failure -C {self.settings.build_type}", env="conanrun") + if can_run(self): + cmake = CMake(self) + cmake.test() From 64699247a7d810a40ca5a87b66bcf52e64863ab4 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 2 Mar 2023 15:59:40 +0100 Subject: [PATCH 2/6] Revert "Use cmake support for testing boost package" This reverts commit 3e3f74a01b759d33d890b8d40d2c1d871ded4021. --- recipes/boost/all/test_package/CMakeLists.txt | 1 - recipes/boost/all/test_package/conanfile.py | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/boost/all/test_package/CMakeLists.txt b/recipes/boost/all/test_package/CMakeLists.txt index 9735204bef3db..769ce4cdc3ba2 100644 --- a/recipes/boost/all/test_package/CMakeLists.txt +++ b/recipes/boost/all/test_package/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) -include(CTest) enable_testing() if(BOOST_NAMESPACE) diff --git a/recipes/boost/all/test_package/conanfile.py b/recipes/boost/all/test_package/conanfile.py index bb9d7ae966081..66ee2b0e2d276 100644 --- a/recipes/boost/all/test_package/conanfile.py +++ b/recipes/boost/all/test_package/conanfile.py @@ -3,6 +3,8 @@ from conan.tools.build import can_run from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.files import chdir +from conan.tools.scm import Version + class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" @@ -54,6 +56,7 @@ def build(self): cmake.build() def test(self): - if can_run(self): - cmake = CMake(self) - cmake.test() + if not can_run(self): + return + with chdir(self, self.folders.build_folder): + self.run(f"ctest --output-on-failure -C {self.settings.build_type}", env="conanrun") From 07ee5d937fe23026118ed96291002c44356f43a3 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 2 Mar 2023 16:06:45 +0100 Subject: [PATCH 3/6] avoid conanrun Signed-off-by: Uilian Ries --- recipes/boost/all/test_package/CMakeLists.txt | 1 + recipes/boost/all/test_package/conanfile.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/boost/all/test_package/CMakeLists.txt b/recipes/boost/all/test_package/CMakeLists.txt index 769ce4cdc3ba2..9735204bef3db 100644 --- a/recipes/boost/all/test_package/CMakeLists.txt +++ b/recipes/boost/all/test_package/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) +include(CTest) enable_testing() if(BOOST_NAMESPACE) diff --git a/recipes/boost/all/test_package/conanfile.py b/recipes/boost/all/test_package/conanfile.py index 66ee2b0e2d276..0a75744b0e77b 100644 --- a/recipes/boost/all/test_package/conanfile.py +++ b/recipes/boost/all/test_package/conanfile.py @@ -3,7 +3,6 @@ from conan.tools.build import can_run from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.files import chdir -from conan.tools.scm import Version class TestPackageConan(ConanFile): @@ -59,4 +58,4 @@ def test(self): if not can_run(self): return with chdir(self, self.folders.build_folder): - self.run(f"ctest --output-on-failure -C {self.settings.build_type}", env="conanrun") + self.run(f"ctest --output-on-failure -C {self.settings.build_type}") From 7497b4b574765aaf3322c3e275a5c65117049693 Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:51:00 +0000 Subject: [PATCH 4/6] boost test package: use build env when invoking ctest on non-windows platforms --- recipes/boost/all/test_package/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/boost/all/test_package/conanfile.py b/recipes/boost/all/test_package/conanfile.py index 0a75744b0e77b..e0dae70f7b6a3 100644 --- a/recipes/boost/all/test_package/conanfile.py +++ b/recipes/boost/all/test_package/conanfile.py @@ -7,7 +7,7 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "VirtualRunEnv" + generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" test_type = "explicit" def _boost_option(self, name, default): @@ -58,4 +58,5 @@ def test(self): if not can_run(self): return with chdir(self, self.folders.build_folder): - self.run(f"ctest --output-on-failure -C {self.settings.build_type}") + env = "conanrun" if self.settings.os == "Windows" else "conanbuild" + self.run(f"ctest --output-on-failure -C {self.settings.build_type}", env=env) From f68817425014ce4344eeea9da71d8ab94190b7ce Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:58:49 +0000 Subject: [PATCH 5/6] boost test package: add comment with clarification --- recipes/boost/all/test_package/conanfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/recipes/boost/all/test_package/conanfile.py b/recipes/boost/all/test_package/conanfile.py index e0dae70f7b6a3..de19d7acf2aa4 100644 --- a/recipes/boost/all/test_package/conanfile.py +++ b/recipes/boost/all/test_package/conanfile.py @@ -58,5 +58,14 @@ def test(self): if not can_run(self): return with chdir(self, self.folders.build_folder): + # When boost and its dependencies are built as shared libraries, + # the test executables need to locate them. Typically the + # `conanrun` env should be enough, but this may cause problems on macOS + # where the CMake installation has dependencies on Apple-provided + # system libraries that are incompatible with Conan-provided ones. + # When `conanrun` is enabled, DYLD_LIBRARY_PATH will also apply + # to ctest itself. Given that CMake already embeds RPATHs by default, + # we can bypass this by using the `conanbuild` environment on + # non-Windows platforms, while still retaining the correct behaviour. env = "conanrun" if self.settings.os == "Windows" else "conanbuild" self.run(f"ctest --output-on-failure -C {self.settings.build_type}", env=env) From 5b9da1a684b503d6614a6fc48b3c0c85b2b706c8 Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Thu, 2 Mar 2023 19:40:21 +0000 Subject: [PATCH 6/6] boost test package: add disable new dtags on Linux --- recipes/boost/all/test_package/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/boost/all/test_package/CMakeLists.txt b/recipes/boost/all/test_package/CMakeLists.txt index 9735204bef3db..d3d62d560560c 100644 --- a/recipes/boost/all/test_package/CMakeLists.txt +++ b/recipes/boost/all/test_package/CMakeLists.txt @@ -1,6 +1,12 @@ cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) +if(UNIX AND NOT APPLE) + # use RPATH instead of RUNPATH so that + # transitive dependencies can be located + add_link_options("LINKER:--disable-new-dtags") +endif() + include(CTest) enable_testing()