This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch feature/conan_support in repository https://gitbox.apache.org/repos/asf/celix.git
commit ba8632467f684908581473e638f75f619a08f89c Author: PengZheng <[email protected]> AuthorDate: Tue Mar 8 11:17:46 2022 +0800 Fix misuse of find_package and find_dependency in CelixConfig.cmake. Use find_dependency without REQUIRED to handle find_package(Celix) correctly (i.e., use Celix as an optional package). --- bundles/http_admin/civetweb/CMakeLists.txt | 1 + cmake/CelixConfig.cmake | 21 +++++++++-------- cmake/cmake_celix/UseCelix.cmake | 37 ------------------------------ 3 files changed, 12 insertions(+), 47 deletions(-) diff --git a/bundles/http_admin/civetweb/CMakeLists.txt b/bundles/http_admin/civetweb/CMakeLists.txt index 8b43cf2..ff2e5fd 100644 --- a/bundles/http_admin/civetweb/CMakeLists.txt +++ b/bundles/http_admin/civetweb/CMakeLists.txt @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +find_package(CURL REQUIRED) #Create shared library add_library(civetweb_shared SHARED diff --git a/cmake/CelixConfig.cmake b/cmake/CelixConfig.cmake index 67e202a..e56039e 100644 --- a/cmake/CelixConfig.cmake +++ b/cmake/CelixConfig.cmake @@ -73,25 +73,26 @@ set(CELIX_SHELL_TUI_BUNDLE ${CELIX_BUNDLES_DIR}/shell_tui.zip) include(CMakeFindDependencyMacro) -find_dependency(ZLIB REQUIRED) #Needed by framework -find_dependency(UUID REQUIRED) #Needed by framework -find_dependency(CURL REQUIRED) #Needed by framework (used for curl initialization) +find_dependency(ZLIB) #Needed by framework +find_dependency(UUID) #Needed by framework +find_dependency(CURL) #Needed by framework (used for curl initialization) find_dependency(LIBZIP) #Needed by utils -find_dependency(Jansson REQUIRED) #Needed by dfi, etcdlib, remote services, pubsub +find_dependency(Jansson) #Needed by dfi, etcdlib, remote services, pubsub +find_dependency(FFI) #Needed by dfi if (TARGET Celix::dfi) - find_dependency(FFI REQUIRED) + find_dependency(FFI) endif() if (TARGET Celix::RsaConfiguredDiscovery) - find_dependency(RapidJSON REQUIRED) + find_dependency(RapidJSON) endif () if (TARGET Celix::rsa_discovery_common) - find_dependency(LibXml2 REQUIRED) + find_dependency(LibXml2) endif () if (TARGET Celix::celix_pubsub_admin_zmq OR TARGET Celix::celix_pubsub_admin_zmq_v2) - find_dependency(ZMQ REQUIRED) - find_dependency(CZMQ REQUIRED) + find_dependency(ZMQ) + find_dependency(CZMQ) endif () if (TARGET Celix::pubsub_admin_nanomsg) - find_dependency(NanoMsg REQUIRED) + find_dependency(NanoMsg) endif () diff --git a/cmake/cmake_celix/UseCelix.cmake b/cmake/cmake_celix/UseCelix.cmake index 0e98b53..5077159 100644 --- a/cmake/cmake_celix/UseCelix.cmake +++ b/cmake/cmake_celix/UseCelix.cmake @@ -28,40 +28,3 @@ include(${CELIX_CMAKE_DIRECTORY}/ContainerPackaging.cmake) include(${CELIX_CMAKE_DIRECTORY}/DockerPackaging.cmake) include(${CELIX_CMAKE_DIRECTORY}/Runtimes.cmake) include(${CELIX_CMAKE_DIRECTORY}/Generic.cmake) - -#find required packages -find_package(CURL REQUIRED) #framework, etcdlib -find_package(ZLIB REQUIRED) #framework -find_package(UUID REQUIRED) #framework -find_package(Jansson REQUIRED) #etcdlib, dfi -find_package(FFI REQUIRED) #dfi - -if (NOT TARGET ZLIB::ZLIB) - #Note more recent zlib will create ZLIB::ZLIB target - message("Note ZLIB::ZLIB target not created by find_package(ZLIB). Creating ZLIB::ZLIB Target.") - add_library(ZLIB::ZLIB SHARED IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}" - ) -endif () - -if (NOT TARGET CURL::libcurl) - #Note more recent curl will create CURL::libcurl target - message("Note CURL::libcurl target not created by find_package(CURL). Creating CURL::libcurl Target.") - add_library(CURL::libcurl SHARED IMPORTED) - set_target_properties(CURL::libcurl PROPERTIES - IMPORTED_LOCATION "${CURL_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" - ) -endif () - -if (NOT TARGET Jansson) - #Note if JanssonConfig is present on system this is not needed - message("Note Jansson target not created by find_package(Jansson). Creating Jansson Target.") - add_library(Jansson SHARED IMPORTED) - set_target_properties(Jansson PROPERTIES - IMPORTED_LOCATION "${JANSSON_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${JANSSON_INCLUDE_DIR}" - ) -endif ()
