-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
75 lines (56 loc) · 2.26 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
cmake_minimum_required(VERSION 3.5)
project(Calculate LANGUAGES CXX VERSION 2.1.1)
option(CALCULATE_BUILD_EXAMPLES "Add Calculate's example targets" OFF)
option(CALCULATE_BUILD_TESTS "Add Calculate's test targets" OFF)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "Configurations" FORCE)
if(NOT CMAKE_BUILD_TYPE)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
else()
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
endif()
message(STATUS "Calculate: setting build type to '${CMAKE_BUILD_TYPE}'")
if(NOT CMAKE_INSTALL_INCLUDEDIR})
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
endif()
if(NOT CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()
endif()
add_library(Calculate INTERFACE)
target_compile_features(Calculate INTERFACE cxx_std_14)
target_include_directories(Calculate
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
add_library(Calculate::Calculate ALIAS Calculate)
include(CMakePackageConfigHelpers)
set(CALCULATE_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calculate")
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CalculateConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CalculateConfig.cmake
INSTALL_DESTINATION ${CALCULATE_CONFIG_DIR}
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/CalculateConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
)
install(TARGETS Calculate EXPORT CalculateTargets DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT CalculateTargets NAMESPACE Calculate:: DESTINATION ${CALCULATE_CONFIG_DIR})
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/CalculateConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/CalculateConfigVersion.cmake"
DESTINATION ${CALCULATE_CONFIG_DIR}
)
if(CALCULATE_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(CALCULATE_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()