Skip to content

Commit

Permalink
Fix linker error caused by private linking of transitive dependencies.
Browse files Browse the repository at this point in the history
Check conan-io/conan#7192 for more information.
  • Loading branch information
PengZheng committed Mar 6, 2024
1 parent 0601f95 commit f75a419
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,9 @@ def generate(self):
tc.cache_variables["CELIX_ERR_BUFFER_SIZE"] = str(self.options.celix_err_buffer_size)
# tc.cache_variables["CMAKE_PROJECT_Celix_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
# the following is workaround for https://github.com/conan-io/conan/issues/7192
if self.settings.os == "Linux":
tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
elif self.settings.os == "Macos":
tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup"
for dep in self.dependencies.host.values():
copy(self, "*", dep.cpp_info.libdir, os.path.join(self.build_folder, "lib"))
tc.cache_variables["CMAKE_BUILD_RPATH"] = os.path.join(self.build_folder, "lib")
v = Version(self.version)
tc.cache_variables["CELIX_MAJOR"] = str(v.major.value)
tc.cache_variables["CELIX_MINOR"] = str(v.minor.value)
Expand Down
8 changes: 4 additions & 4 deletions examples/conan_test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class TestPackageConan(ConanFile):
generators = "cmake_paths", "cmake_find_package"
# requires = "celix/2.3.0@docker/test"

def imports(self):
self.copy("*", src="@libdirs", dst="lib")

def build(self):
cmake = CMake(self)
cmake.definitions["TEST_FRAMEWORK"] = self.options["celix"].build_framework
Expand Down Expand Up @@ -56,10 +59,7 @@ def build(self):
cmake.definitions["TEST_COMPONENTS_READY_CHECK"] = self.options["celix"].build_components_ready_check
cmake.definitions["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
# the following is workaround https://github.com/conan-io/conan/issues/7192
if self.settings.os == "Linux":
cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
elif self.settings.os == "Macos":
cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup"
cmake.definitions["CMAKE_BUILD_RPATH"] = os.path.join(self.build_folder, "lib")
cmake.configure()
cmake.build()

Expand Down
8 changes: 4 additions & 4 deletions examples/conan_test_package_v2/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.build import can_run
from conan.tools.files import chdir
from conan.tools.files import copy
import os


Expand Down Expand Up @@ -65,10 +66,9 @@ def generate(self):
tc.cache_variables["TEST_UTILS"] = celix_options.build_utils
tc.cache_variables["TEST_COMPONENTS_READY_CHECK"] = celix_options.build_components_ready_check
# the following is workaround https://github.com/conan-io/conan/issues/7192
if self.settings.os == "Linux":
tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
elif self.settings.os == "Macos":
tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup"
for dep in self.dependencies.host.values():
copy(self, "*", dep.cpp_info.libdir, os.path.join(self.build_folder, "lib"))
tc.cache_variables["CMAKE_BUILD_RPATH"] = os.path.join(self.build_folder, "lib")
tc.user_presets_path = False
tc.generate()

Expand Down

0 comments on commit f75a419

Please sign in to comment.