CMakeLists.txt

changeset 31
ab17a56a47dd
parent 30
0fec6a1abd13
child 48
ddd1171ecda5
equal deleted inserted replaced
30:0fec6a1abd13 31:ab17a56a47dd
11 SET( bmsapp_VERSION_MAJOR 0 ) 11 SET( bmsapp_VERSION_MAJOR 0 )
12 SET( bmsapp_VERSION_MINOR 1 ) 12 SET( bmsapp_VERSION_MINOR 1 )
13 SET( bmsapp_VERSION_PATCH 0 ) 13 SET( bmsapp_VERSION_PATCH 0 )
14 14
15 # Compile flags 15 # Compile flags
16
17 OPTION(DO_RELEASE_BUILD "If on, will do a release build. Otherwise, debug build." OFF)
18 option(UPDATE_TRANSLATIONS "Enable rescanning sources to update .ts files" OFF)
16 19
17 # Automatically run moc on source files when necessary 20 # Automatically run moc on source files when necessary
18 set(CMAKE_AUTOMOC ON) 21 set(CMAKE_AUTOMOC ON)
19 set(CMAKE_AUTOUIC ON) 22 set(CMAKE_AUTOUIC ON)
20 set(CMAKE_AUTORCC ON) 23 set(CMAKE_AUTORCC ON)
58 61
59 SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}") 62 SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}")
60 SET(SRCDIR "${ROOTDIR}/src") 63 SET(SRCDIR "${ROOTDIR}/src")
61 SET(UIDIR "${ROOTDIR}/ui") 64 SET(UIDIR "${ROOTDIR}/ui")
62 SET(DATADIR "${ROOTDIR}/data") 65 SET(DATADIR "${ROOTDIR}/data")
63 #SET(TRANSLATIONSDIR "${ROOTDIR}/translations") 66 SET(TRANSLATIONSDIR "${ROOTDIR}/translations")
64 67
65 INCLUDE_DIRECTORIES(${SRCDIR}) 68 INCLUDE_DIRECTORIES(${SRCDIR})
66 INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build. 69 INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build.
67 70
68 # ===== Find Qt5 ===== 71 # ===== Find Qt5 =====
69 72
70 # Minimum versio 5.13 for debug messages. 73 # Minimum versio 5.13 for debug messages.
71 find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql) 74 find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools)
72 75
73 # PrintSupport Xml LinguistTools 76 # PrintSupport Xml LinguistTools
74 77
75 # Some extra files for the "make clean" target. 78 # Some extra files for the "make clean" target.
76 SET_PROPERTY( 79 SET_PROPERTY(
161 ${UIDIR}/EditEquipment.ui 164 ${UIDIR}/EditEquipment.ui
162 ${UIDIR}/Setup.ui 165 ${UIDIR}/Setup.ui
163 ${UIDIR}/MainWindow.ui 166 ${UIDIR}/MainWindow.ui
164 ) 167 )
165 168
169
170 set( TS_FILES
171 ${TRANSLATIONSDIR}/bmsapp_en.ts # English
172 ${TRANSLATIONSDIR}/bmsapp_nl.ts # Dutch
173 )
174
166 set( SOURCE_FILES 175 set( SOURCE_FILES
167 ${SRCS} 176 ${SRCS}
168 ${HDRS} 177 ${HDRS}
169 ${UIS} 178 ${UIS}
170 resources/icons.qrc 179 resources/icons.qrc
171 resources/qdarkstyle/theme/style.qrc 180 resources/qdarkstyle/theme/style.qrc
172 ) 181 )
173 182
174 # ===== Build the application ===== 183 # ===== Build the application =====
175 184
176 add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES}) 185 # Run with cmake -DUPDATE_TRANSLATIONS=ON ..
186 # or cmake -DUPDATE_TRANSLATIONS=OFF ..
187
188 if(UPDATE_TRANSLATIONS)
189 message("** parse sources for new translations")
190 qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})
191 else()
192 message("** update qm files")
193 qt5_add_translation(QM_FILES ${TS_FILES})
194 endif()
195
196 add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES} ${QM_FILES})
177 target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql) 197 target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql)
178 198
199 # `make translations'
200 add_custom_target(translations DEPENDS ${QM_FILES})
201
202
203 # ===== Install the application =====
204
205

mercurial