-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
139 lines (120 loc) · 3.79 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.20)
project(feather)
set(CMAKE_CXX_STANDARD 17)
# GLFW
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
# subdirectories
add_subdirectory(thirdparty/glfw)
add_subdirectory(thirdparty/lua)
add_subdirectory(thirdparty/imgui)
add_subdirectory(thirdparty/tracy)
add_subdirectory(thirdparty/cpputest)
add_subdirectory(thirdparty/yojimbo)
add_subdirectory(tests)
add_subdirectory(server)
# Vulkan
find_package(Vulkan REQUIRED)
# FreeType
## set(FREETYPE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/thirdparty/freetype/")
if(WIN32)
set(FREETYPE_LIBRARY
"${CMAKE_SOURCE_DIR}/thirdparty/freetype/lib/freetype.lib"
)
file(COPY "${CMAKE_SOURCE_DIR}/thirdparty/freetype/lib/freetype.dll" DESTINATION ${CMAKE_BINARY_DIR})
endif()
# YAML-CPP
set(YAML_CPP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/thirdparty/yaml-cpp/inc")
if(WIN32)
set(YAML_CPP_LIBRARY
debug "${CMAKE_SOURCE_DIR}/thirdparty/yaml-cpp/lib/yaml-cppd.lib"
optimized "${CMAKE_SOURCE_DIR}/thirdparty/yaml-cpp/lib/yaml-cpp.lib"
)
file(COPY "${CMAKE_SOURCE_DIR}/thirdparty/yaml-cpp/lib/yaml-cppd.dll" DESTINATION ${CMAKE_BINARY_DIR})
file(COPY "${CMAKE_SOURCE_DIR}/thirdparty/yaml-cpp/lib/yaml-cpp.dll" DESTINATION ${CMAKE_BINARY_DIR})
endif()
# Messages
message("Libraries:")
message(VULKAN_INCLUDE_DIRS: ${Vulkan_INCLUDE_DIRS})
message(VULKAN_LIB: ${Vulkan_LIBRARIES})
message(YAML_CPP_LIBRARY: ${YAML_CPP_LIBRARY})
message(FREETYPE_LIBRARY: ${FREETYPE_LIBRARY})
# include directories
include_directories(
thirdparty
thirdparty/entt/single_include
thirdparty/glm
thirdparty/json/single_include
thirdparty/miniaudio
${YAML_CPP_INCLUDE_DIR}
)
# which folder to use for the game (code/assets/etc)
set(GAME_FOLDER "game")
# load source and header files
file(GLOB_RECURSE SOURCE_FILES
"src/*.h"
"src/*.cpp"
"${GAME_FOLDER}/src/*.h"
"${GAME_FOLDER}/src/*.cpp"
)
# Package project with CPACK
SET(CPACK_GENERATOR "ZIP")
SET(CPACK_PACKAGE_NAME "Feather - v0.0.1")
include(CPack)
# tests
#option(COMPILE_TESTS "Compile the tests" OFF)
#if(COMPILE_TESTS)
# add_subdirectory(tests)
#endif(COMPILE_TESTS)
# application icon
set(APP_ICON_RESOURCE_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/appicon.rc")
# creating executable
if(WIN32)
add_executable(${PROJECT_NAME}
${SOURCE_FILES}
thirdparty/glad/glad.c
${APP_ICON_RESOURCE_WINDOWS}
)
else()
add_executable(${PROJECT_NAME}
${SOURCE_FILES}
thirdparty/glad/glad.c
${APP_ICON_RESOURCE_WINDOWS}
)
endif()
if(WIN32)
target_link_libraries(
${PROJECT_NAME}
glfw
Vulkan::Vulkan
lua_lib
imgui
TracyClient
yojimbo
${CMAKE_SOURCE_DIR}/thirdparty/yojimbo/mbedtls.lib
${CMAKE_SOURCE_DIR}/thirdparty/yojimbo/mbedx509.lib
${CMAKE_SOURCE_DIR}/thirdparty/yojimbo/mbedcrypto.lib
${CMAKE_SOURCE_DIR}/thirdparty/yojimbo/sodium.lib
${YAML_CPP_LIBRARY}
${FREETYPE_LIBRARY}
)
else()
target_link_libraries(
${PROJECT_NAME}
glfw
Vulkan::Vulkan
lua_lib
imgui
TracyClient
)
endif()
# defining final executable name
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "Feather - v0.0.1")
# pre-build stuff (shader compilation and asset copying to binary folder)
add_custom_target(pre_build
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/pre-build.cmake
)
add_dependencies(${PROJECT_NAME} pre_build)
# TODO: Use rcedit after cmake build to change windows executable details
# TODO: Package project with CPACK