-
Notifications
You must be signed in to change notification settings - Fork 1
/
CompileOptions.cmake
33 lines (27 loc) · 1.27 KB
/
CompileOptions.cmake
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
# I'm just making this a separate file, so both the framework and
# projects can use it.
function(setCompileOptions target)
target_compile_features(${target} PRIVATE cxx_std_20)
# Keep assert() in the release build
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${target} PRIVATE -UNDEBUG)
endif()
# Sanitizer (doesn't really work, though)
# if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# target_compile_options(${target} PRIVATE -fsanitize=address,undefined -fno-sanitize=leak)
# target_link_options(${target} PRIVATE -fsanitize=address,undefined -fno-sanitize=leak)
# endif()
# endif()
# Set warning options
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${target} PRIVATE
-Wall -Wextra -Wpedantic -Werror -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wswitch-default
-Wuninitialized -Wduplicated-branches -Wfloat-equal -Wshadow -Wcast-qual -Wcast-align -Wsign-conversion
-Wlogical-op -Wmissing-declarations -Wno-psabi -Wnon-virtual-dtor
)
endif()
if (MSVC)
target_compile_options(${target} PRIVATE "/EHsc" "-D_WIN32_WINNT=0x0601" "/Zc:__cplusplus" "-DBOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN7")
endif (MSVC)
endfunction()