chore: update build scripts

This commit is contained in:
Qsaker 2024-02-01 10:34:50 +08:00
parent 26fb792bf2
commit a7185aa0cb
3 changed files with 8 additions and 87 deletions

View File

@ -1,72 +1 @@
function(sak_add_lupdate)
set(LUPDATE "${Qt${QT_VERSION_MAJOR}_DIR}/../../../bin/lupdate.exe")
set(LRELEASE "${Qt${QT_VERSION_MAJOR}_DIR}/../../../bin/lrelease.exe")
# Create ts file.
set(COMMON_STR ${LUPDATE} ${CMAKE_SOURCE_DIR} -no-obsolete -ts)
add_custom_target(
sak_lupdate
COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_en.ts
COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_zh_CN.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_ar.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_cs.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_da.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_de.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_es.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_fa.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_fi.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_fr.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_he.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_uk.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_it.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_ja.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_ko.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_lt.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_pl.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_pt.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_ru.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_sk.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_sl.ts
# COMMAND ${COMMON_STR} ${CMAKE_SOURCE_DIR}/resources/translations/sak_sv.ts
SOURCES .cmake/sak_i18n.cmake
VERBATIM)
endfunction()
function(sak_add_lrelease)
# Create qm file.
add_custom_target(
sak_lrelease
COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_en.ts
COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_zh_CN.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_ar.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_cs.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_da.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_de.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_es.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_fa.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_fi.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_fr.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_he.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_uk.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_it.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_ja.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_ko.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_lt.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_pl.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_pt.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_ru.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_sk.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_sl.ts
# COMMAND ${LRELEASE} -compress ${CMAKE_SOURCE_DIR}/resources/translations/sak_sv.ts
SOURCES .cmake/sak_i18n.cmake
VERBATIM)
add_dependencies(sak_lrelease sak_lupdate)
# Auto create ts files and qm files.
option(SAK_AUTO_I18N "" OFF)
if(SAK_AUTO_I18N)
add_custom_target(sak_i18n ALL)
add_dependencies(sak_i18n sak_lrelease)
endif()
endfunction()
# Nothing

View File

@ -57,9 +57,6 @@ sak_git_get_last_tag(${CMAKE_CURRENT_SOURCE_DIR} "SAK")
# Assistant module.
include_directories(src/assistants)
include_directories(src/assistantsui)
include(${CMAKE_SOURCE_DIR}/.cmake/sak_i18n.cmake)
sak_add_lupdate()
sak_add_lrelease()
# Glog module.
option(SAK_USING_GLOG "Using glog module." ON)
@ -204,6 +201,8 @@ if(SAK_IMPORT_MODULE_BLUETOOTH)
target_link_libraries(QtSwissArmyKnife PRIVATE Qt${QT_VERSION_MAJOR}::Bluetooth)
endif()
add_subdirectory(resources/translations)
install(
TARGETS QtSwissArmyKnife
BUNDLE DESTINATION .
@ -233,7 +232,8 @@ endif()
# The private module is not open source.
option(SAK_ENABLE_APP_PRIVATE "Do not change the option unless you are the author" OFF)
if(SAK_ENABLE_APP_PRIVATE)
sak_add_subdirectory("nodeeditor-3.0.10")
if(NOT Qt6_VERSION VERSION_LESS "6.5.0")
include(${CMAKE_SOURCE_DIR}/src/private/private.cmake)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/private)
endif()
endif()

View File

@ -1,9 +1,9 @@
include(.cmake/sak_common.cmake)
include(${CMAKE_SOURCE_DIR}/.cmake/sak_common.cmake)
file(
GLOB dirs
LIST_DIRECTORIES true
"${CMAKE_SOURCE_DIR}/src/private/*")
"${CMAKE_CURRENT_SOURCE_DIR}/*")
list(REMOVE_ITEM dirs "common")
set(SAK_HAS_PRIVATE_MODULE false)
@ -15,17 +15,10 @@ foreach(dir ${dirs})
endif()
endforeach()
if(${SAK_HAS_PRIVATE_MODULE})
sak_add_subdirectory("nodeeditor-3.0.10")
add_compile_definitions(SAK_IMPORT_MODULE_PRIVATE)
endif()
foreach(dir ${dirs})
if(IS_DIRECTORY ${dir})
file(RELATIVE_PATH cooked_dir ${CMAKE_SOURCE_DIR} ${dir})
if(NOT ${cooked_dir} STREQUAL "src/private/common")
add_subdirectory(${cooked_dir})
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/${cooked_dir})
endif()
endforeach()
@ -34,5 +27,4 @@ add_custom_target(
COMMAND git clone https://gitee.com/qsaker-qsak/fluent2.git ./fluent2
COMMAND git clone https://gitee.com/qsaker-qsak/easydebug.git ./easydebug
COMMAND git clone https://gitee.com/qsaker-qsak/dataflowstudio.git ./dataflowstudio
SOURCES ${CMAKE_SOURCE_DIR}/src/private/private.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/private)