forked from joboccara/NamedType
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
78 lines (68 loc) · 2 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
cmake_minimum_required(VERSION 3.10.3)
project(NamedType
VERSION 1.0.1
LANGUAGES CXX
DESCRIPTION "Type-safe strong type (named type / opaque type) C++ library."
)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
include(CTest)
option(CMAKE_EXPORT_COMPILE_COMMANDS
"Enable/Disable output of compile commands during generation."
ON)
set(header_source_files
${PROJECT_SOURCE_DIR}/named_type.hpp
${PROJECT_SOURCE_DIR}/named_type_impl.hpp
${PROJECT_SOURCE_DIR}/underlying_functionalities.hpp
${PROJECT_SOURCE_DIR}/crtp.hpp
)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
source_group("Header Files" FILES ${header_source_files})
add_library(${PROJECT_NAME} INTERFACE)
target_compile_features(${PROJECT_NAME}
INTERFACE
cxx_auto_type
cxx_constexpr
cxx_decltype_auto
)
target_include_directories(${PROJECT_NAME} INTERFACE ${PROJECT_SOURCE_DIR})
target_sources(${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${header_source_files}>
)
# HACK: There is currently no other possibility to support IntelliSense in
# some IDEs (e.g. Visual Studio Code) for INTERFACE (header-only) libraries.
add_custom_target(${PROJECT_NAME}_ide SOURCES ${header_source_files})
set_property(TARGET ${PROJECT_NAME}_ide
PROPERTY
FOLDER "IDE"
)
if(BUILD_TESTING)
find_package(Catch REQUIRED)
add_executable(${PROJECT_NAME}_test "${PROJECT_SOURCE_DIR}/main.cpp")
target_compile_features(${PROJECT_NAME}_test
PRIVATE
cxx_decltype_auto
)
target_compile_definitions(${PROJECT_NAME}_test
PRIVATE
CATCH_CONFIG_MAIN
)
target_compile_options(${PROJECT_NAME}_test
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
-Werror
-Wall
-Wextra
>
$<$<CXX_COMPILER_ID:MSVC>:
/WX
/W4
>
)
set_property(TARGET ${PROJECT_NAME}_test
PROPERTY
FOLDER "Tests"
)
target_link_libraries(${PROJECT_NAME}_test PRIVATE Catch::Catch)
add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test)
endif()