From 184734a1874bd570a0c4fe4a0934034bd7f72096 Mon Sep 17 00:00:00 2001 From: Mederic Fourmy <mederic.fourmy@gmail.com> Date: Mon, 9 May 2022 14:56:51 +0200 Subject: [PATCH] Compiling a XXXConfig.cmake.in file --- CMakeLists.txt | 39 +++++++++++++++---- cmake_modules/laser_scan_utilsConfig.cmake.in | 9 +++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 cmake_modules/laser_scan_utilsConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e2fff50..c1ff8b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,16 +23,8 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT") #find dependencies FIND_PACKAGE(Eigen3 3.3 REQUIRED) FIND_PACKAGE(falkolib QUIET) - find_package(PkgConfig) pkg_check_modules(csm QUIET csm ) -message(WARNING ${csm_FOUND}) -message(WARNING csm_LIBRARIES: ${csm_LIBRARIES}) -message(WARNING csm_LIBRARY: ${csm_LIBRARY}) -message(WARNING csm_LINK_LIBRARIES: ${csm_LINK_LIBRARIES}) -message(WARNING csm_LIBRARY_DIRS: ${csm_LIBRARY_DIRS}) -message(WARNING csm_INCLUDE_DIRS: ${csm_INCLUDE_DIRS}) -message(WARNING csm_INCLUDE_DIR: ${csm_INCLUDE_DIR}) # NOPE! #Build tests @@ -61,6 +53,37 @@ endif() ADD_SUBDIRECTORY(src) +#install library +#============================================================= +INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} +) +install(EXPORT ${PROJECT_NAME}Targets DESTINATION lib/${PROJECT_NAME}/cmake) + +#Â Configure the package installation +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_SOURCE_DIR}/cmake_modules/${PROJECT_NAME}Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION ${LIB_INSTALL_DIR}/${PROJECT_NAME}/cmake + PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR +) + +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + DESTINATION + ${LIB_INSTALL_DIR}/${PROJECT_NAME}/cmake +) + +# Specifies include directories to use when compiling the plugin target +# This way, include_directories does not need to be called in plugins depending on this one +target_include_directories(${PROJECT_NAME} INTERFACE + $<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}> +) + #Build tests IF(BUILD_TESTS) # Enables testing for this directory and below. diff --git a/cmake_modules/laser_scan_utilsConfig.cmake.in b/cmake_modules/laser_scan_utilsConfig.cmake.in new file mode 100644 index 0000000..699253a --- /dev/null +++ b/cmake_modules/laser_scan_utilsConfig.cmake.in @@ -0,0 +1,9 @@ +set(@PROJECT_NAME@_VERSION 0.0.1) + + +@PACKAGE_INIT@ + + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +check_required_components(@PROJECT_NAME@) \ No newline at end of file -- GitLab