1 include(GNUInstallDirs)
2 install(TARGETS ${INSTALL_TARGETS} EXPORT ${PROJECT_NAME}-targets
3 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
4 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
5 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
7 install(EXPORT ${PROJECT_NAME}-targets FILE ${PROJECT_NAME}-targets.cmake
8 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
10 include(CMakePackageConfigHelpers)
11 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake "\@PACKAGE_INIT\@\n"
12 "include(\"\${CMAKE_CURRENT_LIST_DIR}/\@PROJECT_NAME\@-targets.cmake\")\n"
14 configure_package_config_file(
15 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
16 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
17 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
19 write_basic_package_version_file(
20 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
21 VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion
24 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
25 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
26 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
29 function(install_fixup target define config)
30 get_filename_component(config "${config}" NAME)
31 install(CODE "file(READ \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${target}\" text)
32 string(REGEX REPLACE \"#if([defin\\t (]+)${define}([) \\t\\r\\n]*)\\n\" \"#include \\\"${config}\\\"\\n#if\\\\1${define}\\\\2\\n\" text \"\${text}\")
33 file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${target}\" \"\${text}\")")