Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[boost] Fix test package on macOS when *:shared=True #16348

Merged
merged 6 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/boost/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
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()

if(BOOST_NAMESPACE)
Expand Down
15 changes: 12 additions & 3 deletions recipes/boost/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
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"
generators = "CMakeDeps", "VirtualRunEnv"
generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv"
test_type = "explicit"

def _boost_option(self, name, default):
Expand Down Expand Up @@ -59,4 +58,14 @@ 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")
# 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)