This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch feature/579-automatic-dependency-deduction in repository https://gitbox.apache.org/repos/asf/celix.git
commit 0c216c80d9e29973becdd2667d17fe1ac9cfd69c Author: PengZheng <[email protected]> AuthorDate: Thu Jun 29 09:23:01 2023 +0800 Add missing build options. --- bundles/remote_services/CMakeLists.txt | 1 - .../remote_service_admin_shm_v2/CMakeLists.txt | 1 + .../thpool/CMakeLists.txt | 0 .../thpool/LICENSE | 0 .../thpool/README.md | 0 .../thpool/include/thpool.h | 0 .../thpool/src/thpool.c | 0 conanfile.py | 10 + examples/celix-examples/dm_example/CMakeLists.txt | 1 - libs/dependency_manager/CMakeLists.txt | 65 +++-- libs/dependency_manager_cxx/CMakeLists.txt | 36 +-- libs/framework/CMakeLists.txt | 127 ++++---- libs/rcm/CMakeLists.txt | 37 +-- libs/utils/CMakeLists.txt | 325 +++++++++++---------- 14 files changed, 313 insertions(+), 290 deletions(-) diff --git a/bundles/remote_services/CMakeLists.txt b/bundles/remote_services/CMakeLists.txt index c62a388d..04821b75 100644 --- a/bundles/remote_services/CMakeLists.txt +++ b/bundles/remote_services/CMakeLists.txt @@ -18,7 +18,6 @@ celix_subproject(REMOTE_SERVICE_ADMIN "Option to enable building the Remote Service Admin Service bundles" ON DEPS CELIX_DFI) if (REMOTE_SERVICE_ADMIN) - add_subdirectory(thpool) add_subdirectory(remote_services_api) add_subdirectory(rsa_spi) add_subdirectory(rsa_common) diff --git a/bundles/remote_services/remote_service_admin_shm_v2/CMakeLists.txt b/bundles/remote_services/remote_service_admin_shm_v2/CMakeLists.txt index c475f3c4..e9ce5fe2 100644 --- a/bundles/remote_services/remote_service_admin_shm_v2/CMakeLists.txt +++ b/bundles/remote_services/remote_service_admin_shm_v2/CMakeLists.txt @@ -22,6 +22,7 @@ endif () celix_subproject(RSA_REMOTE_SERVICE_ADMIN_SHM_V2 "Option to enable building the Remote Service Admin Service SHM V2 bundle" RSA_REMOTE_SERVICE_ADMIN_SHM_V2_DEFAULT) if (RSA_REMOTE_SERVICE_ADMIN_SHM_V2) + add_subdirectory(thpool) add_subdirectory(shm_pool) add_subdirectory(rsa_shm) diff --git a/bundles/remote_services/thpool/CMakeLists.txt b/bundles/remote_services/remote_service_admin_shm_v2/thpool/CMakeLists.txt similarity index 100% rename from bundles/remote_services/thpool/CMakeLists.txt rename to bundles/remote_services/remote_service_admin_shm_v2/thpool/CMakeLists.txt diff --git a/bundles/remote_services/thpool/LICENSE b/bundles/remote_services/remote_service_admin_shm_v2/thpool/LICENSE similarity index 100% rename from bundles/remote_services/thpool/LICENSE rename to bundles/remote_services/remote_service_admin_shm_v2/thpool/LICENSE diff --git a/bundles/remote_services/thpool/README.md b/bundles/remote_services/remote_service_admin_shm_v2/thpool/README.md similarity index 100% rename from bundles/remote_services/thpool/README.md rename to bundles/remote_services/remote_service_admin_shm_v2/thpool/README.md diff --git a/bundles/remote_services/thpool/include/thpool.h b/bundles/remote_services/remote_service_admin_shm_v2/thpool/include/thpool.h similarity index 100% rename from bundles/remote_services/thpool/include/thpool.h rename to bundles/remote_services/remote_service_admin_shm_v2/thpool/include/thpool.h diff --git a/bundles/remote_services/thpool/src/thpool.c b/bundles/remote_services/remote_service_admin_shm_v2/thpool/src/thpool.c similarity index 100% rename from bundles/remote_services/thpool/src/thpool.c rename to bundles/remote_services/remote_service_admin_shm_v2/thpool/src/thpool.c diff --git a/conanfile.py b/conanfile.py index cb0c99f9..a3446e23 100644 --- a/conanfile.py +++ b/conanfile.py @@ -79,6 +79,11 @@ class CelixConan(ConanFile): "build_pushstreams": [True, False], "build_experimental": [True, False], "build_celix_dfi": [True, False], + "build_dependency_manager": [True, False], + "build_dependency_manager_cxx": [True, False], + "build_framework": [True, False], + "build_rcm": [True, False], + "build_utils": [True, False], "celix_cxx14": [True, False], "celix_cxx17": [True, False], "celix_install_deprecated_api": [True, False], @@ -127,6 +132,11 @@ class CelixConan(ConanFile): "build_pushstreams": False, "build_experimental": False, "build_celix_dfi": False, + "build_dependency_manager": False, + "build_dependency_manager_cxx": False, + "build_framework": False, + "build_rcm": False, + "build_utils": False, "celix_cxx14": True, "celix_cxx17": True, "celix_install_deprecated_api": False, diff --git a/examples/celix-examples/dm_example/CMakeLists.txt b/examples/celix-examples/dm_example/CMakeLists.txt index 278e32f2..27334c11 100644 --- a/examples/celix-examples/dm_example/CMakeLists.txt +++ b/examples/celix-examples/dm_example/CMakeLists.txt @@ -28,7 +28,6 @@ add_celix_container(dm_example BUNDLES Celix::shell Celix::shell_tui - Celix::dm_shell dm_example_phase1 dm_example_phase2a diff --git a/libs/dependency_manager/CMakeLists.txt b/libs/dependency_manager/CMakeLists.txt index 8dbc604b..2c1f759b 100644 --- a/libs/dependency_manager/CMakeLists.txt +++ b/libs/dependency_manager/CMakeLists.txt @@ -16,40 +16,43 @@ # under the License. #dummy libaries to ensure backward compatability with projects using the dependency manager libs/shell -add_library(dependency_manager_static STATIC src/dm_activator.c) -celix_deprecated_framework_headers(dependency_manager_static) -target_include_directories(dependency_manager_static PUBLIC - $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api> -) -if (APPLE) - target_link_libraries(dependency_manager_static Celix::framework "-undefined dynamic_lookup") -else() - target_link_libraries(dependency_manager_static Celix::framework) -endif() +celix_subproject(DEPENDENCY_MANAGER "Option to enable building the legacy Dependency Manager" ON) +if (DEPENDENCY_MANAGER) + add_library(dependency_manager_static STATIC src/dm_activator.c) + celix_deprecated_framework_headers(dependency_manager_static) + target_include_directories(dependency_manager_static PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api> + ) + if (APPLE) + target_link_libraries(dependency_manager_static Celix::framework "-undefined dynamic_lookup") + else() + target_link_libraries(dependency_manager_static Celix::framework) + endif() -add_library(dependency_manager_so SHARED src/dm_activator.c) -celix_deprecated_framework_headers(dependency_manager_so) -target_include_directories(dependency_manager_so PUBLIC - $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api> -) -if (APPLE) - target_link_libraries(dependency_manager_so Celix::framework "-undefined dynamic_lookup") -else() - target_link_libraries(dependency_manager_so Celix::framework) -endif() + add_library(dependency_manager_so SHARED src/dm_activator.c) + celix_deprecated_framework_headers(dependency_manager_so) + target_include_directories(dependency_manager_so PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api> + ) + if (APPLE) + target_link_libraries(dependency_manager_so Celix::framework "-undefined dynamic_lookup") + else() + target_link_libraries(dependency_manager_so Celix::framework) + endif() -#now part of the the shell bundle -add_library(dm_shell INTERFACE) + #now part of the the shell bundle + add_library(dm_shell INTERFACE) -celix_deprecated_utils_headers(dependency_manager_static) -celix_deprecated_utils_headers(dependency_manager_so) + celix_deprecated_utils_headers(dependency_manager_static) + celix_deprecated_utils_headers(dependency_manager_so) -#Setup target aliases to match external usage -add_library(Celix::dm_shell ALIAS dm_shell) -add_library(Celix::dependency_manager_static ALIAS dependency_manager_static) -add_library(Celix::dependency_manager_so ALIAS dependency_manager_so) + #Setup target aliases to match external usage + add_library(Celix::dm_shell ALIAS dm_shell) + add_library(Celix::dependency_manager_static ALIAS dependency_manager_static) + add_library(Celix::dependency_manager_so ALIAS dependency_manager_so) -#install dummy libs -install(TARGETS dependency_manager_static dependency_manager_so dm_shell EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix) + #install dummy libs + install(TARGETS dependency_manager_static dependency_manager_so dm_shell EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix) +endif () diff --git a/libs/dependency_manager_cxx/CMakeLists.txt b/libs/dependency_manager_cxx/CMakeLists.txt index 15fc29df..e28880d0 100644 --- a/libs/dependency_manager_cxx/CMakeLists.txt +++ b/libs/dependency_manager_cxx/CMakeLists.txt @@ -14,23 +14,25 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +celix_subproject(DEPENDENCY_MANAGER_CXX "Option to enable building the legacy C++ Dependency Manager" ON) +if (DEPENDENCY_MANAGER_CXX) + add_library(dependency_manager_cxx_static STATIC + src/dm_activator.cc + ) + celix_deprecated_framework_headers(dependency_manager_cxx_static) + set_target_properties(dependency_manager_cxx_static PROPERTIES OUTPUT_NAME "celix_dependency_manager_cxx_static") + target_compile_options(dependency_manager_cxx_static PRIVATE -fPIC) + target_compile_options(dependency_manager_cxx_static PRIVATE -Wno-deprecated-declarations) + if (APPLE) + target_link_libraries(dependency_manager_cxx_static Celix::framework "-undefined dynamic_lookup") + else() + target_link_libraries(dependency_manager_cxx_static Celix::framework) + endif() -add_library(dependency_manager_cxx_static STATIC - src/dm_activator.cc -) -celix_deprecated_framework_headers(dependency_manager_cxx_static) -set_target_properties(dependency_manager_cxx_static PROPERTIES OUTPUT_NAME "celix_dependency_manager_cxx_static") -target_compile_options(dependency_manager_cxx_static PRIVATE -fPIC) -target_compile_options(dependency_manager_cxx_static PRIVATE -Wno-deprecated-declarations) -if (APPLE) - target_link_libraries(dependency_manager_cxx_static Celix::framework "-undefined dynamic_lookup") -else() - target_link_libraries(dependency_manager_cxx_static Celix::framework) -endif() + install(TARGETS dependency_manager_cxx_static EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework) -install(TARGETS dependency_manager_cxx_static EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework) + celix_deprecated_utils_headers(dependency_manager_cxx_static) -celix_deprecated_utils_headers(dependency_manager_cxx_static) - -#Setup target aliases to match external usage -add_library(Celix::dependency_manager_cxx_static ALIAS dependency_manager_cxx_static) + #Setup target aliases to match external usage + add_library(Celix::dependency_manager_cxx_static ALIAS dependency_manager_cxx_static) +endif () diff --git a/libs/framework/CMakeLists.txt b/libs/framework/CMakeLists.txt index 82968846..0bd6852c 100644 --- a/libs/framework/CMakeLists.txt +++ b/libs/framework/CMakeLists.txt @@ -15,73 +15,76 @@ # specific language governing permissions and limitations # under the License. -find_package(ZLIB REQUIRED) -find_package(libuuid REQUIRED) -find_package(CURL REQUIRED) +celix_subproject(FRAMEWORK "Option to build the Celix Framework" ON) +if (FRAMEWORK) + find_package(ZLIB REQUIRED) + find_package(libuuid REQUIRED) + find_package(CURL REQUIRED) -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 - src/framework.c src/manifest.c - src/manifest_parser.c src/module.c - src/requirement.c src/capability.c src/resolver.c src/wire.c - src/service_reference.c src/service_registration.c - src/service_registry.c src/service_tracker.c src/service_tracker_customizer.c - src/celix_log.c src/celix_launcher.c - src/celix_framework_factory.c - src/dm_dependency_manager_impl.c src/dm_component_impl.c - src/dm_service_dependency.c src/celix_libloader.c - src/framework_bundle_lifecycle_handler.c - src/celix_bundle_state.c - src/celix_framework_utils.c - src/celix_module_private.h) -set(FRAMEWORK_DEPS libuuid::libuuid CURL::libcurl ZLIB::ZLIB ${CMAKE_DL_LIBS}) + 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 + src/framework.c src/manifest.c + src/manifest_parser.c src/module.c + src/requirement.c src/capability.c src/resolver.c src/wire.c + src/service_reference.c src/service_registration.c + src/service_registry.c src/service_tracker.c src/service_tracker_customizer.c + src/celix_log.c src/celix_launcher.c + src/celix_framework_factory.c + src/dm_dependency_manager_impl.c src/dm_component_impl.c + src/dm_service_dependency.c src/celix_libloader.c + src/framework_bundle_lifecycle_handler.c + src/celix_bundle_state.c + src/celix_framework_utils.c + src/celix_module_private.h) + set(FRAMEWORK_DEPS libuuid::libuuid CURL::libcurl ZLIB::ZLIB ${CMAKE_DL_LIBS}) -add_library(framework SHARED ${FRAMEWORK_SRC}) + add_library(framework SHARED ${FRAMEWORK_SRC}) -set_target_properties(framework - PROPERTIES - C_VISIBILITY_PRESET hidden - "VERSION" "${CELIX_MAJOR}.${CELIX_MINOR}.${CELIX_MICRO}" - "SOVERSION" ${CELIX_MAJOR} - OUTPUT_NAME "celix_framework") -target_include_directories(framework PUBLIC - $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> -) -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 -target_link_libraries(framework PUBLIC Celix::utils ${CELIX_OPTIONAL_EXTRA_LIBS}) -target_link_libraries(framework PRIVATE ${FRAMEWORK_DEPS}) + set_target_properties(framework + PROPERTIES + C_VISIBILITY_PRESET hidden + "VERSION" "${CELIX_MAJOR}.${CELIX_MINOR}.${CELIX_MICRO}" + "SOVERSION" ${CELIX_MAJOR} + OUTPUT_NAME "celix_framework") + target_include_directories(framework PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> + ) + 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 + target_link_libraries(framework PUBLIC Celix::utils ${CELIX_OPTIONAL_EXTRA_LIBS}) + target_link_libraries(framework PRIVATE ${FRAMEWORK_DEPS}) -generate_export_header(framework - BASE_NAME "CELIX_FRAMEWORK" - EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/celix/gen/includes/framework/celix_framework_export.h") -target_include_directories(framework PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/celix/gen/includes/framework>) -celix_deprecated_utils_headers(framework) + generate_export_header(framework + BASE_NAME "CELIX_FRAMEWORK" + EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/celix/gen/includes/framework/celix_framework_export.h") + target_include_directories(framework PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/celix/gen/includes/framework>) + celix_deprecated_utils_headers(framework) -install(TARGETS framework EXPORT celix LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework) -install(DIRECTORY include_deprecated/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework) -install(DIRECTORY ${CMAKE_BINARY_DIR}/celix/gen/includes/framework/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework) + install(TARGETS framework EXPORT celix LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework) + install(DIRECTORY include_deprecated/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework) + install(DIRECTORY ${CMAKE_BINARY_DIR}/celix/gen/includes/framework/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework) -#Alias setup to match external usage -add_library(Celix::framework ALIAS framework) + #Alias setup to match external usage + add_library(Celix::framework ALIAS framework) -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 - ${CMAKE_BINARY_DIR}/celix/gen/includes/framework - ${CMAKE_CURRENT_LIST_DIR}/include_deprecated - ) - 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 - target_link_libraries(framework_cut PUBLIC Celix::utils ${CELIX_OPTIONAL_EXTRA_LIBS} ${FRAMEWORK_DEPS}) - celix_deprecated_utils_headers(framework_cut) - add_subdirectory(gtest) -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 + ${CMAKE_BINARY_DIR}/celix/gen/includes/framework + ${CMAKE_CURRENT_LIST_DIR}/include_deprecated + ) + 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 + target_link_libraries(framework_cut PUBLIC Celix::utils ${CELIX_OPTIONAL_EXTRA_LIBS} ${FRAMEWORK_DEPS}) + celix_deprecated_utils_headers(framework_cut) + add_subdirectory(gtest) + endif() -add_subdirectory(benchmark) + add_subdirectory(benchmark) +endif () diff --git a/libs/rcm/CMakeLists.txt b/libs/rcm/CMakeLists.txt index 23e42266..86ce6e16 100644 --- a/libs/rcm/CMakeLists.txt +++ b/libs/rcm/CMakeLists.txt @@ -15,24 +15,27 @@ # specific language governing permissions and limitations # under the License. -set(RCM_SOURCES src/celix_resource.c src/celix_capability.c src/celix_requirement.c) -set(RCM_PUBLIC_LIBS Celix::utils) -SET(RCM_PRIVATE_LIBS ) +celix_subproject(RCM "Option to enable building the Requirement-Capability-Model library" ON) +if (RCM) + set(RCM_SOURCES src/celix_resource.c src/celix_capability.c src/celix_requirement.c) + set(RCM_PUBLIC_LIBS Celix::utils) + SET(RCM_PRIVATE_LIBS ) -add_library(rcm STATIC ${RCM_SOURCES}) -set_target_properties(rcm PROPERTIES - OUTPUT_NAME "celix_rcm" - VERSION 0.0.1 - SOVERSION 0) -target_link_libraries(rcm PUBLIC ${RCM_PUBLIC_LIBS} PRIVATE ${RCM_PRIVATE_LIBS}) -target_include_directories(rcm PRIVATE src PUBLIC include) -celix_target_hide_symbols(rcm) -add_library(Celix::rcm ALIAS rcm) + add_library(rcm STATIC ${RCM_SOURCES}) + set_target_properties(rcm PROPERTIES + OUTPUT_NAME "celix_rcm" + VERSION 0.0.1 + SOVERSION 0) + target_link_libraries(rcm PUBLIC ${RCM_PUBLIC_LIBS} PRIVATE ${RCM_PRIVATE_LIBS}) + target_include_directories(rcm PRIVATE src PUBLIC include) + celix_target_hide_symbols(rcm) + add_library(Celix::rcm ALIAS rcm) -if (ENABLE_TESTING) - add_library(rcm_cut STATIC ${RCM_SOURCES}) - target_link_libraries(rcm_cut PUBLIC ${RCM_PUBLIC_LIBS} PRIVATE ${RCM_PRIVATE_LIBS}) - target_include_directories(rcm_cut PRIVATE src PUBLIC include) + if (ENABLE_TESTING) + add_library(rcm_cut STATIC ${RCM_SOURCES}) + target_link_libraries(rcm_cut PUBLIC ${RCM_PUBLIC_LIBS} PRIVATE ${RCM_PRIVATE_LIBS}) + target_include_directories(rcm_cut PRIVATE src PUBLIC include) - add_subdirectory(gtest) + add_subdirectory(gtest) + endif () endif () diff --git a/libs/utils/CMakeLists.txt b/libs/utils/CMakeLists.txt index eca64811..6b418aa8 100644 --- a/libs/utils/CMakeLists.txt +++ b/libs/utils/CMakeLists.txt @@ -15,173 +15,176 @@ # specific language governing permissions and limitations # under the License. -find_package(libzip REQUIRED) - -set(MEMSTREAM_SOURCES ) -set(MEMSTREAM_INCLUDES ) -include(CheckFunctionExists) -#check_function_exists(fmemopen FMEMOPEN_EXISTS) -check_function_exists(open_memstream OPEN_MEMSTREAM_EXISTS) -if (NOT OPEN_MEMSTREAM_EXISTS) - set(MEMSTREAM_SOURCES src/memstream/open_memstream.c src/memstream/fmemopen.c ${MEMSTREAM_SOURCES}) - set(MEMSTREAM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/memstream ${MEMSTREAM_INCLUDE_DIR}) - install(DIRECTORY include/memstream/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/memstream COMPONENT framework) -endif() - -set(UTILS_SRC - src/array_list.c - src/hash_map.c - src/linked_list.c - src/linked_list_iterator.c - src/celix_threads.c - src/version.c - src/version_range.c - src/properties.c - src/utils.c - src/ip_utils.c - src/filter.c - src/celix_log_utils.c - src/celix_hash_map.c - src/celix_file_utils.c - src/celix_convert_utils.c - src/celix_errno.c - src/celix_err.c - ${MEMSTREAM_SOURCES} - ) -set(UTILS_PRIVATE_DEPS libzip::libzip) -set(UTILS_PUBLIC_DEPS) - -add_library(utils SHARED ${UTILS_SRC}) - -target_link_libraries(utils PRIVATE libzip::libzip) -set_target_properties(utils - PROPERTIES - C_VISIBILITY_PRESET hidden - SOVERSION ${CELIX_MAJOR} - OUTPUT_NAME "celix_utils") - -if (NOT OPEN_MEMSTREAM_EXISTS) - target_compile_definitions(utils PUBLIC -DCELIX_UTILS_NO_MEMSTREAM_AVAILABLE) -endif () - -if (ANDROID) - target_compile_definitions(utils PRIVATE -DUSE_FILE32API) -endif () - -if (NOT APPLE) - set(UTILS_PUBLIC_DEPS ${UTILS_PUBLIC_DEPS} rt) -endif () - -target_include_directories(utils PUBLIC - $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> - $<BUILD_INTERFACE:${MEMSTREAM_INCLUDE_DIR}> - ) -target_include_directories(utils PRIVATE src include_deprecated) -IF(UNIX AND NOT ANDROID) - set(UTILS_PRIVATE_DEPS ${UTILS_PRIVATE_DEPS} m pthread) -ELSEIF(ANDROID) - set(UTILS_PRIVATE_DEPS ${UTILS_PRIVATE_DEPS} m) -ENDIF() - -target_link_libraries(utils PUBLIC ${UTILS_PUBLIC_DEPS} PRIVATE ${UTILS_PRIVATE_DEPS}) -generate_export_header(utils - BASE_NAME "CELIX_UTILS" - EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/celix/gen/includes/utils/celix_utils_export.h") -target_include_directories(utils PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/celix/gen/includes/utils>) - -#Configure celix_err_constant header file -set(CELIX_ERR_BUFFER_SIZE 512 CACHE STRING "The size of the thread-specific buffer used for library error messages") -configure_file("${CMAKE_CURRENT_LIST_DIR}/src/celix_err_constants.h.in" "${CMAKE_BINARY_DIR}/celix/gen/includes/utils/celix_err_constants.h" @ONLY) - -install(TARGETS utils EXPORT celix LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils) -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils/ - COMPONENT framework PATTERN memstream* EXCLUDE) -install(DIRECTORY ${CMAKE_BINARY_DIR}/celix/gen/includes/utils/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils/ - COMPONENT framework) - -if (CELIX_INSTALL_DEPRECATED_API) - install(DIRECTORY include_deprecated/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils COMPONENT framework) -endif () - -#Alias setup to match external usage -add_library(Celix::utils ALIAS utils) - - -if (ENABLE_TESTING) - add_library(utils_cut STATIC ${UTILS_SRC}) - target_include_directories(utils_cut PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/include - ${MEMSTREAM_INCLUDE_DIR} - ${CMAKE_BINARY_DIR}/celix/gen/includes/utils - src include_deprecated - ) - target_link_libraries(utils_cut PUBLIC ${UTILS_PUBLIC_DEPS} ${UTILS_PRIVATE_DEPS}) - - if (CELIX_CXX17) #utils tests are C++17 - add_subdirectory(gtest) +celix_subproject(UTILS "Option to enable building the Utilities library" ON) +if (UTILS) + find_package(libzip REQUIRED) + + set(MEMSTREAM_SOURCES ) + set(MEMSTREAM_INCLUDES ) + include(CheckFunctionExists) + #check_function_exists(fmemopen FMEMOPEN_EXISTS) + check_function_exists(open_memstream OPEN_MEMSTREAM_EXISTS) + if (NOT OPEN_MEMSTREAM_EXISTS) + set(MEMSTREAM_SOURCES src/memstream/open_memstream.c src/memstream/fmemopen.c ${MEMSTREAM_SOURCES}) + set(MEMSTREAM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/memstream ${MEMSTREAM_INCLUDE_DIR}) + install(DIRECTORY include/memstream/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/memstream COMPONENT framework) endif() - find_package(CppUTest) - - if (CppUTest_FOUND) - include_directories(SYSTEM PRIVATE ${CppUTest_INCLUDE_DIR}) - include_directories(include) - include_directories(src) - - add_executable(hash_map_test private/test/hash_map_test.cpp) - target_include_directories(hash_map_test PRIVATE include_deprecated) - target_link_libraries(hash_map_test utils_cut CppUTest::CppUTest pthread) - - add_executable(array_list_test private/test/array_list_test.cpp) - target_include_directories(array_list_test PRIVATE include_deprecated) - target_link_libraries(array_list_test utils_cut CppUTest::CppUTest pthread) - - add_executable(linked_list_test private/test/linked_list_test.cpp) - target_include_directories(linked_list_test PRIVATE include_deprecated) - target_link_libraries(linked_list_test utils_cut CppUTest::CppUTest pthread) - - add_executable(properties_test private/test/properties_test.cpp) - target_include_directories(properties_test PRIVATE include_deprecated) - target_link_libraries(properties_test CppUTest::CppUTest CppUTest::CppUTestExt utils_cut pthread) - - add_executable(ip_utils_test private/test/ip_utils_test.cpp) - target_include_directories(ip_utils_test PRIVATE include_deprecated) - target_link_libraries(ip_utils_test CppUTest::CppUTest utils_cut pthread) - - add_executable(version_test private/test/version_test.cpp) - target_include_directories(version_test PRIVATE include_deprecated) - target_link_libraries(version_test CppUTest::CppUTest utils_cut pthread) + set(UTILS_SRC + src/array_list.c + src/hash_map.c + src/linked_list.c + src/linked_list_iterator.c + src/celix_threads.c + src/version.c + src/version_range.c + src/properties.c + src/utils.c + src/ip_utils.c + src/filter.c + src/celix_log_utils.c + src/celix_hash_map.c + src/celix_file_utils.c + src/celix_convert_utils.c + src/celix_errno.c + src/celix_err.c + ${MEMSTREAM_SOURCES} + ) + set(UTILS_PRIVATE_DEPS libzip::libzip) + set(UTILS_PUBLIC_DEPS) + add_library(utils SHARED ${UTILS_SRC}) - if (LINKER_WRAP_SUPPORTED) - add_executable(version_ei_test private/test/version_ei_test.cc) - target_include_directories(version_ei_test PRIVATE include_deprecated) - target_link_libraries(version_ei_test CppUTest::CppUTest utils_cut Celix::malloc_ei Celix::utils_ei pthread) - add_test(NAME version_ei_test COMMAND version_ei_test) - endif () + target_link_libraries(utils PRIVATE libzip::libzip) + set_target_properties(utils + PROPERTIES + C_VISIBILITY_PRESET hidden + SOVERSION ${CELIX_MAJOR} + OUTPUT_NAME "celix_utils") - configure_file(private/resources-test/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY) + if (NOT OPEN_MEMSTREAM_EXISTS) + target_compile_definitions(utils PUBLIC -DCELIX_UTILS_NO_MEMSTREAM_AVAILABLE) + endif () - add_test(NAME run_array_list_test COMMAND array_list_test) - add_test(NAME run_hash_map_test COMMAND hash_map_test) - add_test(NAME run_linked_list_test COMMAND linked_list_test) - add_test(NAME run_properties_test COMMAND properties_test) - add_test(NAME run_ip_utils_test COMMAND ip_utils_test) - add_test(NAME version_test COMMAND version_test) + if (ANDROID) + target_compile_definitions(utils PRIVATE -DUSE_FILE32API) + endif () - setup_target_for_coverage(array_list_test) - setup_target_for_coverage(hash_map_test) - setup_target_for_coverage(linked_list_test) - setup_target_for_coverage(properties_test) - setup_target_for_coverage(ip_utils_test) - setup_target_for_coverage(version_test) - else () - message(WARNING "Cannot find CppUTest, deprecated cpputest-based unit test will not be added") - endif () #end CppUTest_FOUND + if (NOT APPLE) + set(UTILS_PUBLIC_DEPS ${UTILS_PUBLIC_DEPS} rt) + endif () + target_include_directories(utils PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> + $<BUILD_INTERFACE:${MEMSTREAM_INCLUDE_DIR}> + ) + target_include_directories(utils PRIVATE src include_deprecated) + IF(UNIX AND NOT ANDROID) + set(UTILS_PRIVATE_DEPS ${UTILS_PRIVATE_DEPS} m pthread) + ELSEIF(ANDROID) + set(UTILS_PRIVATE_DEPS ${UTILS_PRIVATE_DEPS} m) + ENDIF() + + target_link_libraries(utils PUBLIC ${UTILS_PUBLIC_DEPS} PRIVATE ${UTILS_PRIVATE_DEPS}) + generate_export_header(utils + BASE_NAME "CELIX_UTILS" + EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/celix/gen/includes/utils/celix_utils_export.h") + target_include_directories(utils PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/celix/gen/includes/utils>) + + #Configure celix_err_constant header file + set(CELIX_ERR_BUFFER_SIZE 512 CACHE STRING "The size of the thread-specific buffer used for library error messages") + configure_file("${CMAKE_CURRENT_LIST_DIR}/src/celix_err_constants.h.in" "${CMAKE_BINARY_DIR}/celix/gen/includes/utils/celix_err_constants.h" @ONLY) + + install(TARGETS utils EXPORT celix LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils) + install(DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils/ + COMPONENT framework PATTERN memstream* EXCLUDE) + install(DIRECTORY ${CMAKE_BINARY_DIR}/celix/gen/includes/utils/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils/ + COMPONENT framework) + + if (CELIX_INSTALL_DEPRECATED_API) + install(DIRECTORY include_deprecated/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/utils COMPONENT framework) + endif () + + #Alias setup to match external usage + add_library(Celix::utils ALIAS utils) + + + if (ENABLE_TESTING) + add_library(utils_cut STATIC ${UTILS_SRC}) + target_include_directories(utils_cut PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/include + ${MEMSTREAM_INCLUDE_DIR} + ${CMAKE_BINARY_DIR}/celix/gen/includes/utils + src include_deprecated + ) + target_link_libraries(utils_cut PUBLIC ${UTILS_PUBLIC_DEPS} ${UTILS_PRIVATE_DEPS}) + + if (CELIX_CXX17) #utils tests are C++17 + add_subdirectory(gtest) + endif() + + find_package(CppUTest) + + if (CppUTest_FOUND) + include_directories(SYSTEM PRIVATE ${CppUTest_INCLUDE_DIR}) + include_directories(include) + include_directories(src) + + add_executable(hash_map_test private/test/hash_map_test.cpp) + target_include_directories(hash_map_test PRIVATE include_deprecated) + target_link_libraries(hash_map_test utils_cut CppUTest::CppUTest pthread) + + add_executable(array_list_test private/test/array_list_test.cpp) + target_include_directories(array_list_test PRIVATE include_deprecated) + target_link_libraries(array_list_test utils_cut CppUTest::CppUTest pthread) + + add_executable(linked_list_test private/test/linked_list_test.cpp) + target_include_directories(linked_list_test PRIVATE include_deprecated) + target_link_libraries(linked_list_test utils_cut CppUTest::CppUTest pthread) + + add_executable(properties_test private/test/properties_test.cpp) + target_include_directories(properties_test PRIVATE include_deprecated) + target_link_libraries(properties_test CppUTest::CppUTest CppUTest::CppUTestExt utils_cut pthread) + + add_executable(ip_utils_test private/test/ip_utils_test.cpp) + target_include_directories(ip_utils_test PRIVATE include_deprecated) + target_link_libraries(ip_utils_test CppUTest::CppUTest utils_cut pthread) + + add_executable(version_test private/test/version_test.cpp) + target_include_directories(version_test PRIVATE include_deprecated) + target_link_libraries(version_test CppUTest::CppUTest utils_cut pthread) + + + if (LINKER_WRAP_SUPPORTED) + add_executable(version_ei_test private/test/version_ei_test.cc) + target_include_directories(version_ei_test PRIVATE include_deprecated) + target_link_libraries(version_ei_test CppUTest::CppUTest utils_cut Celix::malloc_ei Celix::utils_ei pthread) + add_test(NAME version_ei_test COMMAND version_ei_test) + endif () + + configure_file(private/resources-test/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY) + + add_test(NAME run_array_list_test COMMAND array_list_test) + add_test(NAME run_hash_map_test COMMAND hash_map_test) + add_test(NAME run_linked_list_test COMMAND linked_list_test) + add_test(NAME run_properties_test COMMAND properties_test) + add_test(NAME run_ip_utils_test COMMAND ip_utils_test) + add_test(NAME version_test COMMAND version_test) + + setup_target_for_coverage(array_list_test) + setup_target_for_coverage(hash_map_test) + setup_target_for_coverage(linked_list_test) + setup_target_for_coverage(properties_test) + setup_target_for_coverage(ip_utils_test) + setup_target_for_coverage(version_test) + else () + message(WARNING "Cannot find CppUTest, deprecated cpputest-based unit test will not be added") + endif () #end CppUTest_FOUND + + endif () + + add_subdirectory(benchmark) endif () - -add_subdirectory(benchmark)
