-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
137 lines (119 loc) · 3.69 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
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
# Projet name
project("Witch_Blast")
# Detect compiler
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(USING_GCC TRUE)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(USING_CLANG TRUE)
endif()
# For GCC and Clang, enable C++11 support and add some other flags
if(USING_GCC OR USING_CLANG)
add_compile_options(-std=c++11 -pedantic -Wall)
endif()
# Compilation options
option(ONLINE_MODE "Enable online mode, which requires src/OnlineScoring.h" OFF)
if(ONLINE_MODE)
add_compile_options(-DONLINE_MODE)
endif()
include_directories(.)
file(
GLOB_RECURSE
source_files
src/*
)
if(APPLE)
set(${source_files} “${source_files} src/ressources/witchblast.icns”)
set_source_files_properties(src/ressources/witchblast.icns
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(MACOSX_BUNDLE_ICON_FILE witchblast.icns)
endif()
add_executable(
"Witch_Blast"
MACOSX_BUNDLE
${source_files}
)
set_target_properties(Witch_Blast PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}
)
if(APPLE)
set_target_properties(Witch_Blast PROPERTIES
MACOSX_RPATH 1
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH "@loader_path/../Frameworks")
set(EXTRA_LIBRARIES "-framework CoreFoundation")
endif()
if(UNIX)
find_package(Threads REQUIRED)
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(PUBLIC Witch_Blast "-pthread")
endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(Witch_Blast "${CMAKE_THREAD_LIBS_INIT}")
endif()
endif()
# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
if(ONLINE_MODE)
find_package(SFML 2.2 REQUIRED system window graphics audio network)
else()
find_package(SFML 2.2 REQUIRED system window graphics audio)
endif()
target_link_libraries(Witch_Blast ${SFML_LIBRARIES} ${EXTRA_LIBRARIES})
include_directories(${SFML_INCLUDE_DIR})
Message(${SFML_LIBRARIES})
# Find LibGamerzilla library or build it if missing
if (NOT APPLE)
include(FindPkgConfig)
pkg_search_module(GAMERZILLA OPTIONAL gamerzilla)
if (GAMERZILLA_LIBRARIES)
message(STATUS "Gamerzilla found")
include_directories(${GAMERZILLA_INCLUDE_DIRS})
target_link_libraries(Witch_Blast ${GAMERZILLA_LIBRARIES})
add_definitions(-DGAMERZILLA)
endif()
endif()
if(APPLE)
install(
DIRECTORY Witch_Blast.app
DESTINATION "."
USE_SOURCE_PERMISSIONS)
install(
DIRECTORY
${CMAKE_SOURCE_DIR}/data
${CMAKE_SOURCE_DIR}/media
DESTINATION Witch_Blast.app/Contents/Resources)
# copy SFML frameworks into app bundle for Mac OS X
foreach(LIB ${SFML_LIBRARIES})
install(DIRECTORY ${LIB}
DESTINATION Witch_Blast.app/Contents/Frameworks)
endforeach()
set(SFML_LIBRARIES_EXTRA
SFML FLAC freetype ogg OpenAL vorbis vorbisenc vorbisfile)
foreach(LIB ${SFML_LIBRARIES_EXTRA})
install(DIRECTORY /Library/Frameworks/${LIB}.framework
DESTINATION Witch_Blast.app/Contents/Frameworks)
endforeach()
install(FILES
${CMAKE_SOURCE_DIR}/COPYING.txt
${CMAKE_SOURCE_DIR}/readme.txt
DESTINATION ".")
endif()
# Packaging
SET(CPACK_PACKAGE_VERSION "0.7.5")
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
SET(CPACK_PACKAGE_VERSION_MINOR "7")
SET(CPACK_PACKAGE_VERSION_PATCH "5")
SET(CPACK_PACKAGE_EXECUTABLES "Witch_Blast;Witch Blast")
if(APPLE)
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "Witch Blast")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_ICON src/ressources/witchblast.icns)
# TODO: CPACK_DMG_BACKGROUND_IMAGE
# TODO: CPACK_DMG_DS_STORE
endif()
include(CPack)