This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch hotfix/conan-private-dep
in repository https://gitbox.apache.org/repos/asf/celix.git

commit f75a41974cb53673d88592f8dacc2b3a7eb3022f
Author: PengZheng <[email protected]>
AuthorDate: Wed Mar 6 18:56:20 2024 +0800

    Fix linker error caused by private linking of transitive dependencies.
    
    Check https://github.com/conan-io/conan/issues/7192 for more information.
---
 conanfile.py                                | 7 +++----
 examples/conan_test_package/conanfile.py    | 8 ++++----
 examples/conan_test_package_v2/conanfile.py | 8 ++++----
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/conanfile.py b/conanfile.py
index 60e05f71..79db0fb3 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -344,10 +344,9 @@ class CelixConan(ConanFile):
         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)
diff --git a/examples/conan_test_package/conanfile.py 
b/examples/conan_test_package/conanfile.py
index c80070e3..2fd75fbc 100644
--- a/examples/conan_test_package/conanfile.py
+++ b/examples/conan_test_package/conanfile.py
@@ -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
@@ -56,10 +59,7 @@ class TestPackageConan(ConanFile):
         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()
 
diff --git a/examples/conan_test_package_v2/conanfile.py 
b/examples/conan_test_package_v2/conanfile.py
index 3eaabd65..d64d38b9 100644
--- a/examples/conan_test_package_v2/conanfile.py
+++ b/examples/conan_test_package_v2/conanfile.py
@@ -19,6 +19,7 @@ from conan import ConanFile
 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
 
 
@@ -65,10 +66,9 @@ class TestPackageConan(ConanFile):
         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()
 

Reply via email to