install-rules.cmake (1791B)
1 if(PROJECT_IS_TOP_LEVEL) 2 set( 3 CMAKE_INSTALL_INCLUDEDIR "include/hemplate-${PROJECT_VERSION}" 4 CACHE STRING "" 5 ) 6 set_property(CACHE CMAKE_INSTALL_INCLUDEDIR PROPERTY TYPE PATH) 7 endif() 8 9 include(CMakePackageConfigHelpers) 10 include(GNUInstallDirs) 11 12 # find_package(<package>) call for consumers to find this project 13 set(package hemplate) 14 15 install( 16 DIRECTORY 17 include/ 18 "${PROJECT_BINARY_DIR}/export/" 19 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 20 COMPONENT hemplate_Development 21 ) 22 23 install( 24 TARGETS hemplate_hemplate 25 EXPORT hemplateTargets 26 RUNTIME # 27 COMPONENT hemplate_Runtime 28 LIBRARY # 29 COMPONENT hemplate_Runtime 30 NAMELINK_COMPONENT hemplate_Development 31 ARCHIVE # 32 COMPONENT hemplate_Development 33 INCLUDES # 34 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 35 ) 36 37 write_basic_package_version_file( 38 "${package}ConfigVersion.cmake" 39 COMPATIBILITY SameMajorVersion 40 ) 41 42 # Allow package maintainers to freely override the path for the configs 43 set( 44 hemplate_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package}" 45 CACHE STRING "CMake package config location relative to the install prefix" 46 ) 47 set_property(CACHE hemplate_INSTALL_CMAKEDIR PROPERTY TYPE PATH) 48 mark_as_advanced(hemplate_INSTALL_CMAKEDIR) 49 50 install( 51 FILES cmake/install-config.cmake 52 DESTINATION "${hemplate_INSTALL_CMAKEDIR}" 53 RENAME "${package}Config.cmake" 54 COMPONENT hemplate_Development 55 ) 56 57 install( 58 FILES "${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake" 59 DESTINATION "${hemplate_INSTALL_CMAKEDIR}" 60 COMPONENT hemplate_Development 61 ) 62 63 install( 64 EXPORT hemplateTargets 65 NAMESPACE hemplate:: 66 DESTINATION "${hemplate_INSTALL_CMAKEDIR}" 67 COMPONENT hemplate_Development 68 ) 69 70 if(PROJECT_IS_TOP_LEVEL) 71 include(CPack) 72 endif()