forked from borbrudar/Arcade_16
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (110 loc) · 3.8 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
cmake_minimum_required(VERSION 3.16.0)
if(WIN32)
#default install path, so no spaces
set(CMAKE_INSTALL_PREFIX C:/ CACHE PATH "default path" FORCE)
endif()
project(Arcade VERSION 0.1.1)
set (CMAKE_CXX_STANDARD 17)
#on GCC link stl statically
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
endif()
include(GNUInstallDirs)
include(CTest)
enable_testing()
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/SFML/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
#---------ADD SOURCE AND HEADER FILES ---------------
set(SOURCE_FILE_NAMES
Animation
Arkanoid
Asteroids
Astro
Box
Button
Enemy
Entity
Ghost
Manimation
Mario
Menu
MP
Pac_Man
Pong
Shield
Simon
Space_Invaders
Super_Mario
Tetris
Main
)
list(TRANSFORM SOURCE_FILE_NAMES APPEND ".cpp")
list(TRANSFORM SOURCE_FILE_NAMES PREPEND "src/src/")
if(UNIX)
set(CMAKE_INSTALL_RPATH $ORIGIN/../lib)
endif()
add_executable(${PROJECT_NAME} ${SOURCE_FILE_NAMES})
target_include_directories(Arcade
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/src/include/>
)
#openal32
if(WIN32)
target_include_directories(Arcade
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/win10/
)
#sfml
add_custom_command(TARGET Arcade POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-audio-2.dll"
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-graphics-2.dll"
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-system-2.dll"
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-window-2.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/win10/OpenAL32.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/win10/OpenAL64.dll"
${CMAKE_CURRENT_BINARY_DIR})
endif()
#-----------COPY RES DIR-------------------------
file(COPY res DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
#---------ADD SFML LIBRARY----------------------------
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/SFML")
target_link_libraries(Arcade sfml-graphics sfml-audio)
#--------INSTALL LINUX---------------------------------
install(TARGETS Arcade
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32)
#sfml
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-audio-2.dll"
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-graphics-2.dll"
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-system-2.dll"
"${CMAKE_CURRENT_BINARY_DIR}/external/SFML/lib/sfml-window-2.dll"
#openal
"${CMAKE_CURRENT_SOURCE_DIR}/win10/OpenAL32.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/win10/openal64.dll"
DESTINATION ${CMAKE_INSTALL_BINDIR})
elseif(UNIX)
install(TARGETS Arcade
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
#-------PACKAGING------------------------------------
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)