-
Notifications
You must be signed in to change notification settings - Fork 3
/
default-cmake-options.cmake
57 lines (50 loc) · 1.72 KB
/
default-cmake-options.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
set(CMAKE_C_FLAGS "-std=gnu99")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
if (MSVC)
add_compile_options(/wd4061 /wd4819)
add_compile_options(/wd4477 /wd4244 /wd4245)
add_compile_options(/wd4820 /wd4365)
add_compile_options(/wd4267)
add_compile_options(/wd4623 /wd4625 /wd4626 /wd5027 /wd5045) #nlohmann::json
add_compile_options(/wd4668)
add_compile_options(/wd4996)
add_compile_options(/wd5039)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wimplicit-int")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wtrigraphs")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
endif()
set(BUILD_TYPE "release")
if (debug)
set(BUILD_TYPE "debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_compile_definitions(MACOSX TRUE)
elseif(WIN32)
else()
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
add_definitions(-fPIC)
endif()
set(GCOV "disabled")
if (gcov)
set(GCOV "enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
endif()