forked from gcompris/GCompris-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
161 lines (135 loc) · 5.63 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
cmake_minimum_required(VERSION 2.8)
project(gcompris C CXX)
# Set c++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(my_cxx_flags "-std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(my_cxx_flags "-std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}")
set(GCOMPRIS_MAJOR_VERSION 0)
set(GCOMPRIS_MINOR_VERSION 23)
set(GCOMPRIS_PATCH_VERSION 0)
set(GCOMPRIS_VERSION ${GCOMPRIS_MAJOR_VERSION}.${GCOMPRIS_MINOR_VERSION})
# An integer value that represents the version of the application
# Increase it at each release
set(GCOMPRIS_VERSION_CODE ${GCOMPRIS_MINOR_VERSION})
# Set executable filename
if(ANDROID)
set(GCOMPRIS_EXECUTABLE_NAME GCompris)
else()
set(GCOMPRIS_EXECUTABLE_NAME gcompris-qt)
endif()
# cmake modules setup
find_package(ECM 1.4.0 QUIET NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake/)
set(CMAKE_PREFIX_PATH "${Qt5_DIR}/lib/cmake/Qt5")
# KDE po to qm tools
if(ECM_FOUND)
include(ECMPoQmTools)
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
ecm_install_po_files_as_qm(po)
endif()
endif(ECM_FOUND)
# prevent build in source directory
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(SEND_ERROR "Building in the source directory is not supported.")
message(FATAL_ERROR "Please remove the created \"CMakeCache.txt\" file, the \"CMakeFiles\"
directory and create a build directory and call \"${CMAKE_COMMAND} <path to the sources>\".")
endif("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
set(QT_REQUIRED_VERSION 5.3.0)
find_package(Qt5 ${QT_REQUIRED_VERSION} REQUIRED
Qml Quick Gui Multimedia Core Svg Xml XmlPatterns LinguistTools)
#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message("${_variableName}=${${_variableName}}")
#endforeach()
# Set output directory
if(CMAKE_HOST_APPLE)
set(_bundle_bin gcompris-qt.app/Contents/MacOS)
set(_data_dest_dir bin/${_bundle_bin})
elseif(ANDROID)
set(_data_dest_dir android/assets)
else()
set(_data_dest_dir share/gcompris-qt)
endif()
if(ANDROID)
# Android .so output
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/android/libs/${ARM_TARGET}/)
set(GCOMPRIS_TRANSLATIONS_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir} CACHE INTERNAL "" FORCE)
set(GCOMPRIS_RCC_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir} CACHE INTERNAL "" FORCE)
add_subdirectory(android)
else(ANDROID)
# Desktop build
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(GCOMPRIS_TRANSLATIONS_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir}/translations CACHE INTERNAL "" FORCE)
set(GCOMPRIS_RCC_DIR ${CMAKE_BINARY_DIR}/${_data_dest_dir}/rcc CACHE INTERNAL "" FORCE)
endif(ANDROID)
# Always create these folders
add_custom_command(
OUTPUT shareFolders
COMMAND cmake -E make_directory ${GCOMPRIS_TRANSLATIONS_DIR}
COMMAND cmake -E make_directory ${GCOMPRIS_RCC_DIR}
)
add_custom_target(
createShareFolders ALL
DEPENDS shareFolders
)
include(cmake/rcc.cmake)
# Translations handling
# Simple command calling the python script
add_custom_command(
OUTPUT retrievePoFilesFromSvn
COMMAND python2 tools/l10n-fetch-po-files.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# Install translations
add_custom_target(getSvnTranslations
DEPENDS retrievePoFilesFromSvn
COMMENT "Re-run cmake after this to be able to run BuildTranslations with the latest files"
)
# Get all po files in po/. You can get them doing : python2 tools/l10n-fetch-po-files.py
file(GLOB TRANSLATIONS_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "po/*.po")
# Set the output dir for the translation files to /bin
foreach(PoSource ${TRANSLATIONS_FILES})
# Changes the .po extension to .ts
string(REPLACE ".po" ".ts" TsSource ${PoSource})
# Removes the po/ folder
string(REPLACE "po/" "" TsSource ${TsSource})
# qm filename
string(REPLACE ".ts" ".qm" QmOutput ${TsSource})
add_custom_command(
OUTPUT ${QmOutput}
COMMAND cmake -E make_directory ${GCOMPRIS_TRANSLATIONS_DIR}
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/tmp
COMMAND lconvert -if po -of qm -i ${CMAKE_SOURCE_DIR}/${PoSource} -o ${GCOMPRIS_TRANSLATIONS_DIR}/${QmOutput}
)
list(APPEND QM_FILES ${QmOutput})
endforeach()
# Install translations
add_custom_target(BuildTranslations
DEPENDS ${QM_FILES}
COMMENT "If you don't have the .po, you need to run make getSvnTranslations first then re-run cmake"
)
if(CMAKE_HOST_APPLE)
install(DIRECTORY ${GCOMPRIS_TRANSLATIONS_DIR} DESTINATION ${_bundle_bin})
else()
install(DIRECTORY ${GCOMPRIS_TRANSLATIONS_DIR} DESTINATION ${_data_dest_dir})
endif()
# Build standalone package option -> if ON, we will copy the required Qt files in the build package.
# If OFF, "make install" will not copy Qt files so only GCompris files will be packaged.
# By default, it is true on Windows (as we deliver NSIS package), macOS (bundled), android (apk) and false on linux (to do make install)
# If you want to create a STGZ package for linux (auto-extractible), override this variable by typing : cmake -DBUILD_STANDALONE=ON
if(UNIX AND NOT ANDROID)
option(BUILD_STANDALONE "Build a standalone package when typing 'make package'" OFF)
else()
option(BUILD_STANDALONE "Build a standalone package when typing 'make package'" ON)
endif()
option(WITH_ACTIVATION_CODE "Include the activation system" OFF)
add_subdirectory(src)