-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
123 lines (97 loc) · 3.6 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
cmake_minimum_required(VERSION 2.8)
######################
# Project definition #
######################
project(freetumble)
set(FT_MAJOR_VERSION 1)
set(FT_MINOR_VERSION 1)
set(FT_PATCH_VERSION 0)
set(FT_VERSION "${FT_MAJOR_VERSION}.${FT_MINOR_VERSION}")
if(FT_PATCH_VERSION GREATER 0)
set(FT_VERSION "${FT_VERSION}.${FT_PATCH_VERSION}")
endif()
add_definitions(-DVERSION="${FT_VERSION}")
option(FOR_INSTALL "Build the binary to look for its data in system directories." OFF)
if(FOR_INSTALL)
# Set binary and data install locations if we want to use the installer
set(FT_BIN_PATH ${CMAKE_INSTALL_PREFIX}/games CACHE PATH "Absolute path to the game binary directory")
set(FT_DATA_PATH ${CMAKE_INSTALL_PREFIX}/share/games/${PROJECT_NAME} CACHE PATH "Absolute path to the game data directory")
set(FT_SHARE_PATH ${CMAKE_INSTALL_PREFIX}/share CACHE PATH "Absolute path to the shared data directory (desktop file, icons, etc.)")
# Set the data paths
add_definitions(-DDATADIR="${FT_DATA_PATH}")
endif()
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMake build type is not set, defaulting to 'RelWithDebInfo'")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
################
# Source files #
################
set(SRC ${CMAKE_SOURCE_DIR}/src)
set(FT_SOURCEFILES
${SRC}/gameEngine/GameInput.cpp
${SRC}/gameEngine/GameMain.cpp
${SRC}/gameEngine/GameModel.cpp
${SRC}/gameEngine/GameScores.cpp
${SRC}/gameEngine/Menu.cpp
${SRC}/gameEngine/MenuEntry.cpp
${SRC}/gfxEngine/EntityManager.cpp
${SRC}/gfxEngine/GameEntity.cpp
${SRC}/gfxEngine/GfxEngine.cpp
${SRC}/main.cpp
)
# Create the binary file
add_executable(${PROJECT_NAME} ${FT_SOURCEFILES})
#####################
# Find dependencies #
#####################
find_package(SFML 2 REQUIRED COMPONENTS audio graphics system window)
#######################
# Headers and linking #
#######################
include_directories(
# FreeTumble includes
${SRC}
)
# Link libraries
target_link_libraries(
# target
${PROJECT_NAME}
# libraries
sfml-graphics
sfml-audio
# Don't need to be specified with SFML 2.5+, but we still support 2.4
sfml-window
sfml-system
)
################
# Installation #
################
if(FOR_INSTALL)
set(FT_DATADIRS ${CMAKE_SOURCE_DIR}/gfx
${CMAKE_SOURCE_DIR}/music
${CMAKE_SOURCE_DIR}/sfx
${CMAKE_SOURCE_DIR}/skins
${CMAKE_SOURCE_DIR}/tilesets)
set(FT_DATAFILES ${CMAKE_SOURCE_DIR}/FreeSansBold.ttf
${CMAKE_SOURCE_DIR}/reset_scores.dat)
set(FT_DOC ${CMAKE_SOURCE_DIR}/CHANGELOG.md
${CMAKE_SOURCE_DIR}/LICENSE.txt
${CMAKE_SOURCE_DIR}/README.md)
install(TARGETS ${PROJECT_NAME}
DESTINATION ${FT_BIN_PATH}
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY ${FT_DATADIRS}
DESTINATION ${FT_DATA_PATH})
install(FILES ${FT_DATAFILES}
DESTINATION ${FT_DATA_PATH})
# Additional distribution content (desktop file, icon)
install(FILES ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.desktop
DESTINATION ${FT_SHARE_PATH}/applications)
install(FILES ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.png
DESTINATION ${FT_SHARE_PATH}/icons/hicolor/64x64/apps)
install(FILES ${CMAKE_SOURCE_DIR}/dist/${PROJECT_NAME}.svg
DESTINATION ${FT_SHARE_PATH}/icons/hicolor/scalable/apps)
install(FILES ${FT_DOC}
DESTINATION ${FT_SHARE_PATH}/doc/${PROJECT_NAME})
endif()