Hi All, I merged the feature/CELIX-417-cmake-refactoring to develop.
With this merge the Celix project now uses a "Modern Cmake" approach. The available info of how "Modern CMake" should works is scarce, but see [1] and [2] for more info. [1] https://youtu.be/bsXLMQ6WgIk [2] https://rix0r.nl/blog/2015/08/13/cmake-guide/ In a nutshell, this means that instead of using cmake variables to setup linking or include paths, CMake targets should be used. This also the case for projects not build, but configured with the find_package commands (if the package support that). The latter is realised by imported targets. For Celix the CMake files are updated so that targets are exported using "install(EXPORT ...)" using a Celix:: namespace prefix command. This means that for example the Celix framework library can be used (including setting up include directories) as follows: find_package(Celix REQUIRED) add_library(foo SHARED ...) target_link_libraries(foo PRIVATE Celix::framework) The target_link_libraries will arrange linking to the celix_framework, celix_utils and celix_dfi libraries and setting up the include paths matching these libraries. The install_celix_bundle_targets Celix CMake command is added to support exporting bundle targets. This in result means that bundles can be added using targets instead absolute paths: find_package(Celix REQUIRED) add_celix_container(simple_container BUNDLES Celix::shell Celix::shell_tui ) IMO there are a lot benefits, but to name a few: - As long as libraries, bundle are configured correctly, the can be safely moved about in a project. This is because the dependency is not on a CMake targets not on the bundle, include path or library locations. - Include paths, compile and linking definitions are now coupled to specific targets and not project/directory wide. - CMake var (e.g. ${CELIX_LIBRARIES}) can be empty without raising a warning/error, this is not the case for targets. Removing simple to make, but hard to find errors. - CMake support exporting targets (and as result creating imported targets for the package user), following this approach make the overall CMake configuration easier. - Exporting targets combined with a CelixConfig.cmake makes it easier to find and use Celix. - It is possible to test if a target exists, including imported targets: if (TARGET Celix:shell) .... endif () - Examples in the Celix project should now be 1 on 1 useable outside Celix (as long a target alias are setup correctly) It is already possible for the examples dir: cmake_minimum_required (VERSION 3.2) project (CelixExamples C CXX) set(CMAKE_CXX_FLAGS "-std=c++11") find_package(Celix REQUIRED) add_subdirectory(<path_to_celix_src>/examples examples) For sure there are still some issues with the refactoring, but IMO stable enough to merge to develop. If there are any questions / remarks feel free to ask them. Greetings, Pepijn