-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
146 lines (123 loc) · 5.35 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
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.19)
project(timeless VERSION 0.3)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
set(ENABLE_PRECOMPILED_HEADERS OFF)
set(CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz TRUE)
set(CMAKE_DISABLE_FIND_PACKAGE_libpng TRUE)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_DOC OFF)
set(BUILD_SANDBOX OFF)
# set(GLFW_INSTALL ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(apple)
# set(CMAKE_MACOSX_RPATH 1)
# SET(CMAKE_INSTALL_RPATH @loader_path/../Framework)
endif()
if(LINUX)
set(GLFW_BUILD_WAYLAND OFF)
set(GLFW_BUILD_X11 ON)
endif()
# set(GLFW_LIBRARY_TYPE SHARED)
# add_executable(${PROJECT_NAME} MACOSX_BUNDLE src/main.cpp)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/glad)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/glm)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/freetype2)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/cereal)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod)
# find_package(fmod)
include_directories("${PROJECT_BINARY_DIR}" glad/include glfw/include freetype2/include glm/include stb_image/)
add_library(${PROJECT_NAME} STATIC "example/main.cpp")
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
# add property for shaders folder - to be copied into game build "Assets/" folder
set_property(
TARGET ${PROJECT_NAME}
APPEND PROPERTY
SHADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/shaders"
)
# add property for fmod folder to copy dll files
set_property(
TARGET ${PROJECT_NAME}
APPEND PROPERTY
FMOD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod"
)
# set_target_properties(${PROJECT_NAME}
# PROPERTIES SUFFIX ".html"
# LINK_FLAGS " -O3 -sFULL_ES3 -sUSE_GLFW=3 -sUSE_FREETYPE=1 -s EXPORTED_RUNTIME_METHODS=['cwrap','setValue','getValue'] --preload-file Assets")
# target_include_directories(${PROJECT_NAME} INTERFACE src/)
target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_BINARY_DIR}" src/ vendor/glfw/include vendor/glad/include vendor/freetype2/include vendor/glm vendor/stb_image/ vendor/cereal/include)
# target_include_directories(${PROJECT_NAME} INTERFACE src/)
target_link_libraries(${PROJECT_NAME} glad glfw glm freetype fmod fmod_studio)
link_libraries(${PROJECT_NAME} fmod fmod_studio)
if(WIN32)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod/win/core/lib/fmod.dll
${CMAKE_CURRENT_BINARY_DIR}/fmod.dll)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod/win/core/lib/fmod_vc.lib
${CMAKE_CURRENT_BINARY_DIR}/fmod_vc.lib)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod/win/studio/lib/fmodstudio.dll
${CMAKE_CURRENT_BINARY_DIR}/fmodstudio.dll)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod/win/studio/lib/fmodstudio_vc.lib
${CMAKE_CURRENT_BINARY_DIR}/fmodstudio_vc.lib)
endif()
if(apple)
install(TARGETS ${PROJECT_NAME}
glad freetype glm glfw DESTINATION ${PROJECT_BINARY_DIR}
BUNDLE DESTINATION ${PROJECT_BINARY_DIR}
)
install(IMPORTED_RUNTIME_ARTIFACTS ${PROJECT_NAME})
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${FMOD_DIR}/apple/core/lib/libfmodL.dylib
${CMAKE_CURRENT_BINARY_DIR}/libfmodL.dylib)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${FMOD_DIR}/apple/studio/lib/libfmodstudioL.dylib
${CMAKE_CURRENT_BINARY_DIR}/libfmodstudioL.dylib)
endif()
if(UNIX AND NOT APPLE)
message(STATUS "LINUX BUILD!")
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod/linux/core/lib/x86_64/libfmod.so.13
${CMAKE_CURRENT_BINARY_DIR}/libfmod.so.13)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/vendor/fmod/linux/studio/lib/x86_64/libfmodstudio.so.13
${CMAKE_CURRENT_BINARY_DIR}/libfmodstudio.so.13)
endif()
add_subdirectory(example example)
# target_link_libraries(${PROJECT_NAME} glad glfw glm freetype "${FMOD_DIR}/studio/lib/upstream/w32/fmodstudio_wasm.a" "${FMOD_DIR}/core/lib/upstream/w32/fmod_wasm.a")
# add_custom_command(
# TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# ${CMAKE_SOURCE_DIR}/shaders
# ${CMAKE_CURRENT_BINARY_DIR}/shaders)
# add_custom_command(
# TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# ${CMAKE_SOURCE_DIR}/fonts
# ${CMAKE_CURRENT_BINARY_DIR}/fonts)
# add_custom_command(
# TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# ${CMAKE_SOURCE_DIR}/textures
# ${CMAKE_CURRENT_BINARY_DIR}/textures)