http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/cmake/cmake_celix/Dependencies.cmake ---------------------------------------------------------------------- diff --git a/cmake/cmake_celix/Dependencies.cmake b/cmake/cmake_celix/Dependencies.cmake deleted file mode 100644 index c02db35..0000000 --- a/cmake/cmake_celix/Dependencies.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -MACRO(celix_subproject) - set(ARGS "${ARGN}") - - list(GET ARGS 0 OPTION_NAME) - list(REMOVE_AT ARGS 0) - - list(GET ARGS 0 OPTION_DESCRIPTION) - list(REMOVE_AT ARGS 0) - - list(GET ARGS 0 OPTION_DEFAULT) - list(REMOVE_AT ARGS 0) - - set(OPTIONS ) - set(ONE_VAL_ARGS ) - set(MULTI_VAL_ARGS DEPS) - cmake_parse_arguments(OPTION "${OPTIONS}" "${ONE_VAL_ARGS}" "${MULTI_VAL_ARGS}" ${ARGS}) - - string(TOUPPER ${OPTION_NAME} UC_OPTION_NAME) - set(NAME "BUILD_${UC_OPTION_NAME}") - - option(${NAME} "${OPTION_DESCRIPTION}" ${OPTION_DEFAULT}) - - get_property(BUILD GLOBAL PROPERTY ${NAME}_INTERNAL) - if (NOT DEFINED BUILD) - set(BUILD "OFF") - endif (NOT DEFINED BUILD) - - IF (${NAME} OR ${BUILD}) - set(${OPTION_NAME} "ON") - set_property(GLOBAL PROPERTY ${NAME}_INTERNAL "ON") - - FOREACH (DEP ${OPTION_DEPS}) - string(TOUPPER ${DEP} UC_DEP) - set(DEP_NAME "BUILD_${UC_DEP}") - set_property(GLOBAL PROPERTY ${DEP_NAME}_INTERNAL "ON") - ENDFOREACH (DEP) - ELSE (${NAME} OR ${BUILD}) - set(${OPTION_NAME} "OFF") - ENDIF (${NAME} OR ${BUILD}) -ENDMACRO(celix_subproject) - -MACRO(is_enabled name) - string(TOUPPER "BUILD_${name}_INTERNAL" OPTION) - - get_property(BUILD GLOBAL PROPERTY ${OPTION}) - - if(BUILD) - set(${name} "ON") - else() - set(${name} "OFF") - endif() -ENDMACRO(is_enabled)
http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/cmake/cmake_celix/DeployPackaging.cmake ---------------------------------------------------------------------- diff --git a/cmake/cmake_celix/DeployPackaging.cmake b/cmake/cmake_celix/DeployPackaging.cmake index b7880f4..b22ee40 100644 --- a/cmake/cmake_celix/DeployPackaging.cmake +++ b/cmake/cmake_celix/DeployPackaging.cmake @@ -167,7 +167,7 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_PROPERTIES>, set(PROGRAM_NAME "${LAUNCHER}") set(PROJECT_ATTR "${CMAKE_PROJECT_NAME}-build") set(WORKING_DIRECTORY ${CONTAINER_LOC}) - include("${CELIX_CMAKE_DIRECTORY}/cmake_celix/RunConfig.in.cmake") #set VAR RUN_CONFIG_IN + include("${CELIX_CMAKE_DIRECTORY}/RunConfig.in.cmake") #set VAR RUN_CONFIG_IN file(GENERATE OUTPUT "${CONTAINER_ECLIPSE_LAUNCHER}" CONTENT "${RUN_CONFIG_IN}" @@ -233,15 +233,32 @@ function(celix_container_bundles_dir) get_target_property(DEPS ${CONTAINER_TARGET} "CONTAINER_TARGET_DEPS") foreach(BUNDLE IN ITEMS ${BD_BUNDLES}) + set(HANDLED FALSE) if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE}) get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME) set(OUT "${CONTAINER_LOC}/${BD_DIR_NAME}/${BUNDLE_FILENAME}") add_custom_command(OUTPUT ${OUT} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${BUNDLE} ${OUT} - COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'" - DEPENDS ${BUNDLE} + COMMENT "Copying (file) bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'" ) - else() + set(HANDLED TRUE) + elseif (TARGET ${BUNDLE}) + get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED) + if (IMP) #An imported bundle target -> handle target without DEPENDS + string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell) + set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${CONTAINER_TARGET}-copy-bundle-for-target-${BUNDLE_ID}.timestamp") + set(DEST "${CONTAINER_LOC}/${BD_DIR_NAME}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>") + add_custom_command(OUTPUT ${OUT} + COMMAND ${CMAKE_COMMAND} -E touch ${OUT} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CONTAINER_LOC}/${BD_DIR_NAME} + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST} + COMMENT "Copying (imported) bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'" + ) + set(HANDLED TRUE) + endif () + endif () + + if (NOT HANDLED) #not a imported bundle target so (assuming) a future bundle target string(MAKE_C_IDENTIFIER ${BUNDLE} BUNDLE_ID) #Create id with no special chars (e.g. for target like Celix::shell) set(OUT "${CMAKE_BINARY_DIR}/celix/gen/${CONTAINER_TARGET}-copy-bundle-for-target-${BUNDLE_ID}.timestamp") set(DEST "${CONTAINER_LOC}/${BD_DIR_NAME}/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>") @@ -249,7 +266,7 @@ function(celix_container_bundles_dir) COMMAND ${CMAKE_COMMAND} -E touch ${OUT} COMMAND ${CMAKE_COMMAND} -E make_directory ${CONTAINER_LOC}/${BD_DIR_NAME} COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>" ${DEST} - COMMENT "Copying bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'" + COMMENT "Copying (target) bundle '${BUNDLE}' to '${CONTAINER_LOC}/${BD_DIR_NAME}'" DEPENDS ${BUNDLE} $<TARGET_PROPERTY:${BUNDLE},BUNDLE_CREATE_BUNDLE_TARGET> ) endif() @@ -274,11 +291,22 @@ function(celix_container_bundles) get_target_property(DEPS ${CONTAINER_TARGET} "CONTAINER_TARGET_DEPS") foreach(BUNDLE IN ITEMS ${ARGN}) - if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE}) + set(HANDLED FALSE) + if (IS_ABSOLUTE ${BUNDLE} AND EXISTS ${BUNDLE}) get_filename_component(BUNDLE_FILENAME ${BUNDLE} NAME) set(COPY_LOC "bundles/${BUNDLE_FILENAME}") set(ABS_LOC "${BUNDLE}") - else () #assume target (could be a future target -> if (TARGET ...) not possible + set(HANDLED TRUE) + elseif (TARGET ${BUNDLE}) + get_target_property(IMP ${BUNDLE} BUNDLE_IMPORTED) + if (IMP) #An imported bundle target -> handle target without DEPENDS + set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>") + set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>") + set(HANDLED TRUE) + endif () + endif () + + if (NOT HANDLED) #not a imported bundle target, so assuming a (future) bundle target set(COPY_LOC "bundles/$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILENAME>") set(ABS_LOC "$<TARGET_PROPERTY:${BUNDLE},BUNDLE_FILE>") http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/cmake/cmake_celix/UseCelix.cmake ---------------------------------------------------------------------- diff --git a/cmake/cmake_celix/UseCelix.cmake b/cmake/cmake_celix/UseCelix.cmake index db3f109..51290d3 100644 --- a/cmake/cmake_celix/UseCelix.cmake +++ b/cmake/cmake_celix/UseCelix.cmake @@ -15,8 +15,11 @@ # specific language governing permissions and limitations # under the License. -set(CELIX_CMAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/..) -include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/BundlePackaging.cmake) -include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DeployPackaging.cmake) -include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/DockerPackaging.cmake) -include(${CELIX_CMAKE_DIRECTORY}/cmake_celix/Runtimes.cmake) +include(GNUInstallDirs) + +set(CELIX_CMAKE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CELIX_CMAKE_DIRECTORY}/../Modules) +include(${CELIX_CMAKE_DIRECTORY}/BundlePackaging.cmake) +include(${CELIX_CMAKE_DIRECTORY}/DeployPackaging.cmake) +include(${CELIX_CMAKE_DIRECTORY}/DockerPackaging.cmake) +include(${CELIX_CMAKE_DIRECTORY}/Runtimes.cmake) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/dependency_manager/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt index f98701e..a9fa7bd 100644 --- a/dependency_manager/CMakeLists.txt +++ b/dependency_manager/CMakeLists.txt @@ -79,8 +79,8 @@ if (DEPENDENCY_MANAGER) target_include_directories(dm_shell PRIVATE api src) target_link_libraries(dm_shell PRIVATE Celix::shell_api) - install_celix_bundle(dm_shell) - install(TARGETS dependency_manager_so dependency_manager_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager) + install_celix_bundle(dm_shell EXPORT celix) + install(TARGETS dependency_manager_so dependency_manager_static EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager) install(DIRECTORY api/ DESTINATION include/celix/dependency_manager COMPONENT dependency_manager) unset(DM_COMP_OPT) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/dependency_manager_cxx/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/dependency_manager_cxx/CMakeLists.txt b/dependency_manager_cxx/CMakeLists.txt index 5b7580a..63d0714 100644 --- a/dependency_manager_cxx/CMakeLists.txt +++ b/dependency_manager_cxx/CMakeLists.txt @@ -40,8 +40,8 @@ if (DEPENDENCY_MANAGER_CXX) target_include_directories(dependency_manager_cxx_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/dependency_manager/api> - $<INSTALL_INTERFACE:include/celix/dependency_manager_cxx> $<INSTALL_INTERFACE:include/celix/dependency_manager> + $<INSTALL_INTERFACE:include/celix/dependency_manager_cxx> ) target_include_directories(dependency_manager_cxx_static PRIVATE src) target_compile_options(dependency_manager_cxx_static PRIVATE ${DM_COMP_OPT}) @@ -52,8 +52,8 @@ if (DEPENDENCY_MANAGER_CXX) target_link_libraries(dependency_manager_cxx_static Celix::framework) endif() - install(TARGETS dependency_manager_cxx_static DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager_cxx) - install(DIRECTORY include DESTINATION include/celix/dependency_manager_cxx COMPONENT dependency_manager_cxx) + install(TARGETS dependency_manager_cxx_static EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dependency_manager_cxx) + install(DIRECTORY include/ DESTINATION include/celix/dependency_manager_cxx COMPONENT dependency_manager_cxx) unset(DM_COMP_OPT) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/examples/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 93a648b..0937cc9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -14,7 +14,12 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -celix_subproject(EXAMPLES "Option to enable building the Examples" ON DEPS FRAMEWORK LAUNCHER SHELL_TUI LOG_SERVICE LOG_WRITER) + +if (COMMAND celix_subproject) + celix_subproject(EXAMPLES "Option to enable building the Examples" ON DEPS FRAMEWORK LAUNCHER SHELL_TUI LOG_SERVICE LOG_WRITER) +else () + set(EXAMPLES true) #celix_subproject is only available in the celix project -> using examples dir in other project is also supported +endif () if (EXAMPLES) add_subdirectory(hello_world) add_subdirectory(hello_world_test) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/examples/dm_example/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example/CMakeLists.txt b/examples/dm_example/CMakeLists.txt index a2a2143..9759702 100644 --- a/examples/dm_example/CMakeLists.txt +++ b/examples/dm_example/CMakeLists.txt @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -if (BUILD_DEPENDENCY_MANAGER) +if (TARGET Celix::dependency_manager_static AND TARGET Celix::dm_shell) add_subdirectory(api) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/examples/dm_example/phase3/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/CMakeLists.txt b/examples/dm_example/phase3/CMakeLists.txt index 7cad101..7fae829 100644 --- a/examples/dm_example/phase3/CMakeLists.txt +++ b/examples/dm_example/phase3/CMakeLists.txt @@ -26,7 +26,7 @@ target_include_directories(dm_example_phase3 PRIVATE src) target_link_libraries(dm_example_phase3 PRIVATE dm_example_api) IF(APPLE) - target_link_libraries(dm_example_phase3 PRIVATE -Wl,-all_load dependency_manager_static) + target_link_libraries(dm_example_phase3 PRIVATE -Wl,-all_load Celix::dependency_manager_static) else() if(ENABLE_ADDRESS_SANITIZER) #With asan there can be undefined symbols http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/examples/dm_example_cxx/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/dm_example_cxx/CMakeLists.txt b/examples/dm_example_cxx/CMakeLists.txt index 3f37373..5f6832c 100644 --- a/examples/dm_example_cxx/CMakeLists.txt +++ b/examples/dm_example_cxx/CMakeLists.txt @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -if (BUILD_DEPENDENCY_MANAGER_CXX) +if (TARGET Celix::dependency_manager_cxx_static AND TARGET Celix::dm_shell) add_subdirectory(api) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/examples/mongoose/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/examples/mongoose/CMakeLists.txt b/examples/mongoose/CMakeLists.txt index 7119aa7..d0e94ae 100644 --- a/examples/mongoose/CMakeLists.txt +++ b/examples/mongoose/CMakeLists.txt @@ -39,4 +39,4 @@ celix_bundle_files(mongoose ${CMAKE_CURRENT_LIST_DIR}/root) target_link_libraries(mongoose PRIVATE mongooselib ${LIBS}) -add_celix_container("mongoose_deploy" BUNDLES Celix::shell Celix::shell_tui log_service mongoose) +add_celix_container("mongoose_deploy" BUNDLES Celix::shell Celix::shell_tui Celix::log_service mongoose) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/framework/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 1716a7d..483deee 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -58,10 +58,6 @@ target_link_libraries(framework PRIVATE ${UUID} ${ZLIB_LIBRARY} ${CURL_LIBRARIES install(TARGETS framework EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework) install(DIRECTORY include/ DESTINATION include/celix COMPONENT framework) -install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/" DESTINATION share/celix/cmake/modules COMPONENT framework - PATTERN "CMakeCelix-local.cmake" EXCLUDE -) - #Alias setup to match external usage add_library(Celix::framework ALIAS framework) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/log_service/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/log_service/CMakeLists.txt b/log_service/CMakeLists.txt index bd59961..ed737d9 100644 --- a/log_service/CMakeLists.txt +++ b/log_service/CMakeLists.txt @@ -55,6 +55,7 @@ if (LOG_SERVICE) include/log_reader_service.h include/log_listener.h include/log_entry.h + EXPORT celix ) target_include_directories(log_service PRIVATE src) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/log_writer/log_writer_stdout/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/log_writer/log_writer_stdout/CMakeLists.txt b/log_writer/log_writer_stdout/CMakeLists.txt index 94effae..e4000dc 100644 --- a/log_writer/log_writer_stdout/CMakeLists.txt +++ b/log_writer/log_writer_stdout/CMakeLists.txt @@ -23,6 +23,6 @@ add_celix_bundle(log_writer_stdout src/log_writer_stdout ) -install_celix_bundle(log_writer_stdout) +install_celix_bundle(log_writer_stdout EXPORT celix) target_link_libraries(log_writer_stdout PRIVATE Celix::log_service_api log_writer_common) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/log_writer/log_writer_syslog/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/log_writer/log_writer_syslog/CMakeLists.txt b/log_writer/log_writer_syslog/CMakeLists.txt index e2003d5..9ea3a68 100644 --- a/log_writer/log_writer_syslog/CMakeLists.txt +++ b/log_writer/log_writer_syslog/CMakeLists.txt @@ -26,7 +26,7 @@ if (LOG_WRITER_SYSLOG) private/src/log_writer_syslog ) - install_celix_bundle(log_writer_syslog) + install_celix_bundle(log_writer_syslog EXPORT celix) target_link_libraries(log_writer_syslog PRIVATE log_writer_common) endif (LOG_WRITER_SYSLOG) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/remote_services/topology_manager/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/remote_services/topology_manager/CMakeLists.txt b/remote_services/topology_manager/CMakeLists.txt index 763067d..1e47c37 100644 --- a/remote_services/topology_manager/CMakeLists.txt +++ b/remote_services/topology_manager/CMakeLists.txt @@ -27,7 +27,7 @@ if (RSA_TOPOLOGY_MANAGER) NAME "Apache Celix RS Topology Manager" ) target_include_directories(rsa_topology_manager PRIVATE src) - target_include_directories(rsa_topology_manager PUBLIC include) + target_include_directories(rsa_topology_manager PRIVATE include) target_link_libraries(rsa_topology_manager PRIVATE Celix::log_helper Celix::rsa_spi) install_celix_bundle(rsa_topology_manager) http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/shell/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt index 93c066f..321a173 100644 --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -19,7 +19,12 @@ if (SHELL) find_package(CURL REQUIRED) add_library(shell_api INTERFACE) - target_include_directories(shell_api INTERFACE include) + target_include_directories(shell_api INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> + $<INSTALL_INTERFACE:include/celix/shell> + ) + install(TARGETS shell_api EXPORT celix) + install(DIRECTORY include/ DESTINATION include/celix/shell COMPONENT shell) add_celix_bundle(shell SYMBOLIC_NAME "apache_celix_shell" @@ -44,6 +49,7 @@ if (SHELL) install_celix_bundle(shell HEADERS include/shell.h include/command.h include/shell_constants.h + EXPORT celix ) #Setup target aliases to match external usage http://git-wip-us.apache.org/repos/asf/celix/blob/ae8e2e3c/shell_tui/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/shell_tui/CMakeLists.txt b/shell_tui/CMakeLists.txt index acfe439..a31645f 100644 --- a/shell_tui/CMakeLists.txt +++ b/shell_tui/CMakeLists.txt @@ -33,7 +33,7 @@ if (SHELL_TUI) ) target_link_libraries(shell_tui PRIVATE Celix::shell_api) - install_celix_bundle(shell_tui) + install_celix_bundle(shell_tui EXPORT celix) #Alias setup to match external usage add_library(Celix::shell_tui ALIAS shell_tui)
