-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
100 lines (77 loc) · 2.64 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
cmake_minimum_required(VERSION 3.26)
set(PROJECTNAME "JamTemplate")
project(${PROJECTNAME})
### Enable CCache
#####################################################
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif ()
## Helper Functions
#####################################################
include(config/cmake/helpers.cmake)
include(config/cmake/cache_variables.cmake)
set(SFML_STATIC_LIBRARIES TRUE)
set(BUILD_SHARED_LIBS OFF)
## Other variables and compiler setup I
#####################################################
if (JT_ENABLE_AUDIO_TESTS)
add_definitions(-DJT_ENABLE_AUDIO_TESTS)
endif ()
if (JT_ENABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
endif ()
if (JT_ENABLE_LTO_OPTIMIZATION)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL /LTCG")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=auto -fwhole-program -g0 -march=native -mtune=native")
endif ()
if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
message(WARNING "JT_ENABLE_LTO_OPTIMIZATION set in non-release build")
endif ()
endif ()
if (JT_ENABLE_WEB)
if (JT_ENABLE_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"bmp\",\"png\"]'")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL_TTF=2")
add_link_options("SHELL:-s TOTAL_MEMORY=256MB"
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:--use-preload-plugins"
"SHELL:--preload-file assets")
elseif (MSVC)
add_compile_definitions(NOMINMAX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
elseif (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs")
endif ()
## set include for mac homebrew
#####################################################
if (APPLE)
mac_sdl_setup()
endif ()
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CXX_STANDARD 20)
## get externals
#####################################################
add_subdirectory(ext)
if (USE_SFML)
setup_sfml()
else ()
setup_sdl()
endif ()
#####################################################
# setup FMod
#####################################################
jt_setup_fmod()
add_subdirectory(impl)
add_subdirectory(test)
## copy .clang-format to build directory
#####################################################
configure_file(${CMAKE_SOURCE_DIR}/.clang-format ${CMAKE_BINARY_DIR}/ COPYONLY)