-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
84 lines (63 loc) · 2.21 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
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.10)
project(wordle)
# salt : a81ed3ce
set(OpenGL_GL_PREFERENCE "GLVND")
enable_testing()
set(CMAKE_EXPORT_COMPILE_COMMANDS "on")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(cmake/GitVars.cmake)
include(cmake/BuildTypes.cmake)
if (EMSCRIPTEN)
option(WORDLE_WASM_SINGLE_FILE "wordle: embed WASM inside the generated wordle.js" OFF)
else()
if (MINGW)
set(BUILD_SHARED_LIBS_DEFAULT OFF)
else()
set(BUILD_SHARED_LIBS_DEFAULT ON)
endif()
endif()
# options
option(WORDLE_ALL_WARNINGS "wordle: enable all compiler warnings" ON)
option(WORDLE_ALL_WARNINGS_3RD_PARTY "wordle: enable all compiler warnings in 3rd party libs" OFF)
option(WORDLE_SANITIZE_THREAD "wordle: enable thread sanitizer" OFF)
option(WORDLE_SANITIZE_ADDRESS "wordle: enable address sanitizer" OFF)
option(WORDLE_SANITIZE_UNDEFINED "wordle: enable undefined sanitizer" OFF)
# sanitizers
if (WORDLE_SANITIZE_THREAD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif()
if (WORDLE_SANITIZE_ADDRESS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()
if (WORDLE_SANITIZE_UNDEFINED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
# dependencies
if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS " \
-s USE_SDL=2 \
-s DISABLE_EXCEPTION_CATCHING=1 \
")
set(CMAKE_EXE_LINKER_FLAGS " \
--bind \
--use-preload-cache \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s NO_EXIT_RUNTIME=0 \
")
else()
find_package(SDL2 REQUIRED)
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)
endif()
add_subdirectory(third-party)
# main
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
endif ()
add_subdirectory(src)