You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/07/14 14:02:07 UTC
[celix] 10/17: Merge branch 'master' into feature/579-automatic-dependency-deduction
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 554311977b2441833ee2b3548379ca46279890a0
Merge: 276afafe 456de193
Author: PengZheng <ho...@gmail.com>
AuthorDate: Wed Jul 12 19:55:19 2023 +0800
Merge branch 'master' into feature/579-automatic-dependency-deduction
# Conflicts:
# libs/framework/CMakeLists.txt
# libs/utils/CMakeLists.txt
.clang-format | 2 +-
.../log_admin/gtest/src/LogAdminTestSuite.cc | 20 +-
.../src/pubsub_topology_manager.c | 1 -
.../topology_manager/tms_tst/tms_tests.cpp | 28 +-
documents/README.md | 1 +
documents/framework.md | 35 +-
documents/scheduled_events .md | 136 ++++
.../readme_c_examples/CMakeLists.txt | 6 +
.../src/schedule_events_bundle_activator.c | 70 ++
.../readme_cxx_examples/CMakeLists.txt | 7 +
.../src/ScheduleEventsBundleActivator.cc | 51 ++
libs/framework/CMakeLists.txt | 3 +-
libs/framework/gtest/CMakeLists.txt | 4 +-
.../src/CelixBundleContextServicesTestSuite.cc | 2 +-
.../framework/gtest/src/CelixFrameworkTestSuite.cc | 19 +
.../framework/gtest/src/ScheduledEventTestSuite.cc | 706 +++++++++++++++++++++
.../ScheduledEventWithErrorInjectionTestSuite.cc | 56 ++
libs/framework/include/celix/BundleContext.h | 9 +
libs/framework/include/celix/Framework.h | 2 +-
libs/framework/include/celix/ScheduledEvent.h | 162 +++++
.../include/celix/ScheduledEventBuilder.h | 128 ++++
libs/framework/include/celix/dm/Component.h | 2 +
.../framework/include/celix/dm/DependencyManager.h | 3 +
libs/framework/include/celix_bundle_context.h | 159 ++++-
libs/framework/include/celix_constants.h | 15 +
libs/framework/include/celix_dependency_manager.h | 13 +-
libs/framework/include/celix_framework.h | 61 +-
libs/framework/src/bundle_context.c | 56 +-
libs/framework/src/celix_scheduled_event.c | 301 +++++++++
libs/framework/src/celix_scheduled_event.h | 191 ++++++
libs/framework/src/framework.c | 417 +++++++++---
libs/framework/src/framework_private.h | 106 +++-
libs/framework/src/service_tracker.c | 81 ++-
libs/utils/CMakeLists.txt | 7 +-
libs/utils/gtest/CMakeLists.txt | 1 +
libs/utils/gtest/src/LogTestSuite.cc | 56 ++
libs/utils/gtest/src/LogUtilsTestSuite.cc | 28 +-
libs/utils/gtest/src/ThreadsTestSuite.cc | 40 +-
libs/utils/gtest/src/TimeUtilsTestSuite.cc | 81 ++-
libs/utils/include/celix_errno.h | 1 +
libs/utils/include/celix_log_level.h | 46 +-
libs/utils/include/celix_log_utils.h | 20 +-
libs/utils/include/celix_threads.h | 62 +-
libs/utils/include/celix_utils.h | 16 +
libs/utils/src/celix_log_level.c | 97 +++
libs/utils/src/celix_log_utils.c | 68 +-
libs/utils/src/celix_threads.c | 59 +-
libs/utils/src/utils.c | 36 ++
48 files changed, 3135 insertions(+), 336 deletions(-)
diff --cc libs/framework/CMakeLists.txt
index 6fb8d6a6,3cde3860..b25c48fe
--- a/libs/framework/CMakeLists.txt
+++ b/libs/framework/CMakeLists.txt
@@@ -15,77 -15,74 +15,78 @@@
# 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(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_scheduled_event.c
-)
-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)
++ src/celix_scheduled_event.c
++ )
+ set(FRAMEWORK_DEPS libuuid::libuuid CURL::libcurl ${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)
+ if (CELIX_INSTALL_DEPRECATED_API)
+ install(DIRECTORY include_deprecated/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/framework COMPONENT framework)
+ endif ()
+ 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 --cc libs/utils/CMakeLists.txt
index e7fbcd37,e9362dc0..c8733c9c
--- a/libs/utils/CMakeLists.txt
+++ b/libs/utils/CMakeLists.txt
@@@ -15,175 -15,174 +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_level.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} src/celix_log_level.c)
-
-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_level.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)
- 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 ()
+ add_library(utils SHARED ${UTILS_SRC})
- configure_file(private/resources-test/properties.txt ${CMAKE_CURRENT_BINARY_DIR}/resources-test/properties.txt COPYONLY)
+ set_target_properties(utils
+ PROPERTIES
+ C_VISIBILITY_PRESET hidden
+ SOVERSION ${CELIX_MAJOR}
+ OUTPUT_NAME "celix_utils")
- 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 (NOT OPEN_MEMSTREAM_EXISTS)
+ target_compile_definitions(utils PUBLIC -DCELIX_UTILS_NO_MEMSTREAM_AVAILABLE)
+ 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 (ANDROID)
+ target_compile_definitions(utils PRIVATE -DUSE_FILE32API)
+ endif ()
- if (NOT APPLE)
- set(UTILS_PUBLIC_DEPS ${UTILS_PUBLIC_DEPS} rt)
- endif ()
++if (NOT APPLE)
++ set(UTILS_PUBLIC_DEPS ${UTILS_PUBLIC_DEPS} rt)
+ endif ()
-add_subdirectory(benchmark)
+ 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 ()