Правки для работы с Qt5
This commit is contained in:
parent
ea164d11d4
commit
3b750e439f
@ -9,10 +9,6 @@ function(myx_qt5_target_setup NAME)
|
||||
|
||||
get_target_property(type ${NAME} TYPE)
|
||||
|
||||
if(ARG_SOURCES OR ARG_CPP OR ARG_HPP OR ARG_MOD)
|
||||
myx_message_fatal_error("MyxCMake: prohibited use")
|
||||
endif()
|
||||
|
||||
if(ARG_COMPONENTS)
|
||||
find_package(Qt5 COMPONENTS ${ARG_COMPONENTS} REQUIRED)
|
||||
foreach(iter ${ARG_COMPONENTS})
|
||||
@ -36,10 +32,12 @@ function(myx_qt5_target_setup NAME)
|
||||
|
||||
if(ARG_PUBLIC_MOC)
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC})
|
||||
endif()
|
||||
|
||||
if(ARG_PRIVATE_MOC)
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC})
|
||||
endif()
|
||||
|
||||
if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
|
||||
@ -51,22 +49,35 @@ function(myx_qt5_target_setup NAME)
|
||||
endif()
|
||||
|
||||
if(ARG_UI AND "Widgets" IN_LIST ARG_COMPONENTS)
|
||||
set(Qt5Widgets_UIC_EXECUTABLE "/usr/lib/qt5/bin/uic")
|
||||
qt5_wrap_ui(ui_h ${ARG_UI})
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_UI})
|
||||
# TODO
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
# Формирование файла ресурсов с переводами
|
||||
if("LinguistTools" IN_LIST ARG_COMPONENTS)
|
||||
# Заглавие файла ресурсов
|
||||
file(WRITE ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc "<RCC><qresource prefix=\"/qm\">\n")
|
||||
# Перечень файлов, подлежащих переводу
|
||||
get_target_property(tr ${NAME} TR_FILES)
|
||||
# Для каждого языка, указанное в параметре LANGS
|
||||
foreach(iter ${ARG_LANGS})
|
||||
qt5_create_translation(qm
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
"${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts")
|
||||
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
|
||||
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
|
||||
qt5_create_translation(qm ${tr} "${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts")
|
||||
# Добавление записи для скомпилированного файла переводов в ресурсный файл
|
||||
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc
|
||||
"<file alias=\"${NAME}_${iter}\">${NAME}_${iter}.qm</file>\n")
|
||||
# Добавление скомпилированного файла переводов к списку зависимостей для цели
|
||||
target_sources(${NAME} PRIVATE ${qm})
|
||||
endforeach()
|
||||
unset(qm)
|
||||
# Окончение файла ресурсов
|
||||
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc "</qresource></RCC>\n")
|
||||
# Комплияция файла ресурсов с переводами
|
||||
qt5_add_resources(qrc_l10n ${CMAKE_BINARY_DIR}/${NAME}_l10n.qrc)
|
||||
endif()
|
||||
|
||||
target_sources(${NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
|
||||
target_sources(${NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp} ${qrc_l10n})
|
||||
|
||||
# Установка публичных заголовочных файлов
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
|
@ -4,7 +4,7 @@ function(myx_target_setup NAME)
|
||||
set(options)
|
||||
set(oneValueArgs PCH)
|
||||
set(multiValueArgs COMPILE_DEFINITIONS FIND_PACKAGES LINK_LIBRARIES
|
||||
CPP PUBLIC_HEADERS PRIVATE_HEADERS SOURCES)
|
||||
CPP PUBLIC_HEADERS PRIVATE_HEADERS)
|
||||
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
@ -21,20 +21,19 @@ function(myx_target_setup NAME)
|
||||
endforeach()
|
||||
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
|
||||
|
||||
if(ARG_SOURCES)
|
||||
myx_message_fatal_error("MyxCMake: Use of SOURCES argument")
|
||||
endif()
|
||||
|
||||
if(ARG_CPP)
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY CPP_FILES ${ARG_CPP})
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_CPP})
|
||||
endif()
|
||||
|
||||
if(ARG_PUBLIC_HEADERS)
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_HEADERS}")
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_HEADERS})
|
||||
endif()
|
||||
|
||||
if(ARG_PUBLIC_HEADERS)
|
||||
if(ARG_PRIVATE_HEADERS)
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_HEADERS}")
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_HEADERS})
|
||||
endif()
|
||||
|
||||
if(ARG_PCH)
|
||||
|
Loading…
Reference in New Issue
Block a user