Browse Source

Attempt to make translations optional (MXE...)

Ivan Savenko 2 years ago
parent
commit
20dec34484
2 changed files with 17 additions and 6 deletions
  1. 7 2
      CMakeLists.txt
  2. 10 4
      launcher/CMakeLists.txt

+ 7 - 2
CMakeLists.txt

@@ -52,6 +52,7 @@ option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
 option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
 option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
 option(ENABLE_EDITOR "Enable compilation of map editor" ON)
+option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
 if(APPLE_IOS)
 	set(BUNDLE_IDENTIFIER_PREFIX "" CACHE STRING "Bundle identifier prefix")
 	set(APP_DISPLAY_NAME "VCMI" CACHE STRING "App name on the home screen")
@@ -316,8 +317,12 @@ find_package(TBB REQUIRED)
 
 if(ENABLE_LAUNCHER OR ENABLE_EDITOR)
 	# Widgets finds its own dependencies (QtGui and QtCore).
-	find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network LinguistTools)
-	find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network LinguistTools)
+	find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network OPTIONAL_COMPONENTS LinguistTools)
+	find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network OPTIONAL_COMPONENTS LinguistTools)
+
+	if (NOT DEFINED Qt5LinguistTools_DIR)
+		set(ENABLE_TRANSLATIONS OFF)
+	endif()
 endif()
 
 if(ENABLE_LUA)

+ 10 - 4
launcher/CMakeLists.txt

@@ -90,11 +90,15 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 if(TARGET Qt6::Core)
 	qt_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
-	qt_add_translation( launcher_QM ${launcher_TS} )
+	if (ENABLE_TRANSLATIONS)
+		qt_add_translation( launcher_QM ${launcher_TS} )
+	endif()
 else()
-	set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/translations)
 	qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS})
-	qt5_add_translation( launcher_QM ${launcher_TS} )
+	if (ENABLE_TRANSLATIONS)
+		set_source_files_properties(${launcher_TS} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/translations)
+		qt5_add_translation( launcher_QM ${launcher_TS} )
+	endif()
 endif()
 
 
@@ -169,4 +173,6 @@ else()
 endif()
 
 install(DIRECTORY icons DESTINATION ${RESOURCES_DESTINATION})
-install(DIRECTORY ts DESTINATION ${RESOURCES_DESTINATION})
+if (ENABLE_TRANSLATIONS)
+	install(DIRECTORY translation DESTINATION ${RESOURCES_DESTINATION})
+endif()