This commit is contained in:
Andrei Astafev 2022-10-15 10:14:08 +03:00
parent e87e190cd3
commit 8c4594fd71
13 changed files with 93 additions and 89 deletions

View File

@ -1,4 +1,4 @@
set(MYX_CMAKE_PACKAGE_VERSION "2.0.20") set(MYX_CMAKE_PACKAGE_VERSION "2.0.21")
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()

View File

@ -12,8 +12,8 @@ function(myx_create_packages TARGET_NAME)
# Общие настройки для пакета: организация, автор, версия # Общие настройки для пакета: организация, автор, версия
if(NOT ${PROJECT_NAME}_CONTACT) if(NOT ${PROJECT_NAME}_CONTACT)
if(${PROJECT_NAME}_AUTHOR AND ${PROJECT_NAME}_EMAIL) if(${PROJECT_NAME}_AUTHOR_NAME AND ${PROJECT_NAME}_AUTHOR_EMAIL)
set(CPACK_PACKAGE_CONTACT "${${PROJECT_NAME}_AUTHOR} <${${PROJECT_NAME}_EMAIL}>") set(CPACK_PACKAGE_CONTACT "${${PROJECT_NAME}_AUTHOR_NAME} <${${PROJECT_NAME}_AUTHOR_EMAIL}>")
else() else()
set(CPACK_PACKAGE_CONTACT "unknown maintainer <nonexistent@mailbox>") set(CPACK_PACKAGE_CONTACT "unknown maintainer <nonexistent@mailbox>")
myx_message_warning("\${PROJECT_NAME}_CONTACT variable is required for packaging but unset") myx_message_warning("\${PROJECT_NAME}_CONTACT variable is required for packaging but unset")
@ -23,8 +23,8 @@ function(myx_create_packages TARGET_NAME)
endif() endif()
if(NOT ${PROJECT_NAME}_VENDOR) if(NOT ${PROJECT_NAME}_VENDOR)
if(${PROJECT_NAME}_AUTHOR) if(${PROJECT_NAME}_AUTHOR_NAME)
set(CPACK_PACKAGE_VENDOR "${${PROJECT_NAME}_AUTHOR}") set(CPACK_PACKAGE_VENDOR "${${PROJECT_NAME}_AUTHOR_NAME}")
else() else()
set(CPACK_PACKAGE_VENDOR "unknown vendor") set(CPACK_PACKAGE_VENDOR "unknown vendor")
myx_message_warning("\${PROJECT_NAME}_VENDOR variable is required for packaging but unset") myx_message_warning("\${PROJECT_NAME}_VENDOR variable is required for packaging but unset")
@ -187,4 +187,4 @@ function(myx_create_packages TARGET_NAME)
# Подключение модуля, выполняющего сборку архивов и пакетов # Подключение модуля, выполняющего сборку архивов и пакетов
include(CPack) include(CPack)
endfunction(myx_create_packages NAME) endfunction(myx_create_packages TARGET_NAME)

View File

@ -24,7 +24,7 @@ include_guard(GLOBAL)
# Обязательно в глобальной области # Обязательно в глобальной области
find_package(Git) find_package(Git)
function(FetchContent_Add NAME) function(FetchContent_Add TARGET_NAME)
set(options "") set(options "")
set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH) set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH)
set(multiValueArgs "") set(multiValueArgs "")
@ -45,12 +45,12 @@ function(FetchContent_Add NAME)
endif() endif()
FetchContent_Declare( FetchContent_Declare(
${NAME} ${TARGET_NAME}
${ARG_UNPARSED_ARGUMENTS} ${ARG_UNPARSED_ARGUMENTS}
GIT_REPOSITORY ${ARG_GIT_REPOSITORY} GIT_REPOSITORY ${ARG_GIT_REPOSITORY}
GIT_SHALLOW 1 GIT_SHALLOW 1
) )
set(FETCHCONTENT_QUIET off) set(FETCHCONTENT_QUIET off)
FetchContent_MakeAvailable(${NAME}) FetchContent_MakeAvailable(${TARGET_NAME})
endfunction() endfunction()

View File

