-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (127 loc) · 7.96 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
147
148
149
150
151
152
153
154
155
156
# At LEAST 2.8 but newer is better
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(Asteroids VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
file(GLOB SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/*.cpp
${CMAKE_CURRENT_LIST_DIR}/*.h
${CMAKE_CURRENT_LIST_DIR}/Entities/*.cpp
${CMAKE_CURRENT_LIST_DIR}/Entities/*.h
${CMAKE_CURRENT_LIST_DIR}/Managers/*.cpp
${CMAKE_CURRENT_LIST_DIR}/Managers/*.h
${CMAKE_CURRENT_LIST_DIR}/Asteroids/*.cpp
${CMAKE_CURRENT_LIST_DIR}/Asteroids/*.h
${CMAKE_CURRENT_LIST_DIR}/Physics/*.cpp
${CMAKE_CURRENT_LIST_DIR}/Physics/*.h
${CMAKE_CURRENT_LIST_DIR}/Asteroids/*.h
${CMAKE_CURRENT_LIST_DIR}/Asteroids/*.cpp
)
file(GLOB_RECURSE TMP_FILES
${CMAKE_CURRENT_LIST_DIR}/Asteroids/*.h
${CMAKE_CURRENT_LIST_DIR}/Asteroids/*.cpp
)
foreach(f ${TMP_FILES})
# Get the path of the file relative to ${DIRECTORY},
# then alter it (not compulsory)
file(RELATIVE_PATH SRCGR ${CMAKE_CURRENT_LIST_DIR} ${f})
if (${f} MATCHES ".*cpp")
set(SRCGR "Source Files/${SRCGR}")
elseif (${f} MATCHES ".*h")
set(SRCGR "Header Files/${SRCGR}")
endif()
# Extract the folder, ie remove the filename part
string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR})
# Source_group expects \\ (double antislash), not / (slash)
string(REPLACE / \\ SRCGR ${SRCGR})
source_group("${SRCGR}" FILES ${f})
endforeach()
file(GLOB_RECURSE TMP_FILES
${CMAKE_CURRENT_LIST_DIR}/Physics/*.h
${CMAKE_CURRENT_LIST_DIR}/Physics/*.cpp
)
foreach(f ${TMP_FILES})
# Get the path of the file relative to ${DIRECTORY},
# then alter it (not compulsory)
file(RELATIVE_PATH SRCGR ${CMAKE_CURRENT_LIST_DIR} ${f})
if (${f} MATCHES ".*cpp")
set(SRCGR "Source Files/${SRCGR}")
elseif (${f} MATCHES ".*h")
set(SRCGR "Header Files/${SRCGR}")
endif()
# Extract the folder, ie remove the filename part
string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR})
# Source_group expects \\ (double antislash), not / (slash)
string(REPLACE / \\ SRCGR ${SRCGR})
source_group("${SRCGR}" FILES ${f})
endforeach()
file(GLOB_RECURSE TMP_FILES
${CMAKE_CURRENT_LIST_DIR}/Entities/*.h
${CMAKE_CURRENT_LIST_DIR}/Entities/*.cpp
)
foreach(f ${TMP_FILES})
# Get the path of the file relative to ${DIRECTORY},
# then alter it (not compulsory)
file(RELATIVE_PATH SRCGR ${CMAKE_CURRENT_LIST_DIR} ${f})
if (${f} MATCHES ".*cpp")
set(SRCGR "Source Files/${SRCGR}")
elseif (${f} MATCHES ".*h")
set(SRCGR "Header Files/${SRCGR}")
endif()
# Extract the folder, ie remove the filename part
string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR})
# Source_group expects \\ (double antislash), not / (slash)
string(REPLACE / \\ SRCGR ${SRCGR})
source_group("${SRCGR}" FILES ${f})
endforeach()
file(GLOB_RECURSE TMP_FILES
${CMAKE_CURRENT_LIST_DIR}/Managers/*.h
${CMAKE_CURRENT_LIST_DIR}/Managers/*.cpp
)
foreach(f ${TMP_FILES})
# Get the path of the file relative to ${DIRECTORY},
# then alter it (not compulsory)
file(RELATIVE_PATH SRCGR ${CMAKE_CURRENT_LIST_DIR} ${f})
if (${f} MATCHES ".*cpp")
set(SRCGR "Source Files/${SRCGR}")
elseif (${f} MATCHES ".*h")
set(SRCGR "Header Files/${SRCGR}")
endif()
# Extract the folder, ie remove the filename part
string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR})
# Source_group expects \\ (double antislash), not / (slash)
string(REPLACE / \\ SRCGR ${SRCGR})
source_group("${SRCGR}" FILES ${f})
endforeach()
SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/Debug)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Asteroids)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
add_executable(Asteroids ${SOURCE_FILES})
target_include_directories (Asteroids PUBLIC ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL/include)
target_include_directories (Asteroids PUBLIC ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL2_ttf-2.0.14/include)
target_include_directories (Asteroids PUBLIC ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL2_image-2.0.4/include)
target_include_directories (Asteroids PUBLIC ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL2_mixer-2.0.4/include)
target_link_libraries(Asteroids ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL/lib/win32/SDL2.lib)
target_link_libraries(Asteroids ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL/lib/win32/SDL2main.lib)
target_link_libraries(Asteroids ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL2_ttf-2.0.14/lib/x86/SDL2_ttf.lib)
target_link_libraries(Asteroids ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL2_image-2.0.4/lib/x86/SDL2_image.lib)
target_link_libraries(Asteroids ${CMAKE_CURRENT_LIST_DIR}/ExternalDependencies/SDL2_mixer-2.0.4/lib/x86/SDL2_mixer.lib)
add_custom_command(TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/SDL2.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/SDL2_ttf.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libfreetype-6.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libpng16-16.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libwebp-7.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libjpeg-9.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/SDL2_image.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libtiff-5.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/zlib1.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libFLAC-8.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libmodplug-1.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libmpg123-0.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libogg-0.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libopus-0.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libopusfile-0.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libvorbis-0.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/libvorbisfile-3.dll" $<TARGET_FILE_DIR:Asteroids>
TARGET Asteroids POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/ExternalDependencies/dlls/SDL2_mixer.dll" $<TARGET_FILE_DIR:Asteroids>
)