diff --git a/CMakeLists.txt b/CMakeLists.txt index 95d25541..c4e0da93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ # Minimum cmake version: # - 3.12 is needed for https://cmake.org/cmake/help/latest/command/target_link_libraries.html#id8 # - 3.12 is needed for https://cmake.org/cmake/help/latest/command/add_compile_definitions.html -cmake_minimum_required(VERSION 3.12) +# - 3.13 is needed to install targets that were created in other directories (https://cmake.org/cmake/help/latest/command/install.html) +cmake_minimum_required(VERSION 3.13) project(fabm VERSION 2.0.1 @@ -86,9 +87,11 @@ endif() # Use solution folders in IDEs set_property(GLOBAL PROPERTY USE_FOLDERS ON) +# Determine default installation directories (CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_INCLUDEDIR) +include(GNUInstallDirs) + # Add YAML parsing library, unless the yaml target was already defined by a parent CMakeLists.txt if(NOT TARGET yaml) - include(GNUInstallDirs) add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src/yaml" yaml EXCLUDE_FROM_ALL) set_property(TARGET yaml PROPERTY FOLDER fabm/yaml) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yaml/modules/\${BUILD_TYPE}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yaml) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f6d4409f..cb9af2d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -216,14 +216,18 @@ endif() # Install FABM library and include files, unless the host overruled this. if (NOT DEFINED FABM_NO_LIBRARY_INSTALL) - install(TARGETS fabm EXPORT fabmConfig) + # Note: using an implicit destination for install(TARGETS ...) below, + # or TYPE instead of DESTINATION, requires cmake >= 3.14 + install(TARGETS fabm + EXPORT fabmConfig + DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/modules/\${BUILD_TYPE}/ - TYPE INCLUDE) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES ${CMAKE_CURRENT_LIST_DIR}/../include/fabm.h ${CMAKE_CURRENT_LIST_DIR}/../include/fabm_version.h ${CMAKE_CURRENT_LIST_DIR}/drivers/${FABM_HOST}/fabm_driver.h - TYPE INCLUDE) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() export(EXPORT fabmConfig)