disable misc-non-private-member-variables-in-classes in .clang-tidy
[liba.git] / cmake / InstallTargets.cmake
blob4b326aec57dd768e0ad9dbe9c90cc6a7efa69c60
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"
13   "set(LIBA_INCLUDE_DIR \"\${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@\")\n"
15 configure_package_config_file(
16   ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
17   ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
18   INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
20 write_basic_package_version_file(
21   ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
22   VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion
24 install(FILES
25   ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
26   ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
27   DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
30 function(install_fixup target define config)
31   get_filename_component(config "${config}" NAME)
32   install(CODE "file(READ \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${target}\" text)
33   string(REGEX REPLACE \"#if([defin\\t (]+)${define}([) \\t\\r\\n]*)\\n\" \"#include \\\"${config}\\\"\\n#if\\\\1${define}\\\\2\\n\" text \"\${text}\")
34   file(WRITE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${target}\" \"\${text}\")")
35 endfunction()