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

pengzheng pushed a commit to branch 
hotfix/642-cmake-private-linking-workaround-doc
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to 
refs/heads/hotfix/642-cmake-private-linking-workaround-doc by this push:
     new b76315ab Add documentation for workaround for Conan's CMake private 
linking issue
b76315ab is described below

commit b76315abdbfe21f79c71abc7304c0ed0a7bdbe50
Author: PengZheng <[email protected]>
AuthorDate: Mon Sep 18 13:50:56 2023 +0800

    Add documentation for workaround for Conan's CMake private linking issue
---
 documents/building/README.md | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/documents/building/README.md b/documents/building/README.md
index 71d2ed0e..145b2e2f 100644
--- a/documents/building/README.md
+++ b/documents/building/README.md
@@ -103,6 +103,26 @@ To see a complete overview of the available build options 
use the following comm
 conan inspect . | grep build_
 ```
 
+#### CMake Private Linking Workaround
+
+When using Celix via Conan, you may encounter an 
[issue](https://github.com/apache/celix/issues/642) where libzip.so is not 
found by linker.
+This is due to a [bug in Conan](https://github.com/conan-io/conan/issues/7192).
+
+A workaround we adopt in Celix is to add the following to the conanfile.py:
+
+```python
+    def generate(self):
+        deps = CMakeDeps(self)
+        deps.generate()
+        tc = CMakeToolchain(self)
+        # 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"
+        tc.generate()
+```
+
 ### Building Apache Celix directly using CMake
 The following packages (libraries + headers) should be installed on your 
system:
 

Reply via email to