-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
134 lines (110 loc) · 3.52 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
cmake_minimum_required(VERSION 3.10)
project(GrappleGame VERSION 1.0)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(ZLIB REQUIRED)
get_target_property(SDL2_INCLUDE_DIRS SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(SDL2_image_INCLUDE_DIRS SDL2_image::SDL2_image INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(SDL2_ttf_INCLUDE_DIRS SDL2_ttf::SDL2_ttf INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${SDL2_image_INCLUDE_DIRS})
include_directories(${SDL2_ttf_INCLUDE_DIRS})
include_directories(${ZLIB_INCLUDE_DIRS})
set(ENGINE_DIR ${PROJECT_SOURCE_DIR}/src/engine)
set(FileIO_DIR ${PROJECT_SOURCE_DIR}/src/file)
set(UTIL_DIR ${PROJECT_SOURCE_DIR}/src/util)
set(GAME_DIR ${PROJECT_SOURCE_DIR}/src/game)
set(NFD_DIR ${PROJECT_SOURCE_DIR}/src/nativefiledialog)
add_compile_options(/MD)
add_library(nfd OBJECT
${NFD_DIR}/nfd_win.cpp
${NFD_DIR}/nfd_common.c
${NFD_DIR}/nfdcpp.cpp
)
target_compile_options(nfd PRIVATE /w)
target_link_libraries(nfd User32.lib)
add_library(
FileIO OBJECT
${FileIO_DIR}/json.cpp
${FileIO_DIR}/compression.cpp
)
add_library(
Engine OBJECT
${ENGINE_DIR}/game.cpp
${ENGINE_DIR}/engine.cpp
${ENGINE_DIR}/input.cpp
${ENGINE_DIR}/texture.cpp
${ENGINE_DIR}/ui.cpp
)
add_library(
Util OBJECT
${UTIL_DIR}/geometry.cpp
)
add_library(
Game OBJECT
${GAME_DIR}/climbGame.cpp
${GAME_DIR}/config.cpp
${GAME_DIR}/entity.cpp
${GAME_DIR}/level.cpp
${GAME_DIR}/levelMaker.cpp
${GAME_DIR}/menu.cpp
)
add_compile_definitions(ROOT_BUILD)
add_executable(main src/main.cpp)
target_link_options(main PUBLIC /SUBSYSTEM:CONSOLE)
target_link_options(main PUBLIC /ENTRY:WinMainCRTStartup)
target_link_libraries(main shell32)
target_link_libraries(main Engine)
target_link_libraries(main FileIO)
target_link_libraries(main Util)
target_link_libraries(main Game)
target_link_libraries(main nfd)
target_link_libraries(main ${SDL2_LIBRARIES})
target_link_libraries(main SDL2_image::SDL2_image)
target_link_libraries(main SDL2_ttf::SDL2_ttf)
target_link_libraries(main ZLIB::ZLIB)
cmake_path(GET ZLIB_LIBRARIES PARENT_PATH ZLIB_ROOT)
cmake_path(GET ZLIB_ROOT PARENT_PATH ZLIB_ROOT)
cmake_path(APPEND ZLIB_ROOT ${ZLIB_ROOT} bin)
message(STATUS ${ZLIB_ROOT})
find_file(ZLIB_DLL zlib.dll HINTS ${ZLIB_ROOT} REQUIRED)
add_custom_command (TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL2::SDL2> $<TARGET_FILE_DIR:main>
)
add_custom_command (TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL2_image::SDL2_image> $<TARGET_FILE_DIR:main>
)
add_custom_command (TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL2_ttf::SDL2_ttf> $<TARGET_FILE_DIR:main>
)
add_custom_command (TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${ZLIB_DLL} $<TARGET_FILE_DIR:main>
)
install (
TARGETS main
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install (
FILES
$<TARGET_FILE:SDL2::SDL2>
$<TARGET_FILE:SDL2_ttf::SDL2_ttf>
$<TARGET_FILE:SDL2_image::SDL2_image>
${ZLIB_DLL}
config.json
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install (
DIRECTORY
assets config
DESTINATION ${CMAKE_INSTALL_PREFIX}
PATTERN "font" EXCLUDE
)