This commit is contained in:
Andrei Astafev 2022-10-08 17:23:13 +03:00
parent 64737f3a33
commit 6e9fa0db82
9 changed files with 48 additions and 30 deletions

View File

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

View File

@ -58,7 +58,11 @@ function(myx_qt5_target_setup NAME)
endif()
# Перечень файлов, подлежащих переводу
get_target_property(tr ${NAME} TR_FILES)
if(target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(tr ${NAME} INTERFACE_TR_FILES)
else()
get_target_property(tr ${NAME} TR_FILES)
endif()
# Формирование файла ресурсов с переводами
if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr)
# Заглавие файла ресурсов
@ -67,7 +71,9 @@ function(myx_qt5_target_setup NAME)
foreach(iter ${ARG_LANGS})
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
qt5_create_translation(qm ${tr} "${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts")
qt5_create_translation(qm ${tr}
"${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts
OPTIONS -I ${PROJECT_SOURCE_DIR}/include")
# Добавление записи для скомпилированного файла переводов в ресурсный файл
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc
"<file alias=\"${NAME}_${iter}\">${NAME}_${iter}.qm</file>\n")

View File

@ -5,7 +5,6 @@ function(myx_target_setup NAME)
set(oneValueArgs PCH)
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
CPP INTERFACE_HEADERS PUBLIC_HEADERS PRIVATE_HEADERS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT TARGET ${NAME})
@ -59,6 +58,10 @@ function(myx_target_setup NAME)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
endif()
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}")
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}>)
endif()
set_target_properties(${NAME} PROPERTIES
POSITION_INDEPENDENT_CODE ON
@ -70,10 +73,14 @@ function(myx_target_setup NAME)
install(TARGETS ${NAME} COMPONENT main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
target_sources(${NAME} INTERFACE ${ARG_INTERFACE_HEADERS})
else()
target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
endif()
# CMake до версии 3.12 не умеет извлекать из целей типа `OBJECT_LIBRARY`
# информацию о заголовочных файлах. Это обход.
@ -83,6 +90,8 @@ function(myx_target_setup NAME)
if((NOT ${target_type} STREQUAL "OBJECT_LIBRARY") AND
(NOT ${target_type} STREQUAL "EXECUTABLE"))
target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES})
elseif(${target_type} STREQUAL "INTERFACE")
target_link_libraries(${NAME} INTERFACE ${ARG_LINK_LIBRARIES})
else()
foreach(link_library ${ARG_LINK_LIBRARIES})
if(TARGET ${link_library})

View File

@ -6,7 +6,7 @@ endif()
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
function(myx_uncrustify target)
function(myx_uncrustify NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
endif()
@ -33,8 +33,6 @@ function(myx_uncrustify target)
return()
endif()
if(NOT TARGET myx-uncrustify)
add_custom_target(myx-uncrustify)
endif()
@ -46,30 +44,35 @@ function(myx_uncrustify target)
endif()
# Динамически сгенерированные файлы исключаются
get_target_property(s ${target} SOURCES)
get_target_property(target_type ${NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(s ${NAME} INTERFACE_SOURCES)
else()
get_target_property(s ${NAME} SOURCES)
endif()
foreach(iter ${s})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND src ${iter})
endif()
endforeach()
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
-c ${ARG_CONFIG}
-o ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
-o ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
# cmake-format: off
add_custom_target(${target}-uncrustify-check
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
add_custom_target(${NAME}-uncrustify-check
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${src})
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
add_custom_target(${target}-uncrustify
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
add_custom_target(${NAME}-uncrustify
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${src})
add_custom_target(${target}-uncrustify-append-comments
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
add_custom_target(${NAME}-uncrustify-append-comments
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
@ -78,7 +81,7 @@ function(myx_uncrustify target)
--set cmt_insert_before_ctor_dtor=true --mtime ${src})
# cmake-format: on
add_dependencies(myx-uncrustify ${target}-uncrustify)
add_dependencies(myx-uncrustify-check ${target}-uncrustify-check)
add_dependencies(myx-uncrustify-append-comments ${target}-uncrustify-append-comments)
add_dependencies(myx-uncrustify ${NAME}-uncrustify)
add_dependencies(myx-uncrustify-check ${NAME}-uncrustify-check)
add_dependencies(myx-uncrustify-append-comments ${NAME}-uncrustify-append-comments)
endfunction()

View File

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

View File

@ -1 +1 @@
2.0.6
2.0.7

View File

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

2
debian/changelog vendored
View File

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

View File

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