Debian Codegraph @

src/CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 # Cmake File for Piano Booster
2
3 option(WITH_INTERNAL_FLUIDSYNTH "Build with an internal FluidSynth sound generator" ON)
4 option(USE_FTGL "Build with ftgl for notes localization" ON)
5 option(USE_SYSTEM_FONT "Build with system font" OFF)
6 option(USE_JACK "Build with Jack (Only required for BSD Unix)" OFF)
7 if(${CMAKE_SYSTEM} MATCHES "Linux")
8 option(USE_BUNDLED_RTMIDI "Build with bundled rtmidi (for older distributions only)" OFF)
9 else()
10 option(USE_BUNDLED_RTMIDI "Build with bundled rtmidi" ON)
11 endif()
12
13 cmake_minimum_required(VERSION 2.4)
14 if(COMMAND cmake_policy)
15 cmake_policy(SET CMP0003 NEW)
16 endif(COMMAND cmake_policy)
17
18 if(WIN32)
19 MESSAGE("GUI system is WIN32 ${CMAKE_GENERATOR}")
20 endif(WIN32)
21
22 # set project's name
23 PROJECT( pianobooster )
24
25 cmake_policy(SET CMP0020 NEW)
26 cmake_policy(SET CMP0043 NEW)
27
28 # enable warnings
29 add_compile_options(-Wall)
30
31
32 add_compile_options("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
33
34 if(NOT DATA_DIR)
35 set(DATA_DIR "share/games/pianobooster")
36 endif()
37 add_compile_options("-DDATA_DIR=\"${DATA_DIR}\"")
38
39 if(NOT CMAKE_INSTALL_BINDIR)
40 set(CMAKE_INSTALL_BINDIR "bin")
41 endif()
42
43 MESSAGE("PREFIX: " ${CMAKE_INSTALL_PREFIX})
44 MESSAGE("DATA_DIR: " ${DATA_DIR})
45 MESSAGE("CMAKE_INSTALL_BINDIR: " ${CMAKE_INSTALL_BINDIR})
46
47 FIND_PACKAGE( OpenGL REQUIRED )
48
49 if(NOT WIN32)
50 # the `pkg_check_modules` function is created with this call
51 include(FindPkgConfig)
52 FIND_PACKAGE( PkgConfig REQUIRED )
53 endif()
54
55 if(USE_FTGL)
56 if(NOT WIN32)
57 pkg_check_modules(FTGL ftgl)
58 if(NOT FTGL_FOUND)
59 MESSAGE(FATAL_ERROR "FTGL was not found")
60 endif(NOT FTGL_FOUND)
61 SET(FTGL_INCLUDE_DIR ${FTGL_INCLUDE_DIRS})
62 SET(FTGL_LIBRARY ${FTGL_LIBRARIES})
63 else()
64 FIND_PACKAGE( ftgl REQUIRED )
65 endif()
66 else(USE_FTGL)
67 add_compile_options("-DNO_USE_FTGL")
68 endif(USE_FTGL)
69
70 if(NO_LANGS)
71 add_compile_options("-DNO_LANGS")
72 endif()
73
74 # Finds Qt5 libraries
75 FIND_PACKAGE( Qt5 REQUIRED COMPONENTS Core Gui Widgets LinguistTools OpenGL Xml )
76
77 add_compile_options(-fPIC)
78
79 # Add in the link libraries for each operating system
80 if(${CMAKE_SYSTEM} MATCHES "Linux")
81 ADD_DEFINITIONS(-D__LINUX_ALSA__)
82 LINK_LIBRARIES (asound)
83 LINK_LIBRARIES (pthread)
84 LINK_LIBRARIES (GL)
85 endif(${CMAKE_SYSTEM} MATCHES "Linux")
86
87 if(${CMAKE_SYSTEM} MATCHES "Windows")
88 ADD_DEFINITIONS(-D__WINDOWS_MM__ -D_WIN32)
89 LINK_LIBRARIES(winmm opengl32)
90 endif(${CMAKE_SYSTEM} MATCHES "Windows")
91
92 if(${CMAKE_SYSTEM} MATCHES "Darwin")
93 ADD_DEFINITIONS(-D__MACOSX_CORE__)
94 ADD_DEFINITIONS(-std=c++11)
95 LINK_LIBRARIES("-framework CoreMidi -framework CoreAudio -framework CoreFoundation -framework OpenGL")
96 endif(${CMAKE_SYSTEM} MATCHES "Darwin")
97
98 if(WITH_INTERNAL_FLUIDSYNTH)
99 if(NOT WIN32)
100 pkg_check_modules(FLUIDSYNTH fluidsynth)
101
102 if(NOT FLUIDSYNTH_FOUND)
103 MESSAGE(FATAL_ERROR "FLUIDSYNTH was not found")
104 endif(NOT FLUIDSYNTH_FOUND)
105 INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIRS})
106 SET(FLUIDSYNTH_LIBRARY ${FLUIDSYNTH_LIBRARIES})
107 else()
108 FIND_PACKAGE( fluidsynth REQUIRED )
109 endif()
110 ADD_DEFINITIONS(-DWITH_INTERNAL_FLUIDSYNTH)
111 MESSAGE("Building with internal fluidsynth")
112 SET( PB_BASE_SRCS MidiDeviceFluidSynth.cpp )
113 endif(WITH_INTERNAL_FLUIDSYNTH)
114
115 # we need this to be able to include headers produced by uic in our code
116 # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
117 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} ${OPENGL_INCLUDE_DIR} ${FTGL_INCLUDE_DIR})
118
119 SET(PB_BASE_SRCS MidiFile.cpp MidiTrack.cpp Song.cpp Conductor.cpp Util.cpp
120 Chord.cpp Tempo.cpp MidiDevice.cpp MidiDeviceRt.cpp ${PB_BASE_SRCS})
121 SET(PB_BASE_HDR MidiFile.h MidiTrack.h Song.h Conductor.h Rating.h Util.h
122 Chord.h Tempo.h MidiDevice.h)
123
124 if(USE_JACK)
125 # Check for Jack
126 find_library(JACK_LIB jack)
127 pkg_check_modules(JACK jack)
128 if(NOT JACK_FOUND)
129 MESSAGE(FATAL_ERROR "JACK was not found")
130 endif(NOT JACK_FOUND)
131
132 SET(JACK_INCLUDE_DIR ${JACK_INCLUDE_DIRS})
133 SET(JACK_LIBRARY ${JACK_LIBRARIES})
134 if(JACK_FOUND)
135 ADD_DEFINITIONS(-D__UNIX_JACK__)
136 endif(JACK_FOUND)
137 endif(USE_JACK)
138
139 if(USE_BUNDLED_RTMIDI)
140 message(STATUS "Building using bundled rtmidi")
141 add_compile_options("-DUSE_BUNDLED_RTMIDI")
142 include_directories("3rdparty")
143 set(PB_BASE_SRCS ${PB_BASE_SRCS} 3rdparty/rtmidi/RtMidi.cpp)
144 set(PB_BASE_HDR ${PB_BASE_HDR} 3rdparty/rtmidi/RtMidi.h)
145 else()
146 pkg_check_modules(RTMIDI rtmidi)
147 if(NOT RTMIDI_FOUND)
148 MESSAGE(FATAL_ERROR "rtmidi not found (Try building with option USE_BUNDLED_RTMIDI=ON)")
149 endif(NOT RTMIDI_FOUND)
150 include_directories(${RTMIDI_INCLUDE_DIRS})
151 endif()
152
153 # with SET() command you can change variables or define new ones
154 # here we define PIANOBOOSTER_SRCS variable that contains a list of all .cpp files
155 # note that we don't need \ at the end of line
156 SET( PIANOBOOSTER_SRCS
157 QtMain.cpp
158 QtWindow.cpp
159 GuiTopBar.cpp
160 GuiSidePanel.cpp
161 GuiMidiSetupDialog.cpp
162 GuiKeyboardSetupDialog.cpp
163 GuiPreferencesDialog.cpp
164 GuiSongDetailsDialog.cpp
165 GuiLoopingPopup.cpp
166 GlView.cpp
167 ${PB_BASE_SRCS}
168 StavePosition.cpp
169 Score.cpp
170 Cfg.cpp
171 Piano.cpp
172 Draw.cpp
173 Scroll.cpp
174 Notation.cpp
175 TrackList.cpp
176 Rating.cpp
177 Bar.cpp
178 Settings.cpp
179 Merge.cpp
180 pianobooster.rc
181 images/pianobooster.ico
182 )
183
184 # another list, this time it includes all header files that should be treated with moc
185 SET( PIANOBOOSTER_MOC_HDRS
186 QtWindow.h
187 GlView.h
188 GuiTopBar.h
189 GuiSidePanel.h
190 GuiMidiSetupDialog.h
191 GuiKeyboardSetupDialog.h
192 GuiPreferencesDialog.h
193 GuiSongDetailsDialog.h
194 GuiLoopingPopup.h
195 )
196
197 # some .ui files
198 SET( PIANOBOOSTER_UIS
199 ./GuiTopBar.ui
200 ./GuiSidePanel.ui
201 ./GuiMidiSetupDialog.ui
202 ./GuiKeyboardSetupDialog.ui
203 ./GuiPreferencesDialog.ui
204 ./GuiSongDetailsDialog.ui
205 ./GuiLoopingPopup.ui
206 )
207
208 # and finally an resource file
209 SET( PIANOBOOSTER_RCS
210 ./application.qrc
211 )
212
213 set(CMAKE_AUTOMOC ON)
214 set(CMAKE_AUTOUIC ON)
215 set(CMAKE_AUTORCC ON)
216 set(CMAKE_INCLUDE_CURRENT_DIR ON)
217
218 # here we instruct CMake to build "pianobooster" executable from all of the source files
219 if(APPLE)
220 # the property added the pianobooster icon to Info.plist
221 set(MACOSX_BUNDLE_ICON_FILE pianobooster.icns)
222
223 # Tells CMake where to find and install the pianobooster icon
224 set(pianobooster_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../icons/MacOS/pianobooster.icns)
225 set_source_files_properties(${pianobooster_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
226
227 set(pianobooster_TRANSLATIONS ${CMAKE_CURRENT_BINARY_DIR}/translations/langs.json)
228 set_source_files_properties(${pianobooster_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/translations")
229
230 set(pianobooster_MUSIC ${CMAKE_CURRENT_SOURCE_DIR}/../music/BoosterMusicBooks.zip)
231 set_source_files_properties(${pianobooster_MUSIC} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/music")
232 set(pianobooster_FONT ${CMAKE_CURRENT_SOURCE_DIR}/fonts/DejaVuSans.ttf)
233 set_source_files_properties(${pianobooster_FONT} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/fonts")
234
235 ADD_EXECUTABLE( pianobooster MACOSX_BUNDLE
236 ${pianobooster_ICON} ${pianobooster_TRANSLATIONS}
237 ${pianobooster_MUSIC} ${pianobooster_FONT}
238 ${PIANOBOOSTER_SRCS}
239 ${PIANOBOOSTER_MOC_SRCS} ${PIANOBOOSTER_RC_SRCS}
240 ${PIANOBOOSTER_UI_HDRS} ${PIANOBOOSTER_RCS} )
241
242 add_custom_target(install-translations cp -R -v ${CMAKE_CURRENT_BINARY_DIR}/translations/*.qm ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Resources/translations)
243
244 endif(APPLE)
245
246 if(UNIX AND NOT APPLE)
247 ADD_EXECUTABLE( pianobooster ${PIANOBOOSTER_SRCS}
248 ${PIANOBOOSTER_MOC_SRCS} ${PIANOBOOSTER_RC_SRCS}
249 ${PIANOBOOSTER_UI_HDRS} ${PIANOBOOSTER_RCS} )
250 endif(UNIX AND NOT APPLE)
251
252 if(WIN32)
253 ADD_EXECUTABLE( pianobooster ${PIANOBOOSTER_SRCS}
254 ${PIANOBOOSTER_MOC_SRCS} ${PIANOBOOSTER_RC_SRCS}
255 ${PIANOBOOSTER_UI_HDRS} ${PIANOBOOSTER_RCS} )
256 SET_TARGET_PROPERTIES(pianobooster PROPERTIES LINK_FLAGS "-mwindows")
257 endif(WIN32)
258
259 qt5_use_modules(pianobooster Core Gui Widgets LinguistTools OpenGL Xml)
260
261 if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
262 message("Please consider to switch to CMake 3.13.0")
263 else()
264 target_link_directories(pianobooster PUBLIC ${FTGL_LIBRARY_DIRS} ${JACK_LIBRARY_DIRS} ${FLUIDSYNTH_LIBRARY_DIRS})
265 endif()
266 target_link_libraries (pianobooster Qt5::Widgets Qt5::Xml Qt5::OpenGL ${OPENGL_LIBRARIES} ${FTGL_LIBRARY} ${RTMIDI_LIBRARIES} ${JACK_LIBRARY} ${FLUIDSYNTH_LIBRARY} ${RTMIDI_LIBRARY})
267
268 if(NOT APPLE)
269 INSTALL( FILES ../pianobooster.desktop DESTINATION share/applications )
270 INSTALL(TARGETS pianobooster RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
271 endif(NOT APPLE)
272
273 if(NOT NO_DOCS)
274 INSTALL( FILES ../README.md DESTINATION share/doc/pianobooster/ )
275 INSTALL( FILES ../doc/faq.md DESTINATION share/doc/pianobooster/ )
276 endif()
277
278 if(NOT NO_LICENSE)
279 INSTALL( FILES ../license.txt DESTINATION share/licenses/pianobooster/ )
280 endif()
281
282 if(NOT NO_CHANGELOG)
283 INSTALL( FILES ../Changelog.txt DESTINATION share/doc/pianobooster/ )
284 endif()
285
286 if(WITH_MAN)
287 INSTALL( FILES ../pianobooster.6 DESTINATION share/man/man6/ )
288 endif()
289
290 INSTALL ( FILES ../icons/hicolor/32x32/pianobooster.png DESTINATION share/icons/hicolor/32x32/apps )
291 INSTALL ( FILES ../icons/hicolor/48x48/pianobooster.png DESTINATION share/icons/hicolor/48x48/apps )
292 INSTALL ( FILES ../icons/hicolor/64x64/pianobooster.png DESTINATION share/icons/hicolor/64x64/apps )
293
294 if(UNIX AND NOT APPLE)
295 INSTALL ( FILES ../music/BoosterMusicBooks.zip DESTINATION ${DATA_DIR}/music )
296 endif(UNIX AND NOT APPLE)
297
298 if(WIN32)
299 INSTALL( FILES ../music/BoosterMusicBooks.zip DESTINATION . )
300 endif(WIN32)
301
302 if(NOT USE_SYSTEM_FONT)
303 configure_file(fonts/DejaVuSans.ttf ${CMAKE_CURRENT_BINARY_DIR}/fonts/DejaVuSans.ttf COPYONLY)
304 INSTALL ( FILES fonts/DejaVuSans.ttf DESTINATION ${DATA_DIR}/fonts/)
305 endif(NOT USE_SYSTEM_FONT)
306
307 if(NOT NO_LANGS)
308 ADD_SUBDIRECTORY(../translations ../build/translations)
309 endif(NOT NO_LANGS)
310
311 if(DEBUG_LOG_TRACE)
312 ADD_DEFINITIONS(-DPB_LOG_TRACE)
313 endif()
314
315 if(DEBUG_LOG_TIMING)
316 ADD_DEFINITIONS(-DPB_LOG_TIMING)
317 endif()
318
319 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../music/BoosterMusicBooks.zip ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY)
320