1 | if(SAILFISHOS) |
---|
2 | cmake_minimum_required(VERSION 2.8.11) |
---|
3 | else(SAILFISHOS) |
---|
4 | cmake_minimum_required(VERSION 2.8.12) |
---|
5 | endif() |
---|
6 | |
---|
7 | project(gcompris-qt C CXX) |
---|
8 | |
---|
9 | # get all the redist dll needed for windows when compiling with vc |
---|
10 | set(CMAKE_INSTALL_UCRT_LIBRARIES 1) |
---|
11 | include(InstallRequiredSystemLibraries) |
---|
12 | |
---|
13 | # Set c++11 support |
---|
14 | include(CheckCXXCompilerFlag) |
---|
15 | CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) |
---|
16 | CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) |
---|
17 | if(COMPILER_SUPPORTS_CXX11) |
---|
18 | set(my_cxx_flags "-std=c++11") |
---|
19 | elseif(COMPILER_SUPPORTS_CXX0X) |
---|
20 | set(my_cxx_flags "-std=c++0x") |
---|
21 | else() |
---|
22 | message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") |
---|
23 | endif() |
---|
24 | |
---|
25 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}") |
---|
26 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}") |
---|
27 | |
---|
28 | # enable qml debugging for DEBUG builds: |
---|
29 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG") |
---|
30 | |
---|
31 | set(GCOMPRIS_MAJOR_VERSION 0) |
---|
32 | set(GCOMPRIS_MINOR_VERSION 70) |
---|
33 | set(GCOMPRIS_PATCH_VERSION 0) |
---|
34 | |
---|
35 | # Set the BUILD_DATE |
---|
36 | string(TIMESTAMP BUILD_DATE %Y%M) |
---|
37 | |
---|
38 | # cmake modules setup |
---|
39 | find_package(ECM 1.4.0 QUIET NO_MODULE) |
---|
40 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake/) |
---|
41 | set(CMAKE_PREFIX_PATH "${Qt5_DIR}/lib/cmake/Qt5") |
---|
42 | |
---|
43 | # KDE po to qm tools |
---|
44 | if(ECM_FOUND) |
---|
45 | include(ECMPoQmTools) |
---|
46 | if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") |
---|
47 | ecm_install_po_files_as_qm(po) |
---|
48 | endif() |
---|
49 | endif(ECM_FOUND) |
---|
50 | |
---|
51 | if(CMAKE_SYSTEM_NAME STREQUAL Android) |
---|
52 | find_package(ECM) |
---|
53 | set(ANDROID 1) |
---|
54 | # TODO: possibly should be setup by toolchain one day |
---|
55 | set(QT_QMAKE_EXECUTABLE "${_qt5Core_install_prefix}/bin/qmake") |
---|
56 | # workaround until this fix is in released ECM |
---|
57 | if(ECM_VERSION VERSION_LESS "5.15.0") |
---|
58 | add_definitions(-DANDROID) |
---|
59 | endif() |
---|
60 | endif() |
---|
61 | |
---|
62 | # Set executable filename |
---|
63 | if(ANDROID) |
---|
64 | set(GCOMPRIS_EXECUTABLE_NAME GCompris) |
---|
65 | if("${ANDROID_ARCHITECTURE}" STREQUAL "x86") |
---|
66 | # We always want x86 to be a release above to arm one because the play |
---|
67 | # store want x86 to be pushed after arm. |
---|
68 | MATH(EXPR GCOMPRIS_MINOR_VERSION "${GCOMPRIS_MINOR_VERSION}+1") |
---|
69 | endif("${ANDROID_ARCHITECTURE}" STREQUAL "x86") |
---|
70 | elseif(SAILFISHOS) |
---|
71 | set(GCOMPRIS_EXECUTABLE_NAME harbour-gcompris-qt) |
---|
72 | elseif(WIN32) |
---|
73 | set(GCOMPRIS_EXECUTABLE_NAME GCompris) |
---|
74 | else() |
---|
75 | set(GCOMPRIS_EXECUTABLE_NAME gcompris-qt) |
---|
76 | endif() |
---|
77 | |
---|
78 | set(GCOMPRIS_VERSION ${GCOMPRIS_MAJOR_VERSION}.${GCOMPRIS_MINOR_VERSION}) |
---|
79 | |
---|
80 | # An integer value that represents the version of the application |
---|
81 | # Increase it at each release |
---|
82 | math(EXPR GCOMPRIS_VERSION_CODE "${GCOMPRIS_MAJOR_VERSION}*10000 + ${GCOMPRIS_MINOR_VERSION}*100 + ${GCOMPRIS_PATCH_VERSION}") |
---|
83 | |
---|
84 | # KDE po to qm tools |
---|
85 | if(ECM_FOUND) |
---|
86 | include(ECMPoQmTools) |
---|
87 | if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") |
---|
88 | ecm_install_po_files_as_qm(po) |
---|
89 | endif() |
---|
90 | endif(ECM_FOUND) |
---|
91 | |
---|
92 | # prevent build in source directory |
---|
93 | if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") |
---|
94 | message(SEND_ERROR "Building in the source directory is not supported.") |
---|
95 | message(FATAL_ERROR "Please remove the created \"CMakeCache.txt\" file, the \"CMakeFiles\" |
---|
96 | directory and create a build directory and call \"${CMAKE_COMMAND} <path to the sources>\".") |
---|
97 | endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") |
---|
98 | |
---|
99 | # Sailfish does not provide a recent Qt version |
---|
100 | if(SAILFISHOS) |
---|
101 | set(QT_REQUIRED_VERSION 5.2.2) |
---|
102 | else() |
---|
103 | set(QT_REQUIRED_VERSION 5.3.0) |
---|
104 | endif() |
---|
105 | |
---|
106 | find_package(Qt5 ${QT_REQUIRED_VERSION} REQUIRED |
---|
107 | Qml Quick Gui Multimedia Core Svg Xml XmlPatterns LinguistTools Sensors) |
---|
108 | |
---|
109 | find_package (KF5 QUIET COMPONENTS |
---|
110 | DocTools |
---|
111 | ) |
---|
112 | if(KF5_FOUND) |
---|
113 | include(KDEInstallDirs) |
---|
114 | |
---|
115 | if (ECM_VERSION VERSION_GREATER "1.6.0") |
---|
116 | add_subdirectory(images) |
---|
117 | install(FILES org.kde.gcompris.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) |
---|
118 | install(FILES org.kde.gcompris.desktop DESTINATION ${KDE_INSTALL_APPDIR}) |
---|
119 | endif() |
---|
120 | endif() |
---|
121 | |
---|
122 | # include desktop file in deb |
---|
123 | install(FILES org.kde.gcompris.desktop DESTINATION share/applications) |
---|
124 | |
---|
125 | FIND_PROGRAM(LRELEASE_EXECUTABLE lrelease-qt5 lrelease |
---|
126 | PATHS |
---|
127 | ${Qt5_DIR}/../../../bin/ |
---|
128 | /usr/local/bin |
---|
129 | /usr/bin/ |
---|
130 | NO_DEFAULT_PATH |
---|
131 | ) |
---|
132 | |
---|
133 | #get_cmake_property(_variableNames VARIABLES) |
---|
134 | #foreach (_variableName ${_variableNames}) |
---|
135 | # message("${_variableName}=${${_variableName}}") |
---|
136 | #endforeach() |
---|
137 | |
---|
138 | set(ACTIVATION_MODE "no" CACHE STRING "Policy for activation [no|inapp|internal]") |
---|
139 | option(WITH_DEMO_ONLY "Include only demo activities" OFF) |
---|
140 | |
---|
141 | option(WITH_DOWNLOAD "Internal download" ON) |
---|
142 | # @FIXME These permissions should be removed if download is disable |
---|
143 | # but it makes the application crash on exit (tested on Android 6) |
---|
144 | set(ANDROID_INTERNET_PERMISSION "<uses-permission android:name=\"android.permission.INTERNET\" />") |
---|
145 | set(ANDROID_ACCESS_NETWORK_STATE_PERMISSION "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />") |
---|
146 | |
---|
147 | # Set output directory |
---|
148 | if(CMAKE_HOST_APPLE) |
---|
149 | set(_bundle_bin gcompris-qt.app/Contents/MacOS) |
---|
150 | set(_data_dest_dir bin/${_bundle_bin}/../Resources) |
---|
151 | elseif(ANDROID) |
---|
152 | set(_data_dest_dir android/assets) |
---|
153 | else() |
---|
154 | set(_data_dest_dir share/${GCOMPRIS_EXECUTABLE_NAME}) |
---|
155 | endif() |
---|
156 | if(ANDROID) |
---|
157 | # Android .so output |
---|
158 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/android/libs/${ANDROID_ABI}/) |
---|
159 | set(GCOMPRIS_TRANSLATIONS_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir} CACHE INTERNAL "" FORCE) |
---|
160 | set(GCOMPRIS_RCC_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir} CACHE INTERNAL "" FORCE) |
---|
161 | if(ACTIVATION_MODE STREQUAL "inapp") |
---|
162 | set(ANDROID_BILLING_PERMISSION "<uses-permission android:name=\"com.android.vending.BILLING\"/>") |
---|
163 | set(ANDROID_PACKAGE "net.gcompris") |
---|
164 | else(ACTIVATION_MODE) |
---|
165 | set(ANDROID_PACKAGE "net.gcompris.full") |
---|
166 | endif() |
---|
167 | add_subdirectory(android) |
---|
168 | elseif(CMAKE_HOST_APPLE) |
---|
169 | # MacOSX build |
---|
170 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
171 | set(GCOMPRIS_TRANSLATIONS_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir}/translations CACHE INTERNAL "" FORCE) |
---|
172 | set(GCOMPRIS_RCC_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir}/rcc CACHE INTERNAL "" FORCE) |
---|
173 | else() |
---|
174 | # Desktop build |
---|
175 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
---|
176 | set(GCOMPRIS_TRANSLATIONS_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir}/translations CACHE INTERNAL "" FORCE) |
---|
177 | set(GCOMPRIS_RCC_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir}/rcc CACHE INTERNAL "" FORCE) |
---|
178 | endif(ANDROID) |
---|
179 | |
---|
180 | # Always create these folders |
---|
181 | add_custom_command( |
---|
182 | OUTPUT shareFolders |
---|
183 | COMMAND cmake -E make_directory ${GCOMPRIS_TRANSLATIONS_DIR} |
---|
184 | COMMAND cmake -E make_directory ${GCOMPRIS_RCC_DIR} |
---|
185 | ) |
---|
186 | add_custom_target( |
---|
187 | createShareFolders ALL |
---|
188 | DEPENDS shareFolders |
---|
189 | ) |
---|
190 | |
---|
191 | include(cmake/rcc.cmake) |
---|
192 | |
---|
193 | # Translations handling |
---|
194 | |
---|
195 | # Simple command calling the python script |
---|
196 | add_custom_command( |
---|
197 | OUTPUT retrievePoFilesFromSvn |
---|
198 | COMMAND python2 tools/l10n-fetch-po-files.py |
---|
199 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
---|
200 | ) |
---|
201 | # Install translations |
---|
202 | add_custom_target(getSvnTranslations |
---|
203 | DEPENDS retrievePoFilesFromSvn |
---|
204 | COMMENT "Re-run cmake after this to be able to run BuildTranslations with the latest files" |
---|
205 | ) |
---|
206 | |
---|
207 | # Get all po files in po/. You can get them doing: python2 tools/l10n-fetch-po-files.py |
---|
208 | file(GLOB TRANSLATIONS_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "po/*.po") |
---|
209 | # Set the output dir for the translation files to /bin |
---|
210 | foreach(PoSource ${TRANSLATIONS_FILES}) |
---|
211 | # Changes the .po extension to .ts |
---|
212 | string(REPLACE ".po" ".ts" TsSource ${PoSource}) |
---|
213 | # Removes the po/ folder |
---|
214 | string(REPLACE "po/" "" TsSource ${TsSource}) |
---|
215 | # qm filename |
---|
216 | string(REPLACE ".ts" ".qm" QmOutput ${TsSource}) |
---|
217 | |
---|
218 | set(OutTsFile ${CMAKE_BINARY_DIR}/tmp/${TsSource}) |
---|
219 | add_custom_command( |
---|
220 | OUTPUT ${QmOutput} |
---|
221 | COMMAND cmake -E make_directory ${GCOMPRIS_TRANSLATIONS_DIR} |
---|
222 | COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/tmp |
---|
223 | # Remove the obsolete translations and set po in the ts output file |
---|
224 | COMMAND msgattrib --no-obsolete ${CMAKE_CURRENT_SOURCE_DIR}/${PoSource} -o ${OutTsFile} |
---|
225 | # Convert the po into ts |
---|
226 | COMMAND Qt5::lconvert -if po -of ts -i ${OutTsFile} -o ${OutTsFile} |
---|
227 | # Convert the ts in qm removing non finished translations |
---|
228 | COMMAND Qt5::lrelease -compress -nounfinished ${OutTsFile} -qm ${GCOMPRIS_TRANSLATIONS_DIR}/${QmOutput} |
---|
229 | ) |
---|
230 | list(APPEND QM_FILES ${QmOutput}) |
---|
231 | endforeach() |
---|
232 | |
---|
233 | # Install translations |
---|
234 | if (WIN32) |
---|
235 | add_custom_target(BuildTranslations |
---|
236 | DEPENDS ${QM_FILES} |
---|
237 | COMMENT "If you don't have the .po, you need to run make getSvnTranslations first then re-run cmake" |
---|
238 | ) |
---|
239 | else() |
---|
240 | add_custom_target(BuildTranslations ALL |
---|
241 | DEPENDS ${QM_FILES} |
---|
242 | COMMENT "If you don't have the .po, you need to run make getSvnTranslations first then re-run cmake" |
---|
243 | ) |
---|
244 | endif() |
---|
245 | |
---|
246 | add_custom_command( |
---|
247 | OUTPUT doBundleTranslations |
---|
248 | COMMAND 7z a -w${CMAKE_BINARY_DIR}/share/${GCOMPRIS_EXECUTABLE_NAME} |
---|
249 | ${CMAKE_BINARY_DIR}/translations-${GCOMPRIS_VERSION}.7z |
---|
250 | ${CMAKE_BINARY_DIR}/share/${GCOMPRIS_EXECUTABLE_NAME}/translations |
---|
251 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
---|
252 | ) |
---|
253 | # Bundle translations |
---|
254 | add_custom_target(BundleTranslations |
---|
255 | DEPENDS doBundleTranslations |
---|
256 | COMMENT "If you want to provide a zip of the translations on a server (run make BuildTranslations first)" |
---|
257 | ) |
---|
258 | |
---|
259 | add_custom_command( |
---|
260 | OUTPUT doDlAndInstallBundledTranslations |
---|
261 | COMMAND curl -fsS -o translations-${GCOMPRIS_VERSION}.7z |
---|
262 | http://gcompris.net/download/translations-${GCOMPRIS_VERSION}.7z |
---|
263 | COMMAND 7z x -y -o${CMAKE_BINARY_DIR}/share/${GCOMPRIS_EXECUTABLE_NAME} |
---|
264 | translations-${GCOMPRIS_VERSION}.7z |
---|
265 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
---|
266 | ) |
---|
267 | # Download and install bundled translations |
---|
268 | add_custom_target(DlAndInstallBundledTranslations |
---|
269 | DEPENDS doDlAndInstallBundledTranslations |
---|
270 | COMMENT "Download the bundled translation and install them in the build dir" |
---|
271 | ) |
---|
272 | |
---|
273 | if(CMAKE_HOST_APPLE) |
---|
274 | install(DIRECTORY ${GCOMPRIS_TRANSLATIONS_DIR} DESTINATION ${_bundle_bin}) |
---|
275 | else() |
---|
276 | install(DIRECTORY ${GCOMPRIS_TRANSLATIONS_DIR} DESTINATION ${_data_dest_dir}) |
---|
277 | endif() |
---|
278 | |
---|
279 | # Build standalone package option -> if ON, we will copy the required Qt files in the build package. |
---|
280 | # If OFF, "make install" will not copy Qt files so only GCompris files will be packaged. |
---|
281 | # By default, it is true on Windows (as we deliver NSIS package), macOS (bundled), android (apk) and false on linux (to do make install) |
---|
282 | # If you want to create a STGZ package for linux (auto-extractible), override this variable by typing : cmake -DBUILD_STANDALONE=ON |
---|
283 | if(UNIX AND NOT ANDROID AND NOT APPLE) |
---|
284 | option(BUILD_STANDALONE "Build a standalone package when typing 'make package'" OFF) |
---|
285 | else() |
---|
286 | option(BUILD_STANDALONE "Build a standalone package when typing 'make package'" ON) |
---|
287 | endif() |
---|
288 | |
---|
289 | option(WITH_KIOSK_MODE "Set the kiosk mode by default" OFF) |
---|
290 | |
---|
291 | if(WIN32) |
---|
292 | set(COMPRESSED_AUDIO "mp3" CACHE STRING "Compressed Audio format [ogg|aac|mp3]") |
---|
293 | elseif(APPLE) |
---|
294 | set(COMPRESSED_AUDIO "aac" CACHE STRING "Compressed Audio format [ogg|aac|mp3]") |
---|
295 | else() |
---|
296 | set(COMPRESSED_AUDIO "ogg" CACHE STRING "Compressed Audio format [ogg|aac|mp3]") |
---|
297 | endif() |
---|
298 | |
---|
299 | file(GLOB_RECURSE OGG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/ "*.ogg") |
---|
300 | |
---|
301 | foreach(OGG_FILE ${OGG_FILES}) |
---|
302 | # This should only replace the extension |
---|
303 | string(REGEX REPLACE "ogg$" "aac" AAC_FILE ${OGG_FILE}) |
---|
304 | add_custom_command( |
---|
305 | OUTPUT ${AAC_FILE} |
---|
306 | # Put the good line depending on your installation |
---|
307 | COMMAND avconv -v warning -i ${OGG_FILE} -acodec libvo_aacenc ${AAC_FILE} |
---|
308 | #COMMAND ffmpeg -v warning -i ${OGG_FILE} -acodec aac -strict -2 ${AAC_FILE} |
---|
309 | ) |
---|
310 | list(APPEND AAC_FILES ${AAC_FILE}) |
---|
311 | |
---|
312 | # This should only replace the extension |
---|
313 | string(REGEX REPLACE "ogg$" "mp3" MP3_FILE ${OGG_FILE}) |
---|
314 | add_custom_command( |
---|
315 | OUTPUT ${MP3_FILE} |
---|
316 | # Put the good line depending on your installation |
---|
317 | #COMMAND avconv -v warning -i ${OGG_FILE} -acodec mp3 ${MP3_FILE} |
---|
318 | COMMAND ffmpeg -v warning -i ${OGG_FILE} -acodec mp3 -strict -2 ${MP3_FILE} |
---|
319 | ) |
---|
320 | list(APPEND MP3_FILES ${MP3_FILE}) |
---|
321 | endforeach() |
---|
322 | |
---|
323 | add_custom_target( |
---|
324 | createAacFromOgg |
---|
325 | DEPENDS ${AAC_FILES} |
---|
326 | ) |
---|
327 | |
---|
328 | add_custom_target( |
---|
329 | createMp3FromOgg |
---|
330 | DEPENDS ${MP3_FILES} |
---|
331 | ) |
---|
332 | |
---|
333 | # predownload assets (voices and images) and install them in the rcc folder |
---|
334 | set(DOWNLOAD_ASSETS "" CACHE STRING "Download and packages images and voices. use a list like: words,en,fr,pt_BR to retrieve multiple files") |
---|
335 | add_custom_command( |
---|
336 | OUTPUT predownloadAssets |
---|
337 | COMMAND python2 tools/download-assets.py ${DOWNLOAD_ASSETS} ${COMPRESSED_AUDIO} ${GCOMPRIS_RCC_DIR} |
---|
338 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
---|
339 | ) |
---|
340 | |
---|
341 | add_custom_command( |
---|
342 | OUTPUT assetsFolders |
---|
343 | COMMAND cmake -E make_directory "${GCOMPRIS_RCC_DIR}/data2" |
---|
344 | COMMAND cmake -E make_directory "${GCOMPRIS_RCC_DIR}/data2/voices-${COMPRESSED_AUDIO}" |
---|
345 | COMMAND cmake -E make_directory "${GCOMPRIS_RCC_DIR}/data2/words" |
---|
346 | ) |
---|
347 | # Install assets |
---|
348 | add_custom_target(getAssets |
---|
349 | DEPENDS assetsFolders predownloadAssets |
---|
350 | ) |
---|
351 | |
---|
352 | add_custom_command( |
---|
353 | OUTPUT doBundleConvertedOggs |
---|
354 | COMMAND 7z a converted_ogg_to_${COMPRESSED_AUDIO}-${GCOMPRIS_VERSION}.7z '-ir!src/*${COMPRESSED_AUDIO}' |
---|
355 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
---|
356 | ) |
---|
357 | # Bundle oggs ready to be uploaded on a server. This ease build on system without the appropriate audio |
---|
358 | # convertion tools. |
---|
359 | add_custom_target(BundleConvertedOggs |
---|
360 | DEPENDS doBundleConvertedOggs |
---|
361 | COMMENT "Bundle the converted oggs to upload them on a server. First set COMPRESSED_AUDIO appropriately." |
---|
362 | ) |
---|
363 | |
---|
364 | add_custom_command( |
---|
365 | OUTPUT doDlAndInstallBundledConvertedOggs |
---|
366 | COMMAND curl -fsS -o converted_ogg_to_${COMPRESSED_AUDIO}-${GCOMPRIS_VERSION}.7z |
---|
367 | http://gcompris.net/download/converted_ogg_to_${COMPRESSED_AUDIO}-${GCOMPRIS_VERSION}.7z |
---|
368 | COMMAND 7z x -y converted_ogg_to_${COMPRESSED_AUDIO}-${GCOMPRIS_VERSION}.7z |
---|
369 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
---|
370 | ) |
---|
371 | # Download and install bundled converted oggs |
---|
372 | add_custom_target(DlAndInstallBundledConvertedOggs |
---|
373 | DEPENDS doDlAndInstallBundledConvertedOggs |
---|
374 | COMMENT "Download the bundled converted oggs and install them in the source dir" |
---|
375 | ) |
---|
376 | |
---|
377 | |
---|
378 | set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${GCOMPRIS_VERSION}) |
---|
379 | add_custom_target(dist |
---|
380 | COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD |
---|
381 | | xz > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.xz |
---|
382 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |
---|
383 | |
---|
384 | if(KF5_FOUND) |
---|
385 | add_subdirectory(docs/docbook) |
---|
386 | endif(KF5_FOUND) |
---|
387 | |
---|
388 | if(SAILFISHOS) |
---|
389 | # Need to be done at the end, after src |
---|
390 | add_subdirectory(platforms/sailfishOS) |
---|
391 | endif() |
---|
392 | |
---|
393 | # |
---|
394 | # qml-box2d |
---|
395 | # |
---|
396 | |
---|
397 | set(QML_BOX2D_MODULE "auto" CACHE STRING "Policy for qml-box2d module [auto|submodule|system|disabled]") |
---|
398 | |
---|
399 | if (${QML_BOX2D_MODULE} STREQUAL "disabled") |
---|
400 | # disable all activities depending on qml-box2d |
---|
401 | set(_disabled_activities "balancebox,land_safe") |
---|
402 | message(STATUS "Disabling qml-box2d module and depending activities: ${_disabled_activities}") |
---|
403 | else() |
---|
404 | include(qt_helper) |
---|
405 | |
---|
406 | getQtQmlPath(_qt_qml_system_path) |
---|
407 | set (_box2d_system_dir "${_qt_qml_system_path}/Box2D.2.0") |
---|
408 | |
---|
409 | if (${QML_BOX2D_MODULE} STREQUAL "submodule") |
---|
410 | message(STATUS "Building qml-box2d module from submodule") |
---|
411 | set(_need_box2d_submodule "TRUE") |
---|
412 | else() |
---|
413 | # try to find module in system scope |
---|
414 | find_library(QML_BOX2D_LIBRARY NAMES Box2D libBox2D PATHS ${_box2d_system_dir} NO_DEFAULT_PATH) |
---|
415 | if (QML_BOX2D_LIBRARY) |
---|
416 | message(STATUS "Using system qml-box2d plugin at ${QML_BOX2D_LIBRARY}") |
---|
417 | # for packaging builds, copy the module manually to the correct location |
---|
418 | if(SAILFISHOS) |
---|
419 | file(COPY ${_box2d_system_dir}/qmldir ${QML_BOX2D_LIBRARY} DESTINATION share/harbour-gcompris-qt/lib/qml/Box2D.2.0) |
---|
420 | elseif(ANDROID) |
---|
421 | file(COPY ${_box2d_system_dir}/qmldir ${QML_BOX2D_LIBRARY} DESTINATION lib/qml/Box2D.2.0) |
---|
422 | endif() |
---|
423 | # FIXME: add others as needed |
---|
424 | else() |
---|
425 | if (${QML_BOX2D_MODULE} STREQUAL "auto") |
---|
426 | message(STATUS "Did not find the qml-box2d module in system scope, falling back to submodule build ...") |
---|
427 | set (_need_box2d_submodule "TRUE") |
---|
428 | else() |
---|
429 | message(FATAL_ERROR "Did not find the qml-box2d module in system scope and submodule build was not requested. Can't continue!") |
---|
430 | endif() |
---|
431 | endif() |
---|
432 | endif() |
---|
433 | |
---|
434 | if (_need_box2d_submodule) |
---|
435 | # build qml-box2d ourselves from submodule |
---|
436 | include(ExternalProject) |
---|
437 | get_property(_qmake_program TARGET ${Qt5Core_QMAKE_EXECUTABLE} PROPERTY IMPORT_LOCATION) |
---|
438 | set (_box2d_source_dir ${CMAKE_CURRENT_SOURCE_DIR}/external/qml-box2d) |
---|
439 | if(WIN32) |
---|
440 | set (_box2d_library_dir "release/") |
---|
441 | set (_box2d_library_file "Box2D.dll") |
---|
442 | else() |
---|
443 | set (_box2d_library_dir "") |
---|
444 | set (_box2d_library_file "libBox2D.so") |
---|
445 | endif() |
---|
446 | set (_box2d_install_dir ${CMAKE_CURRENT_BINARY_DIR}/lib/qml/Box2D.2.0) |
---|
447 | # make sure submodule is up2date |
---|
448 | find_package(Git) |
---|
449 | if(GIT_FOUND) |
---|
450 | execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init) |
---|
451 | endif() |
---|
452 | |
---|
453 | # for visual studio, we need to create a vcxproj |
---|
454 | if(WIN32 AND NOT MINGW) |
---|
455 | set(_qmake_options -spec win32-msvc2015 -tp vc) |
---|
456 | else() |
---|
457 | set(_qmake_options "") |
---|
458 | endif() |
---|
459 | ExternalProject_Add(qml_box2d |
---|
460 | DOWNLOAD_COMMAND "" |
---|
461 | SOURCE_DIR ${_box2d_source_dir} |
---|
462 | CONFIGURE_COMMAND ${_qmake_program} ${_qmake_options} ${_box2d_source_dir}/box2d.pro |
---|
463 | BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} |
---|
464 | INSTALL_DIR ${_box2d_install_dir} |
---|
465 | INSTALL_COMMAND cp ${_box2d_library_dir}${_box2d_library_file} ${_box2d_source_dir}/qmldir ${_box2d_install_dir} |
---|
466 | ) |
---|
467 | |
---|
468 | add_library(qml-box2d SHARED IMPORTED) |
---|
469 | set_target_properties(qml-box2d PROPERTIES IMPORTED_LOCATION ${_box2d_install_dir}/${_box2d_library_file}) |
---|
470 | |
---|
471 | if(SAILFISHOS) |
---|
472 | install(DIRECTORY ${_box2d_install_dir} DESTINATION share/harbour-gcompris-qt/lib/qml) |
---|
473 | else() |
---|
474 | install(DIRECTORY ${_box2d_install_dir} DESTINATION lib/qml) |
---|
475 | endif() |
---|
476 | endif() |
---|
477 | endif() |
---|
478 | |
---|
479 | add_subdirectory(src) |
---|
480 | |
---|
481 | add_custom_target(binaries) |
---|
482 | add_dependencies(binaries ${GCOMPRIS_EXECUTABLE_NAME} rcc_core rcc_menu rcc_activities all_activities) |
---|