Skip to content

Commit

Permalink
Merge pull request #737 from apache/hotfix/revert-conan-private-dep-fix
Browse files Browse the repository at this point in the history
hotfix/Revert "Fix linker error caused by private linking of transitive depe…
  • Loading branch information
PengZheng committed Mar 9, 2024
2 parents 1df0588 + 35e30c1 commit d46d983
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 60 deletions.
8 changes: 4 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ 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
for dep in self.dependencies.host.values():
for ld in dep.cpp_info.libdirs:
copy(self, "*", ld, os.path.join(self.build_folder, "lib"))
tc.cache_variables["CMAKE_BUILD_RPATH"] = os.path.join(self.build_folder, "lib")
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"
v = Version(self.version)
tc.cache_variables["CELIX_MAJOR"] = str(v.major.value)
tc.cache_variables["CELIX_MINOR"] = str(v.minor.value)
Expand Down
89 changes: 38 additions & 51 deletions examples/conan_test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,51 @@
# specific language governing permissions and limitations
# under the License.

from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy
from conans import tools
from conans import CMake, ConanFile, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["TEST_FRAMEWORK"] = self.options["celix"].build_framework
tc.cache_variables["TEST_HTTP_ADMIN"] = self.options["celix"].build_http_admin
tc.cache_variables["TEST_LOG_SERVICE"] = self.options["celix"].build_log_service
tc.cache_variables["TEST_SYSLOG_WRITER"] = self.options["celix"].build_syslog_writer
tc.cache_variables["TEST_RSA"] = self.options["celix"].build_remote_service_admin
tc.cache_variables["TEST_RSA_DFI"] = self.options["celix"].build_rsa_remote_service_admin_dfi
tc.cache_variables["TEST_RSA_SHM_V2"] = self.options["celix"].build_rsa_remote_service_admin_shm_v2
tc.cache_variables["TEST_RSA_RPC_JSON"] = self.options["celix"].build_rsa_json_rpc
tc.cache_variables["TEST_RSA_DISCOVERY_CONFIGURED"] = self.options["celix"].build_rsa_discovery_configured
tc.cache_variables["TEST_RSA_DISCOVERY_ETCD"] = self.options["celix"].build_rsa_discovery_etcd
tc.cache_variables["TEST_RSA_DISCOVERY_ZEROCONF"] = self.options["celix"].build_rsa_discovery_zeroconf
tc.cache_variables["TEST_SHELL"] = self.options["celix"].build_shell
if self.options["celix"].build_shell:
tc.cache_variables["TEST_CXX_SHELL"] = self.options["celix"].celix_cxx17 or self.options["celix"].celix_cxx14
tc.cache_variables["TEST_REMOTE_SHELL"] = self.options["celix"].build_remote_shell
tc.cache_variables["TEST_SHELL_TUI"] = self.options["celix"].build_shell_tui
tc.cache_variables["TEST_SHELL_WUI"] = self.options["celix"].build_shell_wui
tc.cache_variables["TEST_ETCD_LIB"] = self.options["celix"].build_celix_etcdlib
tc.cache_variables["TEST_LAUNCHER"] = self.options["celix"].build_launcher
tc.cache_variables["TEST_PROMISES"] = self.options["celix"].build_promises
tc.cache_variables["TEST_PUSHSTREAMS"] = self.options["celix"].build_pushstreams
tc.cache_variables["TEST_LOG_HELPER"] = self.options["celix"].build_log_helper
tc.cache_variables["TEST_LOG_SERVICE_API"] = self.options["celix"].build_log_service_api
tc.cache_variables["TEST_CXX_REMOTE_SERVICE_ADMIN"] = self.options["celix"].build_cxx_remote_service_admin
tc.cache_variables["TEST_SHELL_API"] = self.options["celix"].build_shell_api
tc.cache_variables["TEST_CELIX_DFI"] = self.options["celix"].build_celix_dfi
tc.cache_variables["TEST_UTILS"] = self.options["celix"].build_utils
tc.cache_variables["TEST_COMPONENTS_READY_CHECK"] = self.options["celix"].build_components_ready_check
# the following is workaround https://github.com/conan-io/conan/issues/7192
for dep in self.dependencies.host.values():
for ld in dep.cpp_info.libdirs:
copy(self, "*", ld, 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()
generators = "cmake_paths", "cmake_find_package"
# requires = "celix/2.3.0@docker/test"

def build(self):
cmake = CMake(self)
cmake.definitions["TEST_FRAMEWORK"] = self.options["celix"].build_framework
cmake.definitions["TEST_HTTP_ADMIN"] = self.options["celix"].build_http_admin
cmake.definitions["TEST_LOG_SERVICE"] = self.options["celix"].build_log_service
cmake.definitions["TEST_SYSLOG_WRITER"] = self.options["celix"].build_syslog_writer
cmake.definitions["TEST_RSA"] = self.options["celix"].build_remote_service_admin
cmake.definitions["TEST_RSA_DFI"] = self.options["celix"].build_rsa_remote_service_admin_dfi
cmake.definitions["TEST_RSA_SHM_V2"] = self.options["celix"].build_rsa_remote_service_admin_shm_v2
cmake.definitions["TEST_RSA_RPC_JSON"] = self.options["celix"].build_rsa_json_rpc
cmake.definitions["TEST_RSA_DISCOVERY_CONFIGURED"] = self.options["celix"].build_rsa_discovery_configured
cmake.definitions["TEST_RSA_DISCOVERY_ETCD"] = self.options["celix"].build_rsa_discovery_etcd
cmake.definitions["TEST_RSA_DISCOVERY_ZEROCONF"] = self.options["celix"].build_rsa_discovery_zeroconf
cmake.definitions["TEST_SHELL"] = self.options["celix"].build_shell
if self.options["celix"].build_shell:
cmake.definitions["TEST_CXX_SHELL"] = self.options["celix"].celix_cxx17 or self.options["celix"].celix_cxx14
cmake.definitions["TEST_REMOTE_SHELL"] = self.options["celix"].build_remote_shell
cmake.definitions["TEST_SHELL_TUI"] = self.options["celix"].build_shell_tui
cmake.definitions["TEST_SHELL_WUI"] = self.options["celix"].build_shell_wui
cmake.definitions["TEST_ETCD_LIB"] = self.options["celix"].build_celix_etcdlib
cmake.definitions["TEST_LAUNCHER"] = self.options["celix"].build_launcher
cmake.definitions["TEST_PROMISES"] = self.options["celix"].build_promises
cmake.definitions["TEST_PUSHSTREAMS"] = self.options["celix"].build_pushstreams
cmake.definitions["TEST_LOG_HELPER"] = self.options["celix"].build_log_helper
cmake.definitions["TEST_LOG_SERVICE_API"] = self.options["celix"].build_log_service_api
cmake.definitions["TEST_CXX_REMOTE_SERVICE_ADMIN"] = self.options["celix"].build_cxx_remote_service_admin
cmake.definitions["TEST_SHELL_API"] = self.options["celix"].build_shell_api
cmake.definitions["TEST_CELIX_DFI"] = self.options["celix"].build_celix_dfi
cmake.definitions["TEST_UTILS"] = self.options["celix"].build_utils
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.configure()
cmake.build()

Expand Down Expand Up @@ -136,4 +123,4 @@ def test(self):
self.run("./use_utils", run_environment=True)
if self.options["celix"].build_components_ready_check:
self.run("./use_components_ready_check",
cwd=os.path.join("deploy", "use_components_ready_check"), run_environment=True)
cwd=os.path.join("deploy", "use_components_ready_check"), run_environment=True)
9 changes: 4 additions & 5 deletions examples/conan_test_package_v2/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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 @@ -66,10 +65,10 @@ 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
for dep in self.dependencies.host.values():
for ld in dep.cpp_info.libdirs:
copy(self, "*", ld, os.path.join(self.build_folder, "lib"))
tc.cache_variables["CMAKE_BUILD_RPATH"] = os.path.join(self.build_folder, "lib")
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.user_presets_path = False
tc.generate()

Expand Down

0 comments on commit d46d983

Please sign in to comment.