forked from Naios/function2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
89 lines (72 loc) · 2.45 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
cmake_minimum_required(VERSION 3.0)
project(function2 VERSION 2.2.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
find_package(GTest REQUIRED)
add_library(function2 INTERFACE)
add_library(function2::function2 ALIAS function2)
target_include_directories(function2
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(function2
INTERFACE
cxx_alias_templates
cxx_auto_type
cxx_constexpr
cxx_decltype
cxx_decltype_auto
cxx_final
cxx_lambdas
cxx_lambda_init_captures
cxx_generic_lambdas
cxx_variadic_templates
cxx_defaulted_functions
cxx_nullptr
cxx_trailing_return_types
cxx_return_type_deduction)
# Create an install target
install(TARGETS function2
EXPORT function2-config
INCLUDES DESTINATION include)
install(EXPORT function2-config
FILE function2-config.cmake
NAMESPACE function2::
DESTINATION share/function2/cmake)
install(DIRECTORY include/function2
DESTINATION include FILES_MATCHING PATTERN "*.hpp")
install(FILES LICENSE.txt DESTINATION . RENAME function2-LICENSE.txt)
install(FILES Readme.md DESTINATION . RENAME function2-Readme.md)
# Setup CPack for bundling
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
# Since the header only library is platform independent
# we name the packages after the native line feed
if(WIN32)
set(CPACK_SYSTEM_NAME "crlf")
else()
set(CPACK_SYSTEM_NAME "lf")
endif()
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
endif()
enable_testing()
option(TESTS_NO_EXCEPTIONS "Test without exceptions" OFF)
option(TESTS_NO_DEATH_TESTS "Test without death tests" OFF)
if (TESTS_NO_EXCEPTIONS)
message(STATUS "Testing with exceptions disabled")
add_definitions(-DTESTS_NO_EXCEPTIONS)
endif()
if (TESTS_NO_DEATH_TESTS)
message(STATUS "Testing without death tests")
add_definitions(-DTESTS_NO_DEATH_TESTS)
endif()
include(cmake/CMakeLists.txt)
add_subdirectory(test)
endif ()