forked from milkytracker/MilkyTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
228 lines (198 loc) · 7.75 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#
# CMakeLists.txt
#
# Copyright 2016 Dale Whinham
#
# This file is part of MilkyTracker.
#
# MilkyTracker 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 3 of the License, or
# (at your option) any later version.
#
# MilkyTracker 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 MilkyTracker. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.10)
project(MilkyTracker)
# Set C++ standard to C++98
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_EXTENSIONS OFF)
# Enable IDE solution folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Enable tracker-specific functions in MilkyPlay
add_definitions(-DMILKYTRACKER)
# Adhere to GNU filesystem layout conventions
include(GNUInstallDirs)
# Force SDL if requested
option(FORCESDL "Force SDL instead of native" OFF)
if(FORCESDL)
unset(APPLE)
unset(WIN32)
add_definitions(-D__FORCE_SDL_AUDIO__)
endif()
# Lowercase project name for binaries and packaging
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_LOWER)
# Additional CMake modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# Version number in format X.YY.ZZ
set(VER_X 1)
set(VER_YY 03)
set(VER_ZZ 00)
set(VER_FULL "${VER_X}.${VER_YY}.${VER_ZZ}")
# Generate version header from the above
configure_file(
${PROJECT_SOURCE_DIR}/src/tracker/version.h.in
${PROJECT_BINARY_DIR}/src/tracker/version.h
)
# Packaging
if(APPLE)
set(CPACK_GENERATOR DragNDrop)
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME} ${VER_FULL}")
set(
CPACK_DMG_DS_STORE_SETUP_SCRIPT
${PROJECT_SOURCE_DIR}/resources/packaging/osx/DMGSetup.scpt
)
set(
CPACK_DMG_BACKGROUND_IMAGE
${PROJECT_SOURCE_DIR}/resources/packaging/osx/DMGBackground.tif
)
elseif(WIN32)
set(CPACK_GENERATOR ZIP)
else()
set(CPACK_GENERATOR TGZ)
endif()
set(CPACK_PACKAGE_NAME ${PROJECT_NAME_LOWER})
set(CPACK_PACKAGE_VENDOR "MilkyTracker Team")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_VERSION_MAJOR ${VER_X})
set(CPACK_PACKAGE_VERSION_MINOR ${VER_YY})
set(CPACK_PACKAGE_VERSION_PATCH ${VER_ZZ})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FastTracker II compatible music tracker")
include(CPack)
if(APPLE)
# Warn if deployment target isn't set to Lion
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET MATCHES "10.7")
message(WARNING
"Your deployment target is either unset or not set to \"10.7\", "
"which means that the binaries produced may not run on earlier "
"versions of macOS.\n"
"Please re-run CMake with '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.7' "
"or change the variable in the CMake GUI to target Lion and newer."
)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
# Set variables for generating the Info.plist file
set(MACOSX_BUNDLE_BUNDLE_VERSION "${VER_FULL}")
set(MACOSX_BUNDLE_EXECUTABLE ${PROJECT_NAME})
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.Titan.MilkyTracker")
set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "Application")
set(MACOSX_BUNDLE_ICON_FILE "carton")
set(MACOSX_BUNDLE_NAME ${PROJECT_NAME})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VER_FULL}")
# Carbon only required for HIToolbox/Events.h (virtual keycodes)
find_library(CARBON_LIBRARY Carbon)
find_library(COCOA_LIBRARY Cocoa)
find_library(CORE_AUDIO_LIBRARY CoreAudio)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(CORE_MIDI_LIBRARY CoreMIDI)
find_library(CORE_VIDEO_LIBRARY CoreVideo)
find_library(OPENGL_LIBRARY OpenGL)
# OS X MIDI support requires no external libraries
message(STATUS "Enabled MIDI support (Core MIDI)")
add_subdirectory(src/midi)
elseif(WIN32)
# Visual C++ Compiler options
if(MSVC)
# Warn if platform toolset may not be targetting Windows XP upwards
if(NOT CMAKE_VS_PLATFORM_TOOLSET MATCHES "xp")
message(WARNING
"Your currently-selected platform toolset may generate "
"executables which are incompatible with Windows XP.\n"
"Please set your toolset to be one of v110_xp, v120_xp or "
"v140_xp for VS2012, VS2013, and VS2015 respectively.\n"
"You can do so with the '-T' argument to CMake, or by entering "
"it in the CMake GUI."
)
endif()
# Suppress secure string function warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Enable parallel compilation
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# Enable static linkage of the Microsoft Visual C/C++ Runtime
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MTd")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MTd"
)
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
endif()
# Prevent Windows.h from clashing with the Standard Template Library so we
# can use std::min/std::max (see https://support.microsoft.com/kb/143208)
add_definitions(-DNOMINMAX)
# Windows MIDI support requires no external libraries
message(STATUS "Enabled MIDI support (WinMM)")
add_subdirectory(src/midi)
else()
# Workaround for SDL bug #3295, which occurs in SDL2 <2.0.5
# https://bugzilla.libsdl.org/show_bug.cgi?id=3295
cmake_policy(SET CMP0004 OLD)
find_package(SDL2 REQUIRED)
endif()
# Prefer static linkage under OS X for libraries located with find_package()
if(APPLE)
set(SUFFIXES_ORIG ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
# Under macOS and Windows we use Git Submodules to locate the decompression libs
if(UNIX)
# zlib is provided by Linux and macOS
find_package(ZLIB)
# We can't use Brew for these due to OSX target version mismatch
# (we're targeting an older version of OSX to increase compatibility)
if(NOT APPLE)
find_package(LHASA)
find_package(ZZIPLIB)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(ALSA)
find_package(JACK)
# Linux MIDI support requires ALSA and RtMidi
if(ALSA_FOUND)
find_package(RTMIDI 2.1.0)
if(RTMIDI_FOUND)
message(STATUS "Enabled MIDI support (ALSA/RtMidi)")
add_subdirectory(src/midi)
else()
message("MIDI support disabled (RtMidi unavailable)")
endif()
else()
message("MIDI support disabled (ALSA unavailable)")
endif()
endif()
endif()
# Restore library suffixes
if(APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${SUFFIXES_ORIG})
endif()
add_subdirectory(docs)
add_subdirectory(resources/music)
add_subdirectory(src/compression)
add_subdirectory(src/fx)
add_subdirectory(src/milkyplay)
add_subdirectory(src/ppui)
add_subdirectory(src/tracker)
# Set MilkyTracker target as startup project in Visual Studio
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT tracker)