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

pengzheng pushed a commit to branch feature/604-global-initialization-of-curl
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to 
refs/heads/feature/604-global-initialization-of-curl by this push:
     new abca2390 Make libcurl an optional dependency of framework.
abca2390 is described below

commit abca239061bd5e1a9f32aad4b3d978b0c6cb1c9c
Author: PengZheng <[email protected]>
AuthorDate: Mon Aug 7 19:41:41 2023 +0800

    Make libcurl an optional dependency of framework.
---
 .github/workflows/macos.yml   |  1 +
 .github/workflows/ubuntu.yml  |  1 +
 conanfile.py                  |  9 ++++++---
 libs/framework/CMakeLists.txt | 21 +++++++++++++++++----
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index b1ca4bd1..23f001cf 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -31,6 +31,7 @@ jobs:
             -o celix:enable_testing_for_cxx14=True
             -o celix:enable_testing_dependency_manager_for_cxx11=True
             -o celix:enable_testing_on_ci=True
+            -o celix:framework_curlinit=False
         run: |
           #force require libcurl 7.64.1, due to a sha256 verify issue in 
libcurl/7.87.0
           conan install . celix/ci -pr:b default -pr:h default -if build 
${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 
--require-override=openssl/1.1.1s
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
index cd0505b5..aec3581d 100644
--- a/.github/workflows/ubuntu.yml
+++ b/.github/workflows/ubuntu.yml
@@ -51,6 +51,7 @@ jobs:
             -o celix:enable_testing_for_cxx14=True
             -o celix:enable_testing_dependency_manager_for_cxx11=True
             -o celix:enable_testing_on_ci=True
+            -o celix:framework_curlinit=False
         run: |
           #force require libcurl 7.64.1, due to a sha256 verify issue in 
libcurl/7.87.0
           conan install . celix/ci -pr:b release -pr:h default -if build 
${CONAN_BUILD_OPTIONS} -b missing  -b cpputest 
--require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s
diff --git a/conanfile.py b/conanfile.py
index 5a0c498b..10a66f65 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -99,6 +99,7 @@ class CelixConan(ConanFile):
         "celix_use_compression_for_bundle_zips": [True, False],
         "celix_err_buffer_size": "ANY",
         "enable_testing_on_ci": [True, False],
+        "framework_curlinit": [True, False],
     }
     default_options = {
         "enable_testing": False,
@@ -162,6 +163,7 @@ class CelixConan(ConanFile):
         "celix_use_compression_for_bundle_zips": True,
         "celix_err_buffer_size": 512,
         "enable_testing_on_ci": False,
+        "framework_curlinit": True,
     }
     _cmake = None
 
@@ -383,9 +385,10 @@ class CelixConan(ConanFile):
         if self.options.build_framework or self.options.build_pubsub:
             self.requires("libuuid/1.0.3")
             self.options['libuuid'].shared = True
-        if (self.options.build_framework or self.options.build_celix_etcdlib
-                or self.options.build_deployment_admin or 
self.options.build_rsa_discovery_common
-                or self.options.build_rsa_remote_service_admin_dfi or 
self.options.build_launcher):
+        if ((self.options.build_framework and self.options.framework_curlinit)
+                or self.options.build_celix_etcdlib or 
self.options.build_deployment_admin
+                or self.options.build_rsa_discovery_common or 
self.options.build_rsa_remote_service_admin_dfi
+                or self.options.build_launcher):
             self.requires("libcurl/[>=7.64.1 <8.0.0]")
             self.options['libcurl'].shared = True
         if self.options.build_deployment_admin:
diff --git a/libs/framework/CMakeLists.txt b/libs/framework/CMakeLists.txt
index 11278062..4eb80e9c 100644
--- a/libs/framework/CMakeLists.txt
+++ b/libs/framework/CMakeLists.txt
@@ -18,8 +18,10 @@
 celix_subproject(FRAMEWORK "Option to build the Celix Framework" ON)
 if (FRAMEWORK)
     find_package(libuuid REQUIRED)
-    find_package(CURL REQUIRED)
-
+    option(FRAMEWORK_CURLINIT "Do CURL initialization in framework" ON)
+    if (FRAMEWORK_CURLINIT)
+        find_package(CURL REQUIRED)
+    endif ()
     set(FRAMEWORK_SRC
             src/attribute.c src/bundle.c src/bundle_archive.c 
src/celix_bundle_cache.c
             src/bundle_context.c src/bundle_revision.c
@@ -38,8 +40,6 @@ if (FRAMEWORK)
             src/celix_scheduled_event.c
             src/celix_framework_bundle.c
             )
-    set(FRAMEWORK_DEPS libuuid::libuuid CURL::libcurl ${CMAKE_DL_LIBS})
-
     add_library(framework SHARED ${FRAMEWORK_SRC})
 
     set_target_properties(framework
@@ -54,7 +54,16 @@ if (FRAMEWORK)
     target_include_directories(framework PRIVATE 
${CMAKE_CURRENT_LIST_DIR}/include_deprecated)
     target_compile_options(framework PRIVATE -DUSE_FILE32API)
     target_compile_options(framework PRIVATE -Wno-deprecated-declarations) 
#note part of the api is deprecated, ignore this warning on own api
+    if (NOT FRAMEWORK_CURLINIT)
+        target_compile_definitions(framework PRIVATE CELIX_NO_CURLINIT)
+    endif ()
     target_link_libraries(framework PUBLIC Celix::utils 
${CELIX_OPTIONAL_EXTRA_LIBS})
+
+    set(FRAMEWORK_DEPS libuuid::libuuid ${CMAKE_DL_LIBS})
+    if (FRAMEWORK_CURLINIT)
+        set(FRAMEWORK_DEPS ${FRAMEWORK_DEPS} CURL::libcurl)
+    endif ()
+
     target_link_libraries(framework PRIVATE ${FRAMEWORK_DEPS})
 
     generate_export_header(framework
@@ -79,6 +88,7 @@ if (FRAMEWORK)
     endif ()
     if (ENABLE_TESTING AND CELIX_CXX17) #framework tests are C++17
         add_library(framework_cut STATIC ${FRAMEWORK_SRC})
+
         target_include_directories(framework_cut PUBLIC
                 ${CMAKE_CURRENT_LIST_DIR}/src
                 ${CMAKE_CURRENT_LIST_DIR}/include
@@ -87,6 +97,9 @@ if (FRAMEWORK)
                 )
         target_compile_options(framework_cut PRIVATE -DUSE_FILE32API)
         target_compile_options(framework_cut PRIVATE 
-Wno-deprecated-declarations) #note part of the api is deprecated, ignore this 
warning on own api
+        if (NOT FRAMEWORK_CURLINIT)
+            target_compile_definitions(framework_cut PRIVATE CELIX_NO_CURLINIT)
+        endif ()
         target_link_libraries(framework_cut PUBLIC Celix::utils 
${CELIX_OPTIONAL_EXTRA_LIBS} ${FRAMEWORK_DEPS})
         celix_deprecated_utils_headers(framework_cut)
         add_subdirectory(gtest)

Reply via email to