-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
139 lines (118 loc) · 4.36 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
cmake_minimum_required(VERSION 3.31)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package(om-common-functions REQUIRED)
# Enables the Standard module support. This needs to be done
# before selecting the languages.
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
project("gamedev_study" LANGUAGES CXX)
om_add_custom_build_types()
if(MSVC)
set(CMAKE_CXX_STANDARD 23) # to get c++latest flag
else()
set(CMAKE_CXX_STANDARD 26)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Currently CMake requires extensions enabled when using import std.
# https://gitlab.kitware.com/cmake/cmake/-/issues/25916
# https://gitlab.kitware.com/cmake/cmake/-/issues/25539
set(CMAKE_CXX_EXTENSIONS ON)
option(OM_BUILD_DEPS [=[download and build dependencies [SDL3, GLM, Catch2]
as part of current build]=] ON)
option(OM_BUILD_BOOST "download and build Boost from source" OFF)
option(OM_BUILD_COURSE_BASIC_PROG "turn ON if need to build 00-basic-prog" ON)
option(OM_BUILD_COURSE_BASIC_GAME_DEV
"turn ON if need to build 01-basic-game-dev" ON)
option(OM_BUILD_COURSE_OPENGL "turn ON if need to build 02-opengl" OFF)
option(OM_BUILD_COURSE_VULKAN "turn ON if need to build 02-vulkan" ON)
option(OM_BUILD_GAME_EXAMPLE "turn ON if need to build 05-game" OFF)
option(OM_BUILD_WEB "turn ON if need to build 08-web" ON)
option(OM_CLANG_TIDY "turn ON if need to run clang-tidy" OFF)
if(OM_BUILD_DEPS)
message(STATUS "download and build SDL3 sources")
include(FetchContent)
fetchcontent_declare(
SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG origin/main
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
OVERRIDE_FIND_PACKAGE TRUE)
option(SDL_STATIC "" ON)
option(SDL_SHARED "" ON)
set(CMAKE_UNITY_BUILD_MODE "GROUP")
fetchcontent_makeavailable(SDL3)
#fetchcontent_populate(SDL3)
find_package(SDL3 REQUIRED)
message(STATUS "download and build GLM sources")
fetchcontent_declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG origin/master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
OVERRIDE_FIND_PACKAGE TRUE)
fetchcontent_makeavailable(glm)
find_package(glm REQUIRED)
# use Catch2::Catch2 or Catch2::Catch2WithMain
fetchcontent_declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # or a later release
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
OVERRIDE_FIND_PACKAGE TRUE # to find correct version
EXCLUDE_FROM_ALL)
fetchcontent_makeavailable(Catch2)
find_package(Catch2 REQUIRED)
endif(OM_BUILD_DEPS)
if(OM_BUILD_BOOST)
# The logging output during population can be quite verbose,
# making the configure stage quite noisy. This cache option
# (ON by default) hides all population output unless an error is encountered.
# If experiencing problems with hung downloads, temporarily
# switching this option off may help diagnose which content population
# is causing the issue.
set(FETCHCONTENT_QUIET OFF)
fetchcontent_declare(
Boost
GIT_REPOSITORY "https://github.com/boostorg/boost.git"
GIT_TAG "boost-1.86.0"
GIT_PROGRESS ON
GIT_SHALLOW ON
OVERRIDE_FIND_PACKAGE TRUE # needed to find correct Boost
EXCLUDE_FROM_ALL)
fetchcontent_makeavailable(Boost)
find_package(
Boost
1.86.0
EXACT # Minimum or EXACT version e.g. 1.67.0
REQUIRED # Fail with error if Boost is not found
COMPONENTS filesystem # Boost libraries by their canonical name
# e.g. "date_time" for "libboost_date_time"
#[OPTIONAL_COMPONENTS <libs>...]
# Optional Boost libraries by their canonical name)
) # e.g. "date_time" for "libboost_date_time"
endif(OM_BUILD_BOOST)
set(CMAKE_UNITY_BUILD_MODE "BATCH")
enable_testing()
om_clang_tidy_enable()
# courses
if(OM_BUILD_COURSE_BASIC_PROG)
add_subdirectory(00-basic-prog)
endif()
if(OM_BUILD_COURSE_BASIC_GAME_DEV)
add_subdirectory(01-basic-game-dev)
endif()
if(OM_BUILD_COURSE_OPENGL)
add_subdirectory(02-opengl)
endif()
if(OM_BUILD_COURSE_VULKAN)
add_subdirectory(02-vulkan)
endif()
# start sample project
if(OM_BUILD_GAME_EXAMPLE)
add_subdirectory(05-game)
endif(OM_BUILD_GAME_EXAMPLE)
if(OM_BUILD_WEB)
add_subdirectory(08-web)
endif(OM_BUILD_WEB)