@ -1,45 +1,45 @@
include_guard(GLOBAL) include_guard(GLOBAL)
function(myx_qt5_target_setup NAME) function(myx_qt5_target_setup TARGET_NAME)
set(options) set(options)
set(oneValueArgs) set(oneValueArgs)
set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS) set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_target_property(target_type ${NAME} TYPE) get_target_property(target_type ${TARGET_NAME} TYPE)
foreach(iter ${ARG_COMPONENTS}) foreach(iter ${ARG_COMPONENTS})
if(target_type STREQUAL "INTERFACE_LIBRARY") if(target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${NAME} INTERFACE ${Qt5${iter}_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} INTERFACE ${Qt5${iter}_INCLUDE_DIRS})
else() else()
target_include_directories(${NAME} PRIVATE ${Qt5${iter}_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} PRIVATE ${Qt5${iter}_INCLUDE_DIRS})
endif() endif()
if(target_type STREQUAL "EXECUTABLE" AND NOT iter STREQUAL "LinguistTools") if(target_type STREQUAL "EXECUTABLE" AND NOT iter STREQUAL "LinguistTools")
target_link_libraries(${NAME} PRIVATE "Qt5::${iter}") target_link_libraries(${TARGET_NAME} PRIVATE "Qt5::${iter}")
endif() endif()
endforeach() endforeach()
foreach(iter ${ARG_PRIVATE}) foreach(iter ${ARG_PRIVATE})
if(target_type STREQUAL "INTERFACE_LIBRARY") if(target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${NAME} INTERFACE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} INTERFACE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
else() else()
target_include_directories(${NAME} PRIVATE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} PRIVATE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
endif() endif()
endforeach() endforeach()
if(target_type STREQUAL "EXECUTABLE") if(target_type STREQUAL "EXECUTABLE")
target_compile_options(${NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}) target_compile_options(${TARGET_NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS})
endif() endif()
if(ARG_PUBLIC_MOC) if(ARG_PUBLIC_MOC)
set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}") set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC}) set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC})
endif() endif()
if(ARG_PRIVATE_MOC) if(ARG_PRIVATE_MOC)
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}") set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC}) set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC})
endif() endif()
if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC) if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
@ -52,42 +52,42 @@ function(myx_qt5_target_setup NAME)
if(ARG_UI AND "Widgets" IN_LIST ARG_COMPONENTS) if(ARG_UI AND "Widgets" IN_LIST ARG_COMPONENTS)
qt5_wrap_ui(ui_h ${ARG_UI}) qt5_wrap_ui(ui_h ${ARG_UI})
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_UI}) set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_UI})
# TODO # TODO
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR}) target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
endif() endif()
# Перечень файлов, подлежащих переводу # Перечень файлов, подлежащих переводу
if(target_type STREQUAL "INTERFACE_LIBRARY") if(target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(tr ${NAME} INTERFACE_TR_FILES) get_target_property(tr ${TARGET_NAME} INTERFACE_TR_FILES)
else() else()
get_target_property(tr ${NAME} TR_FILES) get_target_property(tr ${TARGET_NAME} TR_FILES)
endif() endif()
# Формирование файла ресурсов с переводами # Формирование файла ресурсов с переводами
if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr) if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr)
# Заглавие файла ресурсов # Заглавие файла ресурсов
file(WRITE ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc "<RCC><qresource prefix=\"/qm\">\n") file(WRITE ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "<RCC><qresource prefix=\"/qm\">\n")
# Для каждого языка, указанное в параметре LANGS # Для каждого языка, указанное в параметре LANGS
foreach(iter ${ARG_LANGS}) foreach(iter ${ARG_LANGS})
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n # Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
# и его компиляция в каталог ${PROJECT_BINARY_DIR} # и его компиляция в каталог ${PROJECT_BINARY_DIR}
qt5_create_translation(qm ${tr} qt5_create_translation(qm ${tr}
"${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts" "${PROJECT_SOURCE_DIR}/l10n/${TARGET_NAME}_${iter}.ts"
OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}) OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME})
# Добавление записи для скомпилированного файла переводов в ресурсный файл # Добавление записи для скомпилированного файла переводов в ресурсный файл
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc
"<file alias=\"${NAME}_${iter}\">${NAME}_${iter}.qm</file>\n") "<file alias=\"${TARGET_NAME}_${iter}\">${TARGET_NAME}_${iter}.qm</file>\n")
# Добавление скомпилированного файла переводов к списку зависимостей для цели # Добавление скомпилированного файла переводов к списку зависимостей для цели
target_sources(${NAME} PRIVATE ${qm}) target_sources(${TARGET_NAME} PRIVATE ${qm})
endforeach() endforeach()
# Окончение файла ресурсов # Окончение файла ресурсов
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc "</qresource></RCC>\n") file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "</qresource></RCC>\n")
# Комплияция файла ресурсов с переводами # Комплияция файла ресурсов с переводами
qt5_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc) qt5_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc)
target_sources(${NAME} PRIVATE ${qrc_l10n}) target_sources(${TARGET_NAME} PRIVATE ${qrc_l10n})
endif() endif()
unset(tr) unset(tr)
target_sources(${NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp}) target_sources(${TARGET_NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
# Установка публичных заголовочных файлов # Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL) if(PROJECT_IS_TOP_LEVEL)

View File

@ -4,7 +4,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif() endif()
function(myx_doc_doxygen NAME) function(myx_doc_doxygen TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0") if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT}) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT})
endif() endif()
@ -17,14 +17,14 @@ function(myx_doc_doxygen NAME)
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE) set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
endif() endif()
set(target "myx-doc-doxygen-${NAME}") set(target myx-doc-doxygen-${TARGET_NAME})
if(NOT DOXYGEN_FOUND) if(TARGET ${target})
add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build") myx_message_warning("Target ${target} already defined")
return() return()
endif() endif()
if(TARGET ${target}) if(NOT DOXYGEN_FOUND)
myx_message_warning("Target ${target} already defined") add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build")
return() return()
endif() endif()

View File

@ -5,12 +5,13 @@ myx_generate_git_info_header
Вспомогательная функция для автоматической генерации заголовочного Вспомогательная функция для автоматической генерации заголовочного
файла, содержащего информацию о текущем состоянии репозитория git:: файла, содержащего информацию о текущем состоянии репозитория git::
myx_generate_git_info_header(TARGET BASE_FILENAME myx_generate_git_info_header(TARGET_NAME BASE_FILENAME
[ PREFIX prefix ] ) [ PREFIX prefix ] )
Обязательные параметры: `TARGET` - имя цели, с которой связан заголовочный файл, Обязательные параметры: `TARGET_NAME` - имя цели, с которой связан
и `BASE_FILENAME` - имя генерируемого заголовочного файла. Дополнительный аргумент заголовочный файл, и `BASE_FILENAME` - имя генерируемого заголовочного
`PREFIX` добавляет префикс к генерируемым именам переменных. файла. Дополнительный аргумент `PREFIX` добавляет префикс к генерируемым
именам переменных.
#]=======================================================================] #]=======================================================================]
@ -20,7 +21,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif() endif()
function(myx_generate_git_info_header target base_filename) function(myx_generate_git_info_header TARGET_NAME BASE_FILENAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0") if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT}) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT})
endif() endif()
@ -30,24 +31,25 @@ function(myx_generate_git_info_header target base_filename)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}") set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
write(APPEND ${__filename} "")
set(PREFIX "") set(__prefix "")
if(ARG_PREFIX) if(ARG_PREFIX)
string(APPEND ARG_PREFIX "_") string(APPEND ARG_PREFIX "_")
string(REPLACE "-" "_" PREFIX ${ARG_PREFIX}) string(REPLACE "-" "_" __prefix ${ARG_PREFIX})
endif() endif()
# cmake-format: off # cmake-format: off
if(NOT TARGET ${target}-git-info-header) if(NOT TARGET ${TARGET_NAME}-git-info-header)
add_custom_target(${target}-git-info-header ALL add_custom_target(${TARGET_NAME}-git-info-header ALL
${CMAKE_COMMAND} -DGIT_INFO_FILE=${filename} -DPREFIX=${PREFIX} ${CMAKE_COMMAND} -DGIT_INFO_FILE=${__filename} -DPREFIX=${__prefix}
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/GitInfo.cmake -P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/GitInfo.cmake
BYPRODUCTS ${filename} BYPRODUCTS ${__filename}
WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR}) WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR})
endif() endif()
# cmake-format: on # cmake-format: on
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename}) set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
target_sources(${target} PRIVATE ${filename}) target_sources(${TARGET_NAME} PRIVATE ${__filename})
endfunction() endfunction()

