-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathCMakeLists.txt
172 lines (141 loc) · 5.41 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
##------------------------------------------------------------------------------
##
## Doom64EX CMake configuration
##
## LICENSE:
##
## Copyright(C) 2016 Zohar Malamant
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
##
cmake_minimum_required(VERSION 2.8.12)
project(Doom64EX C CXX)
##------------------------------------------------------------------------------
## Build Options
##
option(ENABLE_TESTING "Compile unit tests" ON)
option(ENABLE_SYSTEM_FLUIDSYNTH "Link with system-wide fluidsynth and not fluidsynth-lite" OFF)
option(ENABLE_GTK3 "Display windows using GTK+3" OFF)
option(VERSION_DEV "Add git commit hash to window title" ON)
# If fluidsynth-lite wasn't cloned, fall back to using system fluidsynth.
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/fluidsynth/CMakeLists.txt" AND NOT ENABLE_SYSTEM_FLUIDSYNTH)
set(ENABLE_SYSTEM_FLUIDSYNTH ON)
message(WARNING "The fluidsynth submodule wasn't initialised. Run `git submodule --init --recursive` to use fluidsynth-lite, or add -DENABLE_SYSTEM_FLUIDSYNTH=ON to use the system-provided FluidSynth library.")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" "${CMAKE_SOURCE_DIR}/extern")
set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}" "${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(DATA_DIR "${CMAKE_SOURCE_DIR}/data")
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
set(USE_CONAN ON)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
set(USE_CONAN OFF)
endif()
##------------------------------------------------------------------------------
## Compiler Options
##
if(NOT MSVC AND CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "Debug mode: Enabling stricter warnings")
set(FLAGS "-Wall -Wno-unknown-pragmas -Wno-undefined-var-template -fno-strict-aliasing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
if(NOT MINGW)
message(STATUS "Debug mode: Enabling AddressSanitizer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
endif()
if(MINGW)
add_definitions(-DFMT_USE_WINDOWS_H=0)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows -static")
endif(MINGW)
##------------------------------------------------------------------------------
## Configure config.hh
##
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_GIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_DEV)
set(VERSION_FULL "${VERSION}-git+${VERSION_GIT}")
endif()
configure_file("${CMAKE_SOURCE_DIR}/src/config.hh.in" "${CMAKE_BINARY_DIR}/config/config.hh")
##------------------------------------------------------------------------------
## Dependencies
##
if (NOT USE_CONAN)
# SDL2
find_package(SDL2 REQUIRED)
# SDL2_Net
find_package(SDL2_net REQUIRED)
# zlib
find_package(ZLIB REQUIRED)
# libpng
find_package(PNG REQUIRED)
# FluidSynth
if (ENABLE_SYSTEM_FLUIDSYNTH)
find_package(FluidSynth REQUIRED)
endif()
# OpenGL
find_package(OpenGL REQUIRED)
# GTK3
if(ENABLE_GTK3)
find_package(GTK3 REQUIRED)
find_package(Vala REQUIRED)
endif(ENABLE_GTK3)
endif(NOT USE_CONAN)
if(BUILD_TESTS)
find_package(GTest)
endif(BUILD_TESTS)
##------------------------------------------------------------------------------
## Include subprojects
##
if(NOT ENABLE_SYSTEM_FLUIDSYNTH)
add_subdirectory("${CMAKE_SOURCE_DIR}/fluidsynth")
endif()
add_subdirectory("${CMAKE_SOURCE_DIR}/src/engine")
if(ENABLE_GTK3)
add_subdirectory("${CMAKE_SOURCE_DIR}/src/gtk3")
endif(ENABLE_GTK3)
##------------------------------------------------------------------------------
## doom64ex.pk3 target
##
# CMake 3.3.2 is the earliest version with support for --format=zip
if(CMAKE_VERSION VERSION_LESS 3.3.2)
message(WARNING "Your CMake version is fairly old, so you'll need to generate the doom64ex.pk3 file manually. See README.md for more information.")
else()
# Build doom64ex.pk3
add_custom_target(pk3 ALL
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/distrib/doom64ex.pk3"
COMMAND "${CMAKE_COMMAND}" -E tar "cfv" "${CMAKE_BINARY_DIR}/doom64ex.pk3" --format=zip "--files-from=${CMAKE_SOURCE_DIR}/distrib/doom64ex_pk3.txt")
# Install doom64ex.pk3
if (NOT WIN32)
if (APPLE)
install(FILES "${CMAKE_BINARY_DIR}/doom64ex.pk3" DESTINATION "$ENV{HOME}/Library/Application Support/doom64ex")
else ()
install(FILES "${CMAKE_BINARY_DIR}/doom64ex.pk3" DESTINATION share/games/doom64ex)
endif ()
endif ()
endif()