-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
63 lines (56 loc) · 1.89 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
cmake_minimum_required(VERSION 3.3)
# Solution
project(delegates)
# Options
set(CMAKE_DEBUG_POSTFIX d)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Add compile and link flags
option(ENABLE_COMPILER_OPTION_WARNINGS_TO_ALL "Enable compiler option warnings to all" ON)
option(ENABLE_COMPILER_OPTION_WARNINGS_AS_ERRORS "Enable compiler option warnings as errors" ON)
if (ENABLE_COMPILER_OPTION_WARNINGS_TO_ALL)
if (MSVC)
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
add_compile_options(/W4 /wd4100 /wd4458 /wd4996)
else()
add_compile_options(-Wall -Wextra -Wno-unused-parameter -pedantic)
endif()
endif()
if (ENABLE_COMPILER_OPTION_WARNINGS_AS_ERRORS)
if (MSVC)
add_compile_options(/WX)
else()
add_compile_options(-Werror)
endif()
endif()
# Code coverage
option(ENABLE_COVERAGE "Enable code coverage" OFF)
if (ENABLE_COVERAGE AND UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g --coverage")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} --coverage")
endif()
# Projects
add_subdirectory(src)
# Tests projects
option(ENABLE_TESTS "Enable tests" OFF)
if (ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif ()
# install
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"include(CMakeFindDependencyMacro)\n"
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}.cmake\")\n"
"\n"
"set(${PROJECT_NAME}_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/../include\")\n"
"set(${PROJECT_NAME}_LIBRARIES_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/../lib\")\n"
"set(${PROJECT_NAME}_LIBRARIES ${PROJECT_NAME})\n"
"set(${PROJECT_NAME}_FOUND TRUE)\n"
"\n"
"set(CMAKE_CXX_STANDARD 17)\n"
"set(CMAKE_CXX_STANDARD_REQUIRED ON)\n"
"if (MSVC)\n"
" set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} /utf-8\")\n"
"endif ()\n"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION cmake)
install(EXPORT ${PROJECT_NAME} DESTINATION cmake)