diff -r 593a658cba8e -r 73e448b2943d CMakeLists.txt --- a/CMakeLists.txt Thu Oct 03 11:45:44 2019 +0300 +++ b/CMakeLists.txt Thu Oct 03 23:44:28 2019 +0300 @@ -3,12 +3,13 @@ #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") #include(cotire) find_package(Qt5Widgets REQUIRED) +if (Qt5Widgets_VERSION VERSION_LESS 5.5.0) + message(FATAL_ERROR "Qt5 version 5.5 required") +endif() find_package(Qt5Core REQUIRED) find_package(Qt5OpenGL REQUIRED) find_package(Qt5Network REQUIRED) -if (Qt5Widgets_VERSION VERSION_LESS 5.5.0) - message(FATAL_ERROR "Qt5 version 5.5 required") -endif() +find_package(Qt5LinguistTools REQUIRED) set (CMAKE_AUTOMOC ON) find_package (OpenGL REQUIRED) add_custom_target (revision_check ALL @@ -23,8 +24,7 @@ src/mainwindow.cpp src/model.cpp src/modeleditcontext.cpp - src/parser.cpp - src/uuid.cpp + src/parser.cpp src/version.cpp src/vertex.cpp src/objecttypes/comment.cpp @@ -43,8 +43,7 @@ src/mainwindow.h src/model.h src/modeleditcontext.h - src/parser.h - src/uuid.h + src/parser.h src/version.h src/vertex.h src/objecttypes/comment.h @@ -62,6 +61,19 @@ # src/configurationoptions.txt # data/primitive-categories.cfg # ) + +set(LDFORGE_LOCALES + locale/fi.ts + locale/sv.ts + locale/ru.ts +) + +# Qt5LinguistTools +qt5_create_translation(QM_FILES ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} ${LDFORGE_FORMS} ${LDFORGE_LOCALES}) +add_custom_target(translations ALL DEPENDS ${QM_FILES}) +add_custom_target(resources ALL DEPENDS ${RESOURCE_FILES}) +add_dependencies(resources translations) + set (LDFORGE_RESOURCES ldforge.qrc) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -79,16 +91,28 @@ endif() # qt5_add_resources (LDFORGE_QRC ${LDFORGE_RESOURCES}) qt5_wrap_ui (LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS}) + +# Move languages.qrc into the build directory to bake the .qm-files into LDForge +# so that they don't have to be shipped separately +# https://stackoverflow.com/a/34798124 +set(LANGUAGES_QRC "languages.qrc") +configure_file(${LANGUAGES_QRC} ${LANGUAGES_QRC} COPYONLY) +qt5_add_resources(LDFORGE_QM_RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${LANGUAGES_QRC}) + add_executable (ldforge WIN32 ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} # ${LDFORGE_OTHER_FILES} -# ${LDFORGE_QRC} + ${LDFORGE_RESOURCES} + ${LDFORGE_QRC} + ${LDFORGE_QM_RC_FILE} ${LDFORGE_FORMS_HEADERS} # ${CMAKE_BINARY_DIR}/configuration.cpp ) + set_source_files_properties(${LDFORGE_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${LDFORGE_OTHER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) +set_source_files_properties(${LDFORGE_RESOURCES} PROPERTIES HEADER_FILE_ONLY TRUE) set_target_properties(ldforge PROPERTIES AUTOMOC 1) target_link_libraries(ldforge Qt5::Widgets Qt5::Network Qt5::OpenGL ${OPENGL_LIBRARIES}) # cotire(ldforge)