forked from SergeyMakeev/SlotMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (72 loc) · 2.12 KB
/
Copy pathCMakeLists.txt
File metadata and controls
84 lines (72 loc) · 2.12 KB
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
cmake_minimum_required(VERSION 3.28)
project(
SlotMap
VERSION 0.1.0
LANGUAGES C CXX
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(SLOTMAP_BUILD_TESTS "Build SlotMap unit tests" ON)
option(SLOTMAP_BUILD_DOCS "Enable documentation targets" ON)
option(SLOTMAP_ENABLE_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_library(slotmap INTERFACE)
target_include_directories(
slotmap
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(slotmap INTERFACE cxx_std_23)
set(common_warnings
-Wall
-Wextra
-Wshadow
-Wconversion
-Wpedantic
-Wnon-virtual-dtor
-Wold-style-cast
-Woverloaded-virtual
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(slotmap INTERFACE ${common_warnings})
if(SLOTMAP_ENABLE_WARNINGS_AS_ERRORS)
target_compile_options(slotmap INTERFACE -Werror)
endif()
elseif(MSVC)
target_compile_options(slotmap INTERFACE /W4)
if(SLOTMAP_ENABLE_WARNINGS_AS_ERRORS)
target_compile_options(slotmap INTERFACE /WX)
endif()
endif()
target_compile_definitions(
slotmap
INTERFACE
$<$<CONFIG:Debug>:SLOTMAP_DEBUG=1>
)
if(SLOTMAP_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if(SLOTMAP_BUILD_DOCS)
find_program(MRDOCS_EXECUTABLE NAMES mrdocs REQUIRED)
find_program(DOXYGEN_EXECUTABLE NAMES doxygen REQUIRED)
add_custom_target(
docs
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_docs.sh
--source ${CMAKE_CURRENT_SOURCE_DIR}
--build ${CMAKE_BINARY_DIR}/docs
--mrdocs ${MRDOCS_EXECUTABLE}
--doxygen ${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating SlotMap reference documentation"
VERBATIM
)
endif()