-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
125 lines (107 loc) · 3.12 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
cmake_minimum_required (VERSION 3.13...3.21)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/lib/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif()
project(
ysamba
LANGUAGES C CXX
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") # Keep all runtime files in one directory.
file(
GLOB_RECURSE SOURCE_FILES
CONFIGURE_DEPENDS # Automatically reconfigure if source files are added/removed.
${PROJECT_SOURCE_DIR}/src/*.cpp
${PROJECT_SOURCE_DIR}/src/*.hpp
${PROJECT_SOURCE_DIR}/src/*.c
${PROJECT_SOURCE_DIR}/src/*.h
)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
# Ensure the C++17 standard is available.
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
# Enforce UTF-8 encoding on MSVC.
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /utf-8)
target_compile_definitions(${PROJECT_NAME} PRIVATE _USE_MATH_DEFINES) # Defines M_PI
endif()
# Enable warnings recommended for new projects.
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WD4244)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Og)
endif()
# Set up WebGPU
include(FetchContent)
FetchContent_Declare(
webgpu
GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution
GIT_TAG wgpu-static
)
FetchContent_MakeAvailable(webgpu)
# Set up dependencies under lib directory
set(FASTNOISE2_NOISETOOL OFF CACHE BOOL "Build Noise Tool" FORCE)
add_subdirectory("lib/FastNoise2")
add_subdirectory("lib/i18n_keyval")
add_subdirectory("lib/heman")
# Force an optimized build of FastNoise2
if (MSVC)
else()
target_compile_options(FastNoise PRIVATE -O3)
endif()
find_package(SDL2 CONFIG REQUIRED)
find_package(libtcod CONFIG REQUIRED)
find_package(cereal CONFIG REQUIRED)
find_package(EnTT CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(freetype CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(imgui CONFIG REQUIRED)
find_package(implot CONFIG REQUIRED)
find_package(OpenAL CONFIG REQUIRED)
find_package(Ogg CONFIG REQUIRED)
find_package(Vorbis CONFIG REQUIRED)
target_include_directories(
${PROJECT_NAME}
PRIVATE
"./lib/gal/include"
"./src"
)
SET(
DL_LIBRARIES
webgpu
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
libtcod::libtcod
cereal::cereal
EnTT::EnTT
nlohmann_json::nlohmann_json
freetype
spdlog::spdlog
imgui::imgui
implot::implot
FastNoise
i18n_keyval::i18n_keyval
OpenAL::OpenAL
Vorbis::vorbisfile
heman
)
# Allow objective-c for SDL2 C file on Apple platforms
if(APPLE)
set_source_files_properties("src/graphics/renderer/sdl2_webgpu.c" PROPERTIES COMPILE_FLAGS "-x objective-c" LANGUAGE C)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
${DL_LIBRARIES}
"-framework QuartzCore"
"-framework Cocoa"
"-framework Metal"
)
else()
target_link_libraries(
${PROJECT_NAME}
PRIVATE
${DL_LIBRARIES}
)
endif()