View File

@ -5,10 +5,10 @@ myx_generate_private_config_header
Вспомогательная функция для автоматической генерации заголовочного Вспомогательная функция для автоматической генерации заголовочного
файла, содержащего информацию о проекте:: файла, содержащего информацию о проекте::
myx_generate_private_config_header(TARGET BASE_FILENAME) myx_generate_private_config_header(TARGET_NAME BASE_FILENAME)
Обязательные параметры: `TARGET` - имя цели, с которой связан заголовочный файл, Обязательные параметры: `TARGET_NAME` - имя цели, с которой связан
и `BASE_FILENAME` - имя генерируемого заголовочного файла. заголовочный файл, и `BASE_FILENAME` - имя генерируемого заголовочного файла.
#]=======================================================================] #]=======================================================================]
@ -18,7 +18,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}") set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif() endif()
function(myx_generate_private_config_header target base_filename) function(myx_generate_private_config_header TARGET_NAME BASE_FILENAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0") if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT}) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT})
endif() endif()
@ -27,9 +27,9 @@ function(myx_generate_private_config_header target base_filename)
myx_project_version_int() myx_project_version_int()
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}") set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${filename}) configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${__filename})
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename}) set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
target_sources(${target} PRIVATE ${filename}) target_sources(${TARGET_NAME} PRIVATE ${__filename})
endfunction() endfunction()

