generated from Laguna1989/JamTemplateCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
110 lines (90 loc) · 3.55 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
101
102
103
104
105
106
107
108
109
110
cmake_minimum_required(VERSION 3.19)
set(PROJECTNAME "1hgj382")
project(${PROJECTNAME})
## 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_WEB)
add_compile_definitions(MUSIC_OGG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -g --std=c++17 -fpermissive ")
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_VORBIS=1 -s USE_OGG=1")
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")
else ()
if (MSVC)
## nasty warning 5205 from tileson should not show up,
## so the warning level of this one is set to 4 and the global warning level is set to three
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w45205 /W3 /EHsc")
else ()
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs")
endif ()
if (JT_ENABLE_PERFORMANCETESTS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra --std=c++17 -fpermissive")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra --std=c++17 -fpermissive")
endif ()
endif ()
endif ()
## set include for mac homebrew
#####################################################
if (NOT USE_SFML)
if (NOT JT_ENABLE_WEB)
find_package(SDL2 REQUIRED)
include(FindPkgConfig)
pkg_check_modules(SDL2_Image REQUIRED IMPORTED_TARGET SDL2_image)
pkg_check_modules(SDL2_TTF REQUIRED IMPORTED_TARGET SDL2_ttf)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(/usr/local/Cellar/sdl2/2.0.22/include/
/usr/local/Cellar/sdl2_image/2.0.5/include/
/usr/local/Cellar/sdl2_ttf/2.0.18_1/include/)
endif ()
endif ()
endif ()
## get externals
#####################################################
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
add_subdirectory(ext)
## Other variables and compiler setup II
#####################################################
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD 17)
FetchContent_GetProperties(sfml)
# Apple users: set to /usr/local/Cellar/sfml/2.4.2_1/lib/ or respectively
if (WIN32)
set(SFML_DIR_ROOT "${sfml_SOURCE_DIR}" CACHE PATH "Path to SFML root dir.")
endif ()
if ($ENV{CLION_IDE})
set(SFML_DIR "${SFML_DIR_ROOT}/lib/cmake/SFML")
endif ()
#####################################################
## Set link directories
#####################################################
if (USE_SFML)
if (WIN32 OR APPLE)
link_directories(${SFML_DIR_ROOT}/lib)
endif ()
endif ()
## setup Projects
#####################################################
add_subdirectory(impl)
## copy .clang-format to build directory
#####################################################
configure_file(${CMAKE_SOURCE_DIR}/.clang-format ${CMAKE_BINARY_DIR}/ COPYONLY)