-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
52 lines (42 loc) · 2.16 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
cmake_minimum_required(VERSION 3.17)
set(PROJECT_NAME example)
project(${PROJECT_NAME} LANGUAGES CXX)
set(TARGET_PROJECT vector)
# ------------------------------------------------------------------------------
# Configure Main Projects
# ------------------------------------------------------------------------------
add_executable(${TARGET_PROJECT})
find_package(fmt CONFIG REQUIRED)
file(GLOB CXX_SOURCES *.cpp)
target_sources(${TARGET_PROJECT} PRIVATE ${CXX_SOURCES})
target_link_libraries(${TARGET_PROJECT} fmt::fmt)
# ------------------------------------------------------------------------------
# Set compiler options
# ------------------------------------------------------------------------------
target_compile_features(${TARGET_PROJECT} PUBLIC cxx_std_14)
target_compile_options(${TARGET_PROJECT} PUBLIC
# warnings
$<$<CXX_COMPILER_ID:Clang>:-Wall -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic>
$<$<CXX_COMPILER_ID:GCC>:-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused>
$<$<CXX_COMPILER_ID:MSVC>:/W4>
# flags for each build type
$<$<CXX_COMPILER_ID:Clang>:
$<$<CONFIG:Release>:-O3> # Release
$<$<CONFIG:Debug>:-O0 -g> # Debug
$<$<CONFIG:RelWithDebgInfo>:-O3 -g> # RelWithDebInfo
>
$<$<CXX_COMPILER_ID:GCC>:
$<$<CONFIG:Release>:-O3> # Release
$<$<CONFIG:Debug>:-O0 -g> # Debug
$<$<CONFIG:RelWithDebgInfo>:-O3 -g> # RelWithDebInfo
>
$<$<CXX_COMPILER_ID:MSVC>:
$<$<CONFIG:Release>:/O2 /Zi /MP> # Release
$<$<CONFIG:Debug>:/Od /ZI /MP> # Debug
$<$<CONFIG:RelWithDebgInfo>:/O2 /ZI /MP> # RelWithDebInfo
>
)
target_compile_definitions(${TARGET_PROJECT} PUBLIC
$<$<CONFIG:Debug>:DEBUG> # Debug
$<$<NOT:$<CONFIG:Debug>>:NDEBUG> # else
)