View File

@ -6,12 +6,12 @@ endif()
find_program(UNCRUSTIFY_EXE NAMES uncrustify) find_program(UNCRUSTIFY_EXE NAMES uncrustify)
function(myx_uncrustify NAME) function(myx_uncrustify TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0") if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT}) set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
endif() endif()
myx_skip_external_target(${NAME}) myx_skip_external_target(${TARGET_NAME})
set(options) set(options)
set(oneValueArgs CONFIG) set(oneValueArgs CONFIG)
@ -46,11 +46,11 @@ function(myx_uncrustify NAME)
endif() endif()
# Динамически сгенерированные файлы исключаются # Динамически сгенерированные файлы исключаются
get_target_property(target_type ${NAME} TYPE) get_target_property(target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY") if(${target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(s ${NAME} INTERFACE_SOURCES) get_target_property(s ${TARGET_NAME} INTERFACE_SOURCES)
else() else()
get_target_property(s ${NAME} SOURCES) get_target_property(s ${TARGET_NAME} SOURCES)
endif() endif()
foreach(iter ${s}) foreach(iter ${s})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos) string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
@ -58,24 +58,26 @@ function(myx_uncrustify NAME)
list(APPEND src ${iter}) list(APPEND src ${iter})
endif() endif()
endforeach() endforeach()
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
set(__fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
-c ${ARG_CONFIG} -c ${ARG_CONFIG} -o ${__fixed_config})
-o ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg) list(APPEND __options -c ${__fixed_config})
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
# cmake-format: off # cmake-format: off
add_custom_target(${NAME}-uncrustify-check add_custom_target(${TARGET_NAME}-uncrustify-check
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${src}) COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${src})
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup) list(APPEND __options --replace --no-backup)
add_custom_target(${NAME}-uncrustify add_custom_target(${TARGET_NAME}-uncrustify
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${src}) COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${src})
add_custom_target(${NAME}-uncrustify-append-comments add_custom_target(${TARGET_NAME}-uncrustify-append-comments
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} COMMAND ${UNCRUSTIFY_EXE} ${__options}
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt --set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt --set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
--set cmt_insert_file_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt --set cmt_insert_file_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt
@ -83,7 +85,7 @@ function(myx_uncrustify NAME)
--set cmt_insert_before_ctor_dtor=true --mtime ${src}) --set cmt_insert_before_ctor_dtor=true --mtime ${src})
# cmake-format: on # cmake-format: on
add_dependencies(myx-uncrustify ${NAME}-uncrustify) add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)
add_dependencies(myx-uncrustify-check ${NAME}-uncrustify-check) add_dependencies(myx-uncrustify-check ${TARGET_NAME}-uncrustify-check)
add_dependencies(myx-uncrustify-append-comments ${NAME}-uncrustify-append-comments) add_dependencies(myx-uncrustify-append-comments ${TARGET_NAME}-uncrustify-append-comments)
endfunction() endfunction()

View File

@ -3,7 +3,7 @@
## Установка ## Установка
В корневом каталоге проекта создать каталог `cmake` и распаковать в него В корневом каталоге проекта создать каталог `cmake` и распаковать в него
[архив](../../../releases/download/2.0.20/myx-cmake-local-2.0.20.tar.xz ). [архив](../../../releases/download/2.0.21/myx-cmake-local-2.0.21.tar.xz ).
## Использование ## Использование

View File

@ -1 +1 @@
2.0.20 2.0.21

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.6 FATAL_ERROR) cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(myx-cmake VERSION 2.0.20 LANGUAGES) project(myx-cmake VERSION 2.0.21 LANGUAGES)
include(GNUInstallDirs) include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
myx-cmake (2.0.20) unstable; urgency=medium myx-cmake (2.0.21) unstable; urgency=medium
* New version. * New version.

View File

@ -20,11 +20,11 @@ if(ENV{MYX_CMAKE_DIR})
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR}) set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
endif() endif()
if(MYX_CMAKE_DIR) if(MYX_CMAKE_DIR)
find_package(MyxCMake 2.0.20 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH) find_package(MyxCMake 2.0.21 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===") myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
else() else()
if(MYX_CMAKE_USE_SYSTEM) if(MYX_CMAKE_USE_SYSTEM)
find_package(MyxCMake 2.0.20 REQUIRED) find_package(MyxCMake 2.0.21 REQUIRED)
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===") myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
else() else()
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake) include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)