-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
CMakeLists.txt
52 lines (44 loc) · 2.55 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cmake_minimum_required(VERSION 3.5)
# define the project
project(effolkronium_random VERSION 1.5.0 LANGUAGES CXX)
option(Random_BuildTests "Build the unit tests" ON)
# define project variables
set(EFFOLKRONIUM_RANDOM_TARGET_NAME ${PROJECT_NAME})
set(EFFOLKRONIUM_RANDOM_PACKAGE_NAME ${EFFOLKRONIUM_RANDOM_TARGET_NAME})
set(EFFOLKRONIUM_RANDOM_TARGETS_FILENAME "${EFFOLKRONIUM_RANDOM_PACKAGE_NAME}Targets.cmake")
set(EFFOLKRONIUM_RANDOM_CONFIG_FILENAME "${EFFOLKRONIUM_RANDOM_PACKAGE_NAME}Config.cmake")
set(EFFOLKRONIUM_RANDOM_CONFIGVERSION_FILENAME "${EFFOLKRONIUM_RANDOM_PACKAGE_NAME}ConfigVersion.cmake")
set(EFFOLKRONIUM_RANDOM_CONFIG_DESTINATION "cmake")
set(EFFOLKRONIUM_RANDOM_INCLUDE_DESTINATION "include")
# create and configure the library target
add_library(${EFFOLKRONIUM_RANDOM_TARGET_NAME} INTERFACE)
target_include_directories(${EFFOLKRONIUM_RANDOM_TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${EFFOLKRONIUM_RANDOM_INCLUDE_DESTINATION}>)
if(Random_BuildTests)
enable_testing()
add_subdirectory(test)
endif()
# generate a config and config version file for the package
include(CMakePackageConfigHelpers)
configure_package_config_file("cmake/config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${EFFOLKRONIUM_RANDOM_CONFIG_FILENAME}"
INSTALL_DESTINATION ${EFFOLKRONIUM_RANDOM_CONFIG_DESTINATION}
PATH_VARS EFFOLKRONIUM_RANDOM_INCLUDE_DESTINATION)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${EFFOLKRONIUM_RANDOM_CONFIGVERSION_FILENAME}"
COMPATIBILITY SameMajorVersion)
# export the library target and store build directory in package registry
export(TARGETS ${EFFOLKRONIUM_RANDOM_TARGET_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/${EFFOLKRONIUM_RANDOM_TARGETS_FILENAME}")
export(PACKAGE ${EFFOLKRONIUM_RANDOM_PACKAGE_NAME})
# install library target and config files
install(TARGETS ${EFFOLKRONIUM_RANDOM_TARGET_NAME}
EXPORT ${EFFOLKRONIUM_RANDOM_PACKAGE_NAME})
install(DIRECTORY "include/effolkronium"
DESTINATION ${EFFOLKRONIUM_RANDOM_INCLUDE_DESTINATION})
install(EXPORT ${EFFOLKRONIUM_RANDOM_PACKAGE_NAME}
FILE ${EFFOLKRONIUM_RANDOM_TARGETS_FILENAME}
DESTINATION ${EFFOLKRONIUM_RANDOM_CONFIG_DESTINATION})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${EFFOLKRONIUM_RANDOM_CONFIG_FILENAME}"
"${CMAKE_CURRENT_BINARY_DIR}/${EFFOLKRONIUM_RANDOM_CONFIGVERSION_FILENAME}"
DESTINATION ${EFFOLKRONIUM_RANDOM_CONFIG_DESTINATION})