-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
94 lines (76 loc) · 2.34 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
cmake_minimum_required(VERSION 3.1)
project(IN_CONSTEXPR)
###############################################
# Find C++ version #
###############################################
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14)
check_cxx_compiler_flag("-std=c++1z" COMPILER_SUPPORTS_CXX17)
check_cxx_compiler_flag(foobar COMPILER_SUPPORTS_CXX17)
if("${COMPILER_SUPPORTS_CXX17}")
set(CXX_STANDARD_TO_USE cxx_std_17)
elseif("${COMPILER_SUPPORTS_CXX14}")
set(CXX_STANDARD_TO_USE cxx_std_14)
else()
error("Dont have a supported compiler")
endif()
if( NOT CMAKE_BUILD_TYPE )
# Set to release if not default set.
set( CMAKE_BUILD_TYPE Release )
endif()
###############################################
# Create Library #
###############################################
add_library(in_constexpr
STATIC
src/if_in_constexpr.cpp
)
target_compile_features(in_constexpr
PUBLIC
${CXX_STANDARD_TO_USE}
)
target_include_directories(in_constexpr
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
###############################################
# Setup installation #
###############################################
set(EXPORT_HEADER_FILES
include/in_constexpr/if_in_constexpr.hpp
include/in_constexpr/smart_assert.hpp
)
# Export the following headers
set_target_properties(in_constexpr
PROPERTIES
PUBLIC_HEADER "${EXPORT_HEADER_FILES}"
)
# Install the target
install (
TARGETS in_constexpr
EXPORT in_constexpr-targets
LIBRARY DESTINATION lib/in_constexpr
ARCHIVE DESTINATION lib/in_constexpr
PUBLIC_HEADER DESTINATION include/in_constexpr
)
# Using the target, generate a config file
export(
EXPORT in_constexpr-targets
FILE in_constexpr-config.cmake
NAMESPACE in_constexpr::
)
# Export this to the package registry
export(PACKAGE in_constexpr)
# Install the config file to the proper location as well
install (
FILES ${CMAKE_BINARY_DIR}/in_constexpr-config.cmake
DESTINATION cmake/in_constexpr
)
###############################################
# Build Examples #
###############################################
# Build only if no-one is including us.
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
add_subdirectory(examples)
endif()