-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
180 lines (131 loc) · 4.94 KB
/
CMakeLists.txt
File metadata and controls
180 lines (131 loc) · 4.94 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
cmake_minimum_required(VERSION 3.20)
project(CatWare)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Stolen from https://github.com/TheLartians/GroupSourcesByFolder.cmake
function(GroupSourcesByFolder target)
set(SOURCE_GROUP_DELIMITER "/")
set(last_dir "")
set(files "")
get_target_property(sources ${target} SOURCES)
foreach(file ${sources})
file(RELATIVE_PATH relative_file "${PROJECT_SOURCE_DIR}" ${file})
get_filename_component(dir "${relative_file}" PATH)
if(NOT "${dir}" STREQUAL "${last_dir}")
if(files)
source_group("${last_dir}" FILES ${files})
endif()
set(files "")
endif()
set(files ${files} ${file})
set(last_dir "${dir}")
endforeach()
if(files)
source_group("${last_dir}" FILES ${files})
endif()
endfunction()
# ImGui
file(GLOB CW_IMGUI Engine/Lib/ImGui/*.cpp)
# -----------------------------------------------------
# CatWareEngine
# -----------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
file(GLOB_RECURSE CW_SOURCE_FILES Engine/Source/*.cpp)
file(GLOB_RECURSE CW_HEADER_FILES Engine/Source/*.h)
file(GLOB_RECURSE CW_GLAD Engine/Lib/Glad/*.c)
source_group(CW_SOURCE_FILES Source)
source_group(CW_HEADER_FILES Source)
# platforms
if (WIN32)
add_compile_definitions(CW_PLATFORM_WIN64)
add_compile_definitions()
else()
# Not sure if i should call this platform linux or just generally unix
# cause it probably also works on bsd and other unix like systems
add_compile_definitions(CW_PLATFORM_UNIX64)
add_compile_options(-fPIC)
endif()
add_library(CatWareEngine SHARED ${CW_SOURCE_FILES} ${CW_GLAD} ${CW_HEADER_FILES} ${CW_IMGUI} ${PROJECT_SOURCE_DIR}/Engine/Lib/ImGui/backends/imgui_impl_opengl3.cpp ${PROJECT_SOURCE_DIR}/Engine/Lib/ImGui/backends/imgui_impl_sdl2.cpp)
target_compile_definitions(CatWareEngine PRIVATE CATWARE_BUILD)
add_subdirectory("Engine/Lib/freetype")
target_link_libraries(CatWareEngine PRIVATE freetype)
set_target_properties(freetype PROPERTIES FOLDER "Libraries")
add_subdirectory("Engine/Lib/SDL2" EXCLUDE_FROM_ALL)
target_link_libraries(CatWareEngine PRIVATE SDL2-static)
set_target_properties(SDL2-static PROPERTIES FOLDER "Libraries")
add_subdirectory("Engine/Lib/yaml-cpp")
target_link_libraries(CatWareEngine PRIVATE yaml-cpp)
set_target_properties(yaml-cpp PROPERTIES FOLDER "Libraries")
set_target_properties(sdl_headers_copy PROPERTIES FOLDER "Libraries")
target_include_directories(
CatWareEngine PUBLIC
"Engine/Source"
"Engine/Lib/freetype/include"
"Engine/Lib/SDL2/include"
"Engine/Lib/glm"
"Engine/Lib/ImGui"
"Engine/Lib/ImGui/backends"
"Engine/Lib/miniaudio"
)
target_include_directories(
CatWareEngine
PRIVATE
"Engine/Source"
"Engine/Lib/yaml-cpp/include"
"Engine/Lib/Glad/include"
"Engine/Lib/Single header"
)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_definitions(CatWareEngine PRIVATE CW_DEBUG)
endif()
# -----------------------------------------------------
# TestScript
# -----------------------------------------------------
option(buildTestScript "buildTestScript" OFF)
if (buildTestScript)
include_directories("Engine/Source/")
link_libraries(CatWareEngine)
set(CMAKE_CXX_STANDARD 17)
add_library(TestScript SHARED TestScript/Source/Main.cpp)
target_include_directories(
TestScript
PRIVATE
"Engine/Source"
)
set_target_properties(TestScript PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/WorkDir/Scripts)
set_target_properties(TestScript PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/WorkDir/Scripts)
set_target_properties(TestScript PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/WorkDir/Scripts)
set_target_properties(TestScript PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/WorkDir/Scripts)
endif()
# -----------------------------------------------------
# Runtime
# -----------------------------------------------------
link_libraries(CatWareEngine)
if (buildTestScript)
link_libraries(TestScript)
endif()
file(GLOB_RECURSE RUNTIME_SOURCE_FILES Runtime/Source/*.cpp)
file(GLOB_RECURSE RUNTIME_HEADER_FILES Runtime/Source/*.h)
add_executable(Runtime ${RUNTIME_SOURCE_FILES} ${RUNTIME_HEADER_FILES})
target_include_directories(
Runtime
PRIVATE
"Runtime/Source"
"Engine/Source"
)
#[[
# -----------------------------------------------------
# Meowditor
# -----------------------------------------------------
file(GLOB_RECURSE EDITOR_SOURCE_FILES Editor/Source/*.cpp)
file(GLOB_RECURSE EDITOR_HEADER_FILES Editor/Source/*.h)
add_executable(Meowditor ${EDITOR_SOURCE_FILES} ${EDITOR_HEADER_FILES} ${CW_IMGUI} ${PROJECT_SOURCE_DIR}/Engine/Lib/ImGui/backends/imgui_impl_opengl3.cpp ${PROJECT_SOURCE_DIR}/Engine/Lib/ImGui/backends/imgui_impl_sdl2.cpp)
target_include_directories(
Meowditor
PRIVATE
"Editor/Source"
"Engine/Source"
)
GroupSourcesByFolder(CatWareEngine)
GroupSourcesByFolder(Meowditor)
GroupSourcesByFolder(Runtime)
#]]