basiccmake/CMakeLists.txt
2022-11-06 04:09:33 +01:00

21 lines
788 B
CMake

cmake_minimum_required(VERSION 3.20)
project(basiccmake LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# keep PUBLIC dependencies in sync with cmake/config.cmake.in
#find_package(foo REQUIRED)
include(AddAutoformatTarget)
include(GlobalOptions)
include(GNUInstallDirs)
add_subdirectory(src)
install(DIRECTORY include TYPE INCLUDE FILES_MATCHING PATTERN *.h)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets)
install(EXPORT ${PROJECT_NAME}-targets NAMESPACE ${PROJECT_NAME}::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}")
configure_file(cmake/config.cmake.in ${PROJECT_NAME}-config.cmake @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}")