Compare commits

..

11 Commits

37 changed files with 907 additions and 557 deletions

3
.gitignore vendored
View File

@@ -7,6 +7,9 @@ build
# Каталог для тестирования установки
_output
# Каталог для скачивания необходимых файлов
_downloads
# Файлы настроек, редактируемые во время отладки,
# за исключением шаблонных файлов
files/etc/*.conf

View File

@@ -1,20 +1,42 @@
---
include:
- project: 'f1x1t/gitlab-ci'
- project: 'cicd/gitlab'
ref: master
file: 'scheduled.yml'
file: 'gitlab.yml'
smolensk15-nightly:
extends: .scheduled-smolensk15
variables:
# git ssl no verify - git clone works for https/ssl from letsencrypt
GIT_SSL_NO_VERIFY: "1"
orel212-nightly:
extends: .scheduled-orel212
uncrustify:
extends:
- .test-formatting-with-uncrustify
focal-nightly:
extends: .scheduled-focal
build-smolensk15:
extends:
- .image-smolensk15-large
- .build-cmake-make
jammy-nightly:
extends: .scheduled-jammy
build-smolensk16:
extends:
- .image-smolensk16-large
- .build-cmake-make
elbrus-nightly:
extends: .scheduled-elbrus
build-smolensk17:
extends:
- .image-smolensk16-large
- .build-cmake-make
build-with-modern-clang:
extends:
- .use-clang-18
- .image-noble-large
- .build-cmake-ninja
analyze-clang-tidy:
extends:
- .cmake-analyze-clang-tidy
analyze-pvs-studio:
extends:
- .cmake-analyze-pvs-studio

View File

@@ -11,34 +11,12 @@ project(myx-example-app-ext VERSION 0.4.0 LANGUAGES C CXX)
set(${PROJECT_NAME}_AUTHOR_NAME "Andrey Astafyev")
set(${PROJECT_NAME}_AUTHOR_EMAIL "dev@246060.ru")
set(CMAKE_CXX_STANDARD 11)
# Рекомендуемый способ подключения MyxCMake
include(cmake/myx_setup.cmake)
if(PROJECT_IS_TOP_LEVEL)
myx_add_external_target(myx-example-interface-library
GIT_REPOSITORY git@gitlab.2:myx/examples/myx-example-interface-library)
myx_add_external_target(myx-example-object-library
GIT_REPOSITORY git@gitlab.2:myx/examples/myx-example-object-library)
endif()
#add_subdirectory(${PROJECT_SOURCE_DIR}/modules/myx-example-interface-library ${CMAKE_BINARY_DIR}/myx-example-interface-library EXCLUDE_FROM_ALL)
#add_subdirectory(${PROJECT_SOURCE_DIR}/modules/myx-example-object-library ${CMAKE_BINARY_DIR}/myx-example-object-library EXCLUDE_FROM_ALL)
#if(PROJECT_IS_TOP_LEVEL)
# FetchContent_Add(myx-example-interface-library
# GIT_REPOSITORY git@gitlab.2:myx/examples/myx-example-interface-library
# GIT_PATH myx/examples/myx-example-interface-library
# GIT_REMOTE origin
# )
# FetchContent_Add(myx-example-object-library
# GIT_REPOSITORY git@gitlab.2:myx/examples/myx-example-object-library
# GIT_PATH myx/examples/myx-example-object-library
# GIT_REMOTE origin
# )
#else()
# include(myx_add_subdirectories.cmake)
#endif()
# Правила загрузки требуемых файлов
include(myx_download_content.cmake)
# Цель для создания исполняемого файла
myx_add_executable(${PROJECT_NAME})

View File

@@ -24,8 +24,7 @@ set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
# Модули для обеспечения обратной совместимости со старыми версиями CMake
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
if(${CMAKE_VERSION} VERSION_LESS 3.11)
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
else()
include(FetchContent)
@@ -38,11 +37,13 @@ include(CMakeDependentOption)
# Полезные макросы
include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/FindQt.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/CheckEnableCxxCompilerFlag.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/GTest.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/QTest.cmake)
include(${MYX_CMAKE_LIB_DIR}/ProjectIsTopLevel.cmake)
include(${MYX_CMAKE_LIB_DIR}/ColoredMessages.cmake)
include(${MYX_CMAKE_LIB_DIR}/PopulateCMakeBinaryDir.cmake)
include(${MYX_CMAKE_LIB_DIR}/CurrentDate.cmake)
@@ -50,18 +51,14 @@ include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWarning.cmake)
include(${MYX_CMAKE_LIB_DIR}/DirectoriesGuards.cmake)
include(${MYX_CMAKE_LIB_DIR}/SemanticProjectVersion.cmake)
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWrapper.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddExternalTarget.cmake)
include(${MYX_CMAKE_LIB_DIR}/FetchContentAdd.cmake)
include(${MYX_CMAKE_LIB_DIR}/DownloadContent.cmake)
set(MYX_CMAKE_TOOLCHAINS_DIR "${MYX_CMAKE_LIB_DIR}/toolchains")
include(${MYX_CMAKE_LIB_DIR}/Toolchains.cmake)
unset(MYX_CMAKE_TOOLCHAINS_DIR)
include(${MYX_CMAKE_LIB_DIR}/AddExecutable.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddInterfaceLibrary.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddObjectLibrary.cmake)
include(${MYX_CMAKE_LIB_DIR}/TargetSetup.cmake)
include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
include(${MYX_CMAKE_LIB_DIR}/TargetSetupQt.cmake)
include(${MYX_CMAKE_LIB_DIR}/uncrustify/Uncrustify.cmake)
include(${MYX_CMAKE_LIB_DIR}/doc/Doxygen.cmake)

View File

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

View File

@@ -1,9 +0,0 @@
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS 3.21)
get_property(__parent_directory DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT __parent_directory)
set(PROJECT_IS_TOP_LEVEL true)
endif()
unset(__parent_directory)
endif()

View File

@@ -14,7 +14,7 @@ myx_add_executable
include_guard(GLOBAL)
function(myx_add_executable TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
if(${CMAKE_VERSION} VERSION_LESS 3.11.0)
add_executable(${TARGET_NAME} ${ARGN} "")
else()
add_executable(${TARGET_NAME} ${ARGN})

View File

@@ -1,79 +0,0 @@
#[=======================================================================[.rst:
myx_add_external_target
-----------------------
Функция для подключения целей из внешних проектов::
myx_add_external_target(TARGET_NAME
[ MODULES_PATH modules_path ] |
[ GIT_REPOSITORY url ] |
[ GIT_TAG tag ] |
[ LOCAL_PATH local_path ] )
Обязательный параметр: `TARGET_NAME` - имя цели, содержащейся во внешнем проекте.
Параметр `MODULES_PATH` содержит имя каталога, в который будут загружаться
внешние проекты (по умлолчанию `modules`). Параметр `GIT_REPOSITORY` содержит
адрес внешнего проекта, который нужно загрузить с помощью git. Параметр `GIT_TAG`
содержит используемые метку, идентификатор коммита или ветку в репозитории.
Параметр `LOCAL_PATH` используется для указания пути к подкаталогу, находящемуся
вне текущего проекта. Его следует указывать только при вызове функции из
вспомогательного файла `external_targets.cmake`.
#]=======================================================================]
find_package(Git)
function(myx_add_external_target TARGET_NAME)
set(options)
set(oneValueArgs)
set(multiValueArgs MODULES_PATH GIT_REPOSITORY GIT_TAG LOCAL_PATH)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(TARGET ${TARGET_NAME})
return()
endif()
if(ARG_LOCAL_PATH)
myx_message_notice("Using directory ${ARG_LOCAL_PATH} to build target ${TARGET_NAME}")
add_subdirectory(${ARG_LOCAL_PATH} ${CMAKE_BINARY_DIR}/${TARGET_NAME} EXCLUDE_FROM_ALL)
return()
endif()
if(NOT ARG_MODULES_PATH)
set(ARG_MODULES_PATH modules)
endif()
if(CMAKE_SCRIPT_MODE_FILE)
set(PROJECT_SOURCE_DIR ${CMAKE_SOURCE_DIR})
endif()
set(ARG_MODULES_PATH ${PROJECT_SOURCE_DIR}/${ARG_MODULES_PATH})
if(NOT IS_DIRECTORY ${ARG_MODULES_PATH})
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_MODULES_PATH})
endif()
if(GIT_EXECUTABLE)
if(NOT IS_DIRECTORY ${ARG_MODULES_PATH}/${TARGET_NAME})
execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ARG_GIT_REPOSITORY} ${TARGET_NAME}
WORKING_DIRECTORY ${ARG_MODULES_PATH})
else()
execute_process(COMMAND ${GIT_EXECUTABLE} fetch
WORKING_DIRECTORY ${ARG_MODULES_PATH}/${TARGET_NAME})
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${ARG_GIT_TAG}
WORKING_DIRECTORY ${ARG_MODULES_PATH}/${TARGET_NAME})
endif()
if(NOT CMAKE_SCRIPT_MODE_FILE)
add_subdirectory(${ARG_MODULES_PATH}/${TARGET_NAME} EXCLUDE_FROM_ALL)
endif()
if(NOT TARGET ${TARGET_NAME})
myx_message_fatal_error("Target ${TARGET_NAME} is not found.")
endif()
endfunction(myx_add_external_target)
include("${PROJECT_SOURCE_DIR}/external_targets.cmake" OPTIONAL)

View File

@@ -8,14 +8,10 @@ myx_add_interface_library
[ PACKAGES packages ] |
[ LINK_LIBRARIES link_libraries ] |
[ OUTPUT_NAME output_name ] |
[ EXPORT_FILE_NAME file_name ] |
[ EXPORT_BASE_NAME base_name ] |
[ HEADERS headers ])
Обязательные параметры: `TARGET_NAME` - имя библиотеки.
Параметр `OUTPUT_NAME` определяет базовое имя выходных файлов.
Параметр `EXPORT_FILE_NAME` задаёт имя заголовочного файла экспортируемых
переменных, а `EXPORT_BASE_NAME` - базовый суффикс для формирования имён переменных.
Все остальные параметры передаются в стандартную функцию `add_library()`
#]=======================================================================]
@@ -23,14 +19,13 @@ myx_add_interface_library
include_guard(GLOBAL)
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17)
set(MYX_CMAKE_LIB_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
function(myx_add_interface_library TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17)
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT})
endif()
@@ -48,42 +43,65 @@ function(myx_add_interface_library TARGET_NAME)
endif()
# Вызов стандартной функции `add_library()`
if(${CMAKE_VERSION} VERSION_LESS "3.19.0")
if(${CMAKE_VERSION} VERSION_LESS 3.19)
add_library(${TARGET_NAME} INTERFACE)
target_sources(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${ARG_HEADERS}>)
else()
add_library(${TARGET_NAME} INTERFACE ${ARG_HEADERS})
endif()
foreach(__iter ${ARG_PACKAGES})
target_include_directories(${TARGET_NAME} INTERFACE ${${__iter}_INCLUDE_DIRS})
target_compile_definitions(${TARGET_NAME} INTERFACE ${${__iter}_COMPILE_DEFINITIONS})
foreach(iter ${ARG_PACKAGES})
target_include_directories(${TARGET_NAME} INTERFACE ${${iter}_INCLUDE_DIRS})
target_compile_definitions(${TARGET_NAME} INTERFACE ${${iter}_COMPILE_DEFINITIONS})
endforeach()
if(ARG_LINK_LIBRARIES)
target_link_libraries(${TARGET_NAME} INTERFACE ${ARG_LINK_LIBRARIES})
if(${CMAKE_VERSION} VERSION_GREATER "3.15.0")
foreach(__lib ${ARG_LINK_LIBRARIES})
if(TARGET ${__lib})
install(
TARGETS ${__lib}
EXPORT ${TARGET_NAME}Targets
COMPONENT DEV)
foreach(lib ${ARG_LINK_LIBRARIES})
if(TARGET ${lib})
set(exlib ${lib})
get_target_property(type ${lib} TYPE)
if(type)
get_target_property(include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES)
if(include_dirs)
target_include_directories(${TARGET_NAME} INTERFACE ${include_dirs})
endif()
endif()
endforeach()
endif()
if(${CMAKE_VERSION} VERSION_GREATER 3.13)
install(TARGETS ${lib}
EXPORT ${TARGET_NAME}Targets
COMPONENT DEV)
else()
get_target_property(target_type ${lib} TYPE)
if(target_type STREQUAL "OBJECT_LIBRARY")
if(TARGET "${lib}_static")
set(exlib "${lib}_static")
elseif(TARGET "${lib}_shared")
set(exlib "${lib}_shared")
endif()
endif()
endif()
target_link_libraries(${TARGET_NAME} INTERFACE ${exlib})
endif()
endforeach()
endif()
# Библиотека, состоящая только из заголовочных файлов не требует сборки.
# Стандартные пути к заголовочным файлам
target_include_directories(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_include_directories(${TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Если вызов был выполнен не из проекта верхнего уровня,
# то созданная цель исключается из цели `all`.
# При этом сама цель `${TARGET_NAME}` может участвовать в сборке,
# если окажется в перечне зависимостей.
if(NOT PROJECT_IS_TOP_LEVEL)
set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL True)
if(${CMAKE_VERSION} VERSION_GREATER 3.17)
set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL True)
else()
set_target_properties(${TARGET_NAME} PROPERTIES INTERFACE_EXCLUDE_FROM_ALL True)
endif()
return()
endif()
@@ -104,9 +122,12 @@ function(myx_add_interface_library TARGET_NAME)
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(EXPORT ${TARGET_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
COMPONENT DEV)
if(${CMAKE_VERSION} VERSION_GREATER 3.13)
install(
EXPORT ${TARGET_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
COMPONENT DEV)
endif()
install(
FILES
@@ -136,10 +157,12 @@ function(myx_add_interface_library TARGET_NAME)
# Установка библиотеки из заголовочных файлов
target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(
TARGETS ${TARGET_NAME}
EXPORT ${TARGET_NAME}Targets
COMPONENT DEV)
if(${CMAKE_VERSION} VERSION_GREATER 3.13)
install(
TARGETS ${TARGET_NAME}
EXPORT ${TARGET_NAME}Targets
COMPONENT DEV)
endif()
# Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS)

View File

@@ -6,11 +6,13 @@ myx_add_object_library
myx_add_object_library(TARGET_NAME
[ OUTPUT_NAME output_name ] |
[ NO_EXPORT ] |
[ EXPORT_FILE_NAME file_name ] |
[ EXPORT_BASE_NAME base_name ])
Обязательные параметры: `TARGET_NAME` - имя библиотеки.
Параметр `OUTPUT_NAME` определяет базовое имя выходных файлов.
Если указана опция `NO_EXPORT`, то файл экспорта не генерируется.
Параметр `EXPORT_FILE_NAME` задаёт имя заголовочного файла экспортируемых
переменных, а `EXPORT_BASE_NAME` - базовый суффикс для формирования имён переменных.
Все остальные параметры передаются в стандартную функцию `add_library()`
@@ -19,19 +21,18 @@ myx_add_object_library
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17)
set(MYX_CMAKE_LIB_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
function(myx_add_object_library TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17)
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT})
endif()
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
set(options)
set(options NO_EXPORT)
set(oneValueArgs OUTPUT_NAME EXPORT_FILE_NAME EXPORT_BASE_NAME)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -43,12 +44,12 @@ function(myx_add_object_library TARGET_NAME)
# Вызов стандартной функции `add_library()`
add_library(${TARGET_NAME} OBJECT ${ARG_UNPARSED_ARGUMENTS})
string(TOUPPER ${TARGET_NAME} __project_name_upper)
string(TOUPPER ${TARGET_NAME} project_name_upper)
# Опция для разрешения сборки динамической библиотеки
cmake_dependent_option(${__project_name_upper}_BUILD_SHARED
cmake_dependent_option(${project_name_upper}_BUILD_SHARED
"Build shared library for ${TARGET_NAME}" ON "BUILD_SHARED_LIBS" OFF)
# Опция для разрешения сборки статической библиотеки
cmake_dependent_option(${__project_name_upper}_BUILD_STATIC
cmake_dependent_option(${project_name_upper}_BUILD_STATIC
"Build static library for ${TARGET_NAME}" ON "NOT BUILD_SHARED_LIBS" OFF)
# Стандартные пути к заголовочным файлам
@@ -64,28 +65,31 @@ function(myx_add_object_library TARGET_NAME)
# для создания динамической библиотеки
set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(NOT EXPORT_BASE_NAME)
set(ARG_EXPORT_BASE_NAME ${__project_name_upper})
endif()
if(NOT ARG_NO_EXPORT)
include(GenerateExportHeader)
if(NOT EXPORT_BASE_NAME)
set(ARG_EXPORT_BASE_NAME ${project_name_upper})
endif()
if(NOT ARG_EXPORT_FILE_NAME)
set(ARG_EXPORT_FILE_NAME "${PROJECT_SOURCE_DIR}/include/${TARGET_NAME}/${TARGET_NAME}_export.hpp")
endif()
if(NOT ARG_EXPORT_FILE_NAME)
set(ARG_EXPORT_FILE_NAME "${PROJECT_SOURCE_DIR}/include/${TARGET_NAME}/${TARGET_NAME}_export.hpp")
endif()
generate_export_header(${TARGET_NAME}
BASE_NAME ${ARG_EXPORT_BASE_NAME}
EXPORT_MACRO_NAME "EXPORT_${ARG_EXPORT_BASE_NAME}"
DEPRECATED_MACRO_NAME "DEPRECATED_${ARG_EXPORT_BASE_NAME}"
NO_DEPRECATED_MACRO_NAME "NO_DEPRECATED_${ARG_EXPORT_BASE_NAME}"
NO_EXPORT_MACRO_NAME "NO_EXPORT_${ARG_EXPORT_BASE_NAME}"
STATIC_DEFINE "STATIC_DEFINE_${ARG_EXPORT_BASE_NAME}"
EXPORT_FILE_NAME ${ARG_EXPORT_FILE_NAME}
DEFINE_NO_DEPRECATED
)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY INTERFACE_HEADER_FILES "${ARG_EXPORT_FILE_NAME}")
generate_export_header(${TARGET_NAME}
BASE_NAME ${ARG_EXPORT_BASE_NAME}
EXPORT_MACRO_NAME "EXPORT_${ARG_EXPORT_BASE_NAME}"
DEPRECATED_MACRO_NAME "DEPRECATED_${ARG_EXPORT_BASE_NAME}"
NO_DEPRECATED_MACRO_NAME "NO_DEPRECATED_${ARG_EXPORT_BASE_NAME}"
NO_EXPORT_MACRO_NAME "NO_EXPORT_${ARG_EXPORT_BASE_NAME}"
STATIC_DEFINE "STATIC_DEFINE_${ARG_EXPORT_BASE_NAME}"
EXPORT_FILE_NAME ${ARG_EXPORT_FILE_NAME}
DEFINE_NO_DEPRECATED
)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY INTERFACE_HEADER_FILES "${ARG_EXPORT_FILE_NAME}")
endif()
# Цель для создания динамической библиотеки из объектных файлов
if(${__project_name_upper}_BUILD_SHARED)
if(${project_name_upper}_BUILD_SHARED)
# Для создания динамической библиотеки используются объектные файлы цели ${TARGET_NAME}
add_library(${TARGET_NAME}_shared SHARED $<TARGET_OBJECTS:${TARGET_NAME}>)
# Установка дополнительных свойств для цели ${TARGET_NAME}_shared
@@ -101,7 +105,7 @@ function(myx_add_object_library TARGET_NAME)
endif()
# Цель для создания статической библиотеки из объектных файлов
if(${__project_name_upper}_BUILD_STATIC)
if(${project_name_upper}_BUILD_STATIC)
# Для создания статической библиотеки используются
# объектные файлы цели ${TARGET_NAME}
add_library(${TARGET_NAME}_static STATIC $<TARGET_OBJECTS:${TARGET_NAME}>)

View File

@@ -1,13 +1,13 @@
#[=======================================================================[.rst:
Обёртки для функции `message()`, которые в терминале UNIX
подсвечиают сообщения в зависимости от важности.
подсвечивают сообщения в зависимости от важности.
#]=======================================================================]
include_guard(GLOBAL)
if(DEFINED ENV{TERM} AND UNIX)
if(DEFINED ENV{COLORTERM} AND UNIX)
string(ASCII 27 Esc)
set(MyxColorReset "${Esc}[m")
set(MyxColorBold "${Esc}[1m")

View File

@@ -0,0 +1,95 @@
#[=======================================================================[.rst:
myx_download_content
-----------------------
Функция для загрузки дополнительных репозиториев::
myx_download_content(NAME
[ DOWNLOAD_DIR dir ] |
[ GIT_REPOSITORY url ] |
[ GIT_TAG tag ] |
[ AUTOFETCH ] | [ AUTOPULL ] )
Обязательный параметр: `NAME` - имя целевого каталога.
Параметр `DOWNLOAD_DIR` содержит имя каталога, в который будет загружаться
содержимое (по умолчанию `_downloads`).
Параметр `GIT_REPOSITORY` содержит адрес внешнего проекта, который нужно
загрузить с помощью git.
Параметр `GIT_TAG` содержит используемые метку, идентификатор коммита или
ветку в загружаемом репозитории.
Если указана опция `AUTOFETCH`, то на этапе конфигурирования для загруженного
репозитория будут скачиваться изменения.
Если указана опция `AUTOPULL`, то на этапе конфигурирования из загруженного
репозитория будет изменяться рабочий каталог.
#]=======================================================================]
find_package(Git QUIET)
option(ENABLE_DOWNLOAD_CONTENT "Enable download content" ON)
if(CMAKE_SCRIPT_MODE_FILE)
include(${CMAKE_CURRENT_LIST_DIR}/ProjectIsTopLevel.cmake)
endif()
function(myx_download_content NAME)
set(options AUTOFETCH AUTOPULL)
set(oneValueArgs)
set(multiValueArgs DOWNLOAD_DIR GIT_REPOSITORY GIT_TAG)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT CMAKE_SCRIPT_MODE_FILE)
if(TARGET myx-download-${NAME})
return()
else()
add_custom_target(myx-download-${NAME})
endif()
if(NOT TARGET myx-download-content)
add_custom_target(myx-download-content)
endif()
endif()
if(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()
if(NOT ARG_DOWNLOAD_DIR)
set(ARG_DOWNLOAD_DIR "_downloads")
endif()
if(CMAKE_SCRIPT_MODE_FILE)
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
set(ARG_DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/${ARG_DOWNLOAD_DIR})
if(NOT IS_DIRECTORY ${ARG_DOWNLOAD_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DOWNLOAD_DIR})
endif()
set(WORK_DIR "${ARG_DOWNLOAD_DIR}/${NAME}")
if(ENABLE_DOWNLOAD_CONTENT AND GIT_EXECUTABLE AND ARG_GIT_REPOSITORY)
if(NOT IS_DIRECTORY ${WORK_DIR})
execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ARG_GIT_REPOSITORY} ${NAME}
WORKING_DIRECTORY ${ARG_DOWNLOAD_DIR})
else()
if(ARG_AUTOFETCH)
execute_process(COMMAND ${GIT_EXECUTABLE} fetch
WORKING_DIRECTORY ${WORK_DIR})
endif()
endif()
if(ARG_GIT_TAG)
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${ARG_GIT_TAG}
WORKING_DIRECTORY ${WORK_DIR})
else()
if(ARG_AUTOPULL)
execute_process(COMMAND ${GIT_EXECUTABLE} pull
WORKING_DIRECTORY ${WORK_DIR})
endif()
endif()
endif()
if(NOT CMAKE_SCRIPT_MODE_FILE AND EXISTS "${WORK_DIR}/CMakeLists.txt")
add_subdirectory(${WORK_DIR} EXCLUDE_FROM_ALL)
endif()
endfunction()

View File

@@ -1,56 +0,0 @@
#[=======================================================================[.rst:
FetchContent_Add
----------------
Вспомогательная функция для `FetchContent_Declare()`::
FetchContent_Add(NAME
[ GIT_REPOSITORY repo ] |
[ GIT_REMOTE remote ] |
[ GIT_PATH path ])
Обязательные параметры: `NAME` - идентификатор загружаемого ресурса.
Параметр `GIT_REPOSITORY` определяет имя репозитория по умолчанию.
Если указана пара параметров `GIT_REMOTE` и `GIT_PATH` и у git-репозитория
основного проекта указан удалённый репозиторий с именем, определяемым
переменной `GIT_REMOTE`, то адрес репозитория для получения проекта
изменяется. В этом случае загрузка будет производиться с сервера,
определяемого из адреса с меткой `GIT_REMOTE`, и по пути `GIT_PATH`.
#]=======================================================================]
include_guard(GLOBAL)
# Обязательно в глобальной области
find_package(Git)
function(FetchContent_Add TARGET_NAME)
set(options "")
set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(GIT_FOUND AND ARG_GIT_REMOTE AND ARG_GIT_PATH)
execute_process(COMMAND ${GIT_EXECUTABLE} config --get remote.${ARG_GIT_REMOTE}.url OUTPUT_VARIABLE REMOTE_URL ERROR_QUIET)
if(REMOTE_URL)
string(REGEX REPLACE ":.*" "" SERVER ${REMOTE_URL})
string(FIND ${SERVER} "http" POS)
if(NOT POS EQUAL 0)
if(NOT SERVER STREQUAL REMOTE_URL)
set(ARG_GIT_REPOSITORY "${SERVER}:${ARG_GIT_PATH}")
endif()
endif()
endif()
endif()
FetchContent_Declare(
${TARGET_NAME}
${ARG_UNPARSED_ARGUMENTS}
GIT_REPOSITORY ${ARG_GIT_REPOSITORY}
GIT_SHALLOW 1
)
set(FETCHCONTENT_QUIET off)
FetchContent_MakeAvailable(${TARGET_NAME})
endfunction()

View File

@@ -1,8 +1,7 @@
# Версии CMake, как минимум до 3.8.0, генерируют некорректные
# правила для ninja.
# Версии CMake, как минимум до 3.8, генерируют некорректные правила для ninja.
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.8.0" AND CMAKE_GENERATOR MATCHES Ninja)
if(${CMAKE_VERSION} VERSION_LESS 3.8 AND CMAKE_GENERATOR MATCHES Ninja)
myx_message_send_error("Myx: Old CMake versions should use Makefile generator")
endif()

View File

@@ -0,0 +1,15 @@
include_guard(GLOBAL)
# Установка переменной, определяющей находится ли текущий
# проект на верхнем уровне.
# (Файл перемещён из каталога backports в lib для myx_download_content)
#
if(${CMAKE_VERSION} VERSION_LESS 3.21)
get_property(pd DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT pd)
set(PROJECT_IS_TOP_LEVEL TRUE)
else()
set(PROJECT_IS_TOP_LEVEL FALSE)
endif()
unset(pd)
endif()

View File

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

View File

@@ -3,7 +3,8 @@ include_guard(GLOBAL)
function(myx_target_setup TARGET_NAME)
set(options)
set(oneValueArgs PCH)
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
set(multiValueArgs PACKAGES
COMPILE_DEFINITIONS INCLUDE_DIRECTORIES LINK_LIBRARIES
CPP PUBLIC_HEADERS PRIVATE_HEADERS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -11,8 +12,8 @@ function(myx_target_setup TARGET_NAME)
myx_message_fatal_error("Target ${TARGET_NAME} does not exists.")
endif()
get_target_property(__target_type ${TARGET_NAME} TYPE)
if(${__target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
myx_message_fatal_error("This function will not work for interface targets.")
endif()
@@ -53,7 +54,7 @@ function(myx_target_setup TARGET_NAME)
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
endif()
if(__target_type STREQUAL "EXECUTABLE")
if(target_type STREQUAL "EXECUTABLE")
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
@@ -74,40 +75,49 @@ function(myx_target_setup TARGET_NAME)
install(TARGETS ${TARGET_NAME} COMPONENT MAIN RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
target_sources(${TARGET_NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
target_sources(${TARGET_NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
target_sources(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
if(${CMAKE_VERSION} VERSION_LESS "3.11.99")
target_sources(${TARGET_NAME} PRIVATE $<BUILD_INTERFACE:${ARG_PUBLIC_HEADERS}>)
target_sources(${TARGET_NAME} PRIVATE $<BUILD_INTERFACE:${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS}>)
else()
target_sources(${TARGET_NAME} PRIVATE ${ARG_PUBLIC_HEADERS})
target_sources(${TARGET_NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
endif()
target_compile_definitions(${TARGET_NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
target_include_directories(${TARGET_NAME} PRIVATE ${ARG_INCLUDE_DIRECTORIES})
# CMake до версии 3.12 не умеет извлекать из целей типа `OBJECT_LIBRARY`
# информацию о заголовочных файлах. Это обход.
if(${CMAKE_VERSION} VERSION_GREATER "3.11.99")
target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
else()
if((NOT ${__target_type} STREQUAL "OBJECT_LIBRARY") AND
(NOT ${__target_type} STREQUAL "EXECUTABLE"))
if((NOT ${target_type} STREQUAL "OBJECT_LIBRARY") AND
(NOT ${target_type} STREQUAL "EXECUTABLE"))
target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
else()
foreach(__link_library ${ARG_LINK_LIBRARIES})
if(TARGET ${__link_library})
get_target_property(__lib_type ${__link_library} TYPE)
if(__lib_type)
get_target_property(__include_dirs ${__link_library} INTERFACE_INCLUDE_DIRECTORIES)
if(__include_dirs)
target_include_directories(${TARGET_NAME} PUBLIC ${__include_dirs})
foreach(link_library ${ARG_LINK_LIBRARIES})
if(TARGET ${link_library})
get_target_property(library_type ${link_library} TYPE)
if(library_type)
get_target_property(include_dirs ${link_library} INTERFACE_INCLUDE_DIRECTORIES)
if(include_dirs)
target_include_directories(${TARGET_NAME} PUBLIC ${include_dirs})
endif()
if(${__target_type} STREQUAL "EXECUTABLE")
if(${__lib_type} STREQUAL "OBJECT_LIBRARY")
if(TARGET ${__link_library}_static)
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_static)
if(${target_type} STREQUAL "EXECUTABLE")
if(${library_type} STREQUAL "OBJECT_LIBRARY")
if(TARGET ${link_library}_static)
target_link_libraries(${TARGET_NAME} PRIVATE ${link_library}_static)
else()
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_shared)
endif()
target_link_libraries(${TARGET_NAME} PRIVATE ${link_library}_shared)
endif()
else()
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library})
target_link_libraries(${TARGET_NAME} PRIVATE ${link_library})
endif()
endif()
endif()
else()
if((${CMAKE_VERSION} VERSION_GREATER "3.7.99") OR (NOT target_type STREQUAL "OBJECT_LIBRARY"))
target_link_libraries(${TARGET_NAME} PRIVATE ${link_library})
endif()
endif()
endforeach()
endif()

View File

@@ -0,0 +1,155 @@
include_guard(GLOBAL)
function(myx_target_setup_qt TARGET_NAME)
set(options)
set(oneValueArgs)
set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(myx_qt_ver "5")
if(QT_DEFAULT_MAJOR_VERSION)
set(myx_qt_ver "${QT_DEFAULT_MAJOR_VERSION}")
endif()
if(NOT (myx_qt_ver STREQUAL "5" OR myx_qt_ver STREQUAL "6"))
myx_message_fatal_error("Supported Qt versions are 5 and 6")
endif()
get_target_property(target_type ${TARGET_NAME} TYPE)
foreach(iter ${ARG_COMPONENTS})
if(target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${TARGET_NAME} INTERFACE ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS})
else()
target_include_directories(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS})
if(NOT iter STREQUAL "LinguistTools")
if(target_type STREQUAL "EXECUTABLE")
target_link_libraries(${TARGET_NAME} PRIVATE Qt${myx_qt_ver}::${iter})
endif()
if(target_type STREQUAL "SHARED_LIBRARY")
target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter})
endif()
if((${CMAKE_VERSION} VERSION_GREATER 3.8.0) AND (target_type STREQUAL "OBJECT_LIBRARY"))
target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter})
else()
target_include_directories(${TARGET_NAME} PUBLIC ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS})
endif()
endif()
endif()
endforeach()
foreach(iter ${ARG_PRIVATE})
if(target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${TARGET_NAME} INTERFACE ${Qt${myx_qt_ver}${iter}_PRIVATE_INCLUDE_DIRS})
else()
target_include_directories(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}${iter}_PRIVATE_INCLUDE_DIRS})
endif()
endforeach()
if(target_type STREQUAL "EXECUTABLE")
target_compile_options(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}Core_EXECUTABLE_COMPILE_FLAGS})
endif()
if(ARG_PUBLIC_MOC)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC})
endif()
if(ARG_PRIVATE_MOC)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC})
endif()
if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
if(myx_qt_ver EQUAL 5)
qt5_wrap_cpp(moc_cpp ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC})
elseif(myx_qt_ver EQUAL 6)
qt6_wrap_cpp(moc_cpp ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC})
endif()
endif()
if(ARG_QRC)
if(myx_qt_ver EQUAL 5)
qt5_add_resources(qrc_cpp ${ARG_QRC})
elseif(myx_qt_ver EQUAL 6)
qt6_add_resources(qrc_cpp ${ARG_QRC})
endif()
endif()
if(ARG_UI)
if(NOT COMMAND qt${myx_qt_ver}_wrap_ui)
message(WARNING "MyxCMake: Widgets is required to process UI")
else()
if(myx_qt_ver EQUAL 5)
qt5_wrap_ui(ui_h ${ARG_UI})
elseif(myx_qt_ver EQUAL 6)
qt6_wrap_ui(ui_h ${ARG_UI})
endif()
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_UI})
target_link_libraries(${TARGET_NAME} PRIVATE Qt${myx_qt_ver}::Widgets)
# TODO
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
endif()
endif()
# Перечень файлов, подлежащих переводу
if(target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(tr ${TARGET_NAME} INTERFACE_TR_FILES)
else()
get_target_property(tr ${TARGET_NAME} TR_FILES)
endif()
# Формирование файла ресурсов с переводами
if(tr AND ARG_LANGS)
if(NOT COMMAND qt${myx_qt_ver}_create_translation)
message(WARNING "MyxCMake: LinguistTools is required to process LANGS")
else()
# Заглавие файла ресурсов
file(WRITE ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "<RCC><qresource prefix=\"/l10n\">\n")
# Для каждого языка, указанное в параметре LANGS
foreach(iter ${ARG_LANGS})
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
if(myx_qt_ver EQUAL 5)
qt5_create_translation(qm ${tr}
"${PROJECT_SOURCE_DIR}/l10n/${TARGET_NAME}_${iter}.ts"
OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME})
elseif(myx_qt_ver EQUAL 6)
qt6_create_translation(qm ${tr}
"${PROJECT_SOURCE_DIR}/l10n/${TARGET_NAME}_${iter}.ts"
OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME})
endif()
# Добавление записи для скомпилированного файла переводов в ресурсный файл
file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc
"<file alias=\"${TARGET_NAME}_${iter}.qm\">${TARGET_NAME}_${iter}.qm</file>\n")
# Добавление скомпилированного файла переводов к списку зависимостей для цели
target_sources(${TARGET_NAME} PRIVATE ${qm})
endforeach()
# Окончание файла ресурсов
file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "</qresource></RCC>\n")
# Компиляция файла ресурсов с переводами
if(myx_qt_ver EQUAL 5)
qt5_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc)
elseif(myx_qt_ver EQUAL 6)
qt6_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc)
endif()
target_sources(${TARGET_NAME} PRIVATE ${qrc_l10n})
endif()
endif()
unset(tr)
if(target_type STREQUAL "INTERFACE_LIBRARY")
target_sources(${TARGET_NAME} INTERFACE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
else()
target_sources(${TARGET_NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
endif()
# Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL)
myx_install_relative(${PROJECT_SOURCE_DIR}
FILES ${ARG_PUBLIC_MOC}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT DEV
)
endif()
endfunction()

View File

@@ -34,23 +34,38 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
include("${MYX_CMAKE_TOOLCHAINS_DIR}/GCC.cmake")
if(CMAKE_COLOR_MAKEFILE)
check_enable_cxx_compiler_flag(-fdiagnostics-color=auto)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include("${MYX_CMAKE_TOOLCHAINS_DIR}/Clang.cmake")
if(CMAKE_COLOR_MAKEFILE)
check_enable_cxx_compiler_flag(-fcolor-diagnostics)
endif()
endif()
if((MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE") AND
(MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk") AND
(MYX_CMAKE_LSB_RELEASE_VERSION STREQUAL "1.5"))
include("${MYX_CMAKE_TOOLCHAINS_DIR}/AstraLinuxSE-1.5.cmake")
return()
find_program(CMAKE_AR NAMES "/usr/bin/x86_64-linux-gnu-gcc-ar-4.7")
find_program(CMAKE_NM NAMES "/usr/bin/x86_64-linux-gnu-gcc-nm-4.7")
find_program(CMAKE_RANLIB NAMES "/usr/bin/x86_64-linux-gnu-gcc-ranlib-4.7")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS ON)
check_enable_cxx_compiler_flag(-Wno-shadow)
endif()
if((MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "ElbrusD") AND
(MYX_CMAKE_LSB_CODENAME STREQUAL "Jessie") AND
(MYX_CMAKE_LSB_RELEASE_VERSION VERSION_GREATER "1.4"))
include("${MYX_CMAKE_TOOLCHAINS_DIR}/ElbrusD-1.4.cmake")
return()
find_program(CMAKE_AR NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ar")
find_program(CMAKE_NM NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/nm")
find_program(CMAKE_RANLIB NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS ON)
check_enable_cxx_compiler_flag(-Wno-invalid-offsetof)
list(APPEND CMAKE_LIBRARY_PATH "/usr/lib/e2k-linux-gnu")
endif()

View File

@@ -1,9 +1,11 @@
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17)
set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
find_package(Doxygen QUIET)
function(myx_doc_doxygen TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17)
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT})
endif()
@@ -11,7 +13,6 @@ function(myx_doc_doxygen TARGET_NAME)
return()
endif()
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
set(DOXYGEN_EXECUTABLE "${DOXYGEN_EXECUTABLE}" CACHE STRING "Path to Doxygen executable")

View File

@@ -7,7 +7,7 @@ set(GIT_DIFF "")
set(GIT_TAG "N/A")
set(GIT_BRANCH "N/A")
find_package(Git)
find_package(Git QUIET)
if(GIT_EXECUTABLE)
execute_process(COMMAND ${GIT_EXECUTABLE} log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE GIT_REV ERROR_QUIET)

View File

@@ -17,12 +17,12 @@ myx_generate_git_info_header
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17.0)
set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
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})
endif()
@@ -31,26 +31,31 @@ function(myx_generate_git_info_header TARGET_NAME BASE_FILENAME)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
file(APPEND ${__filename} "")
set(filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
file(APPEND ${filename} "")
set(__prefix "")
set(prefix "")
if(ARG_PREFIX)
string(APPEND ARG_PREFIX "_")
string(REPLACE "-" "_" __prefix ${ARG_PREFIX})
string(REPLACE "-" "_" prefix ${ARG_PREFIX})
endif()
# cmake-format: off
if(NOT TARGET ${TARGET_NAME}-git-info-header)
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
BYPRODUCTS ${__filename}
BYPRODUCTS ${filename}
WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR})
endif()
# cmake-format: on
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
target_sources(${TARGET_NAME} PRIVATE ${__filename})
get_target_property(target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
target_sources(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${filename}>)
else()
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
target_sources(${TARGET_NAME} PRIVATE ${filename})
endif()
add_dependencies(${TARGET_NAME} ${TARGET_NAME}-git-info-header)
endfunction()

View File

@@ -14,12 +14,12 @@ myx_generate_private_config_header
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17.0)
set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
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})
endif()
@@ -27,9 +27,14 @@ function(myx_generate_private_config_header TARGET_NAME BASE_FILENAME)
myx_project_version_int()
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${__filename})
set(filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${filename})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
target_sources(${TARGET_NAME} PRIVATE ${__filename})
get_target_property(target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
target_sources(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${filename}>)
else()
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
target_sources(${TARGET_NAME} PRIVATE ${filename})
endif()
endfunction()

View File

@@ -27,8 +27,8 @@ macro(check_enable_cxx_compiler_flag FLAG)
endif()
unset(check_cxx_flag CACHE)
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
foreach(iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)

View File

@@ -3,7 +3,7 @@ include_guard(GLOBAL)
# Создание символических ссылок
macro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)
if(UNIX AND (NOT EXISTS ${LINKNAME}))
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
if(${CMAKE_VERSION} VERSION_LESS 3.14.0)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${ORIGINAL_FILENAME} ${LINKNAME})
else()

View File

@@ -1,34 +1,62 @@
#[=======================================================================[.rst:
myx_find_packages
-----------------
Вспомогательная функция для поиска зависимостей::
myx_find_packages()
Упрощённый способ поиска необходимых и опциональных зависимостей.
Для поиска зависимостей с учётом особенных требований (например, номер версии)
следует использовать функции `find_package` и `pkg_check_modules`.
Параметр `REQUIRED` содержит перечисление необходимых зависимостей
для поиска с помощью функции `find_package`.
Параметр `OPTIONAL` содержит перечисление опциональных зависимостей
для поиска с помощью функции `find_package`.
Параметр `PKG_REQUIRED` содержит перечисление необходимых зависимостей
для поиска с помощью функции `pkg_check_modules`.
Параметр `PKG_OPTIONAL` содержит перечисление опциональных зависимостей
для поиска с помощью функции `pkg_check_modules`.
#]=======================================================================]
include_guard(GLOBAL)
macro(myx_find_required_packages)
macro(myx_find_packages)
set(options)
set(oneValueArgs)
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private)
set(multiValueArgs REQUIRED OPTIONAL PKG_REQUIRED PKG_OPTIONAL)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(iter ${ARG_PACKAGES})
foreach(iter ${ARG_REQUIRED})
find_package(${iter} REQUIRED)
endforeach()
if(ARG_Boost)
find_package(Boost COMPONENTS ${ARG_Boost} REQUIRED)
endif()
foreach(iter ${ARG_OPTIONAL})
find_package(${iter})
endforeach()
if(ARG_Qt5)
find_package(Qt5 COMPONENTS ${ARG_Qt5} REQUIRED)
endif()
if(ARG_Qt5Private)
foreach(iter ${ARG_Qt5Private})
find_package("Qt5${iter}" COMPONENTS Private REQUIRED)
if(ARG_PKG_REQUIRED)
find_package(PkgConfig REQUIRED)
foreach(iter ${ARG_PKG_REQUIRED})
string(TOUPPER ${iter} iu)
pkg_check_modules(${iu} REQUIRED ${iter})
endforeach()
endif()
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
if(ARG_PKG_OPTIONAL)
find_package(PkgConfig REQUIRED)
foreach(iter ${ARG_PKG_OPTIONAL})
string(TOUPPER ${iter} iu)
pkg_check_modules(${iu} ${iter})
endforeach()
endif()
foreach(iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)
unset(oneValueArgs)
unset(options)
endmacro(myx_find_required_packages)
endmacro(myx_find_packages)

View File

@@ -0,0 +1,40 @@
include_guard(GLOBAL)
macro(myx_find_qt)
set(options REQUIRED)
set(oneValueArgs VERSION)
set(multiValueArgs COMPONENTS PRIVATE)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_VERSION)
set(ARG_VERSION "5")
if(QT_DEFAULT_MAJOR_VERSION)
set(ARG_VERSION "${QT_DEFAULT_MAJOR_VERSION}")
endif()
endif()
if(ARG_REQUIRED)
set(ARG_REQUIRED "REQUIRED")
endif()
if(NOT (ARG_VERSION STREQUAL "5" OR ARG_VERSION STREQUAL "6"))
message(FATAL_ERROR "Supported Qt versions are 5 and 6")
endif()
foreach(iter ${ARG_COMPONENTS})
find_package(Qt${ARG_VERSION} COMPONENTS ${iter} ${ARG_REQUIRED})
endforeach()
foreach(iter ${ARG_PRIVATE})
find_package("Qt${ARG_VERSION}${iter}" COMPONENTS Private ${ARG_REQUIRED})
endforeach()
foreach(iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)
unset(oneValueArgs)
unset(options)
endmacro()

View File

@@ -19,8 +19,8 @@ macro(myx_add_gtest TARGET_NAME)
endif()
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
foreach(iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)

View File

@@ -14,14 +14,14 @@ macro(myx_add_qtest TARGET_NAME)
foreach(filename ${ARG_UNPARSED_ARGUMENTS})
get_filename_component(basename ${filename} NAME_WE)
list(APPEND cpps "${basename}.cpp")
list(APPEND hpps "${basename}.hpp")
list(APPEND cpps "${CMAKE_CURRENT_SOURCE_DIR}/${basename}.cpp")
list(APPEND hpps "${CMAKE_CURRENT_SOURCE_DIR}/${basename}.hpp")
qt5_wrap_cpp(moc "${basename}.hpp")
list(APPEND mocs "${moc}")
endforeach()
add_executable(${TARGET_NAME} ${mocs} ${cpps} ${hpps})
target_link_libraries(${TARGET_NAME} Qt5::Core Qt5::Test)
target_link_libraries(${TARGET_NAME} PRIVATE Qt5::Core Qt5::Test)
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
@@ -29,8 +29,8 @@ macro(myx_add_qtest TARGET_NAME)
unset(hpps)
unset(moc)
unset(mocs)
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
foreach(iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)

View File

@@ -1,8 +0,0 @@
find_program(CMAKE_AR NAMES "/usr/bin/x86_64-linux-gnu-gcc-ar-4.7")
find_program(CMAKE_NM NAMES "/usr/bin/x86_64-linux-gnu-gcc-nm-4.7")
find_program(CMAKE_RANLIB NAMES "/usr/bin/x86_64-linux-gnu-gcc-ranlib-4.7")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS ON)
check_enable_cxx_compiler_flag(-Wno-shadow)

View File

@@ -1,3 +0,0 @@
if(CMAKE_COLOR_MAKEFILE)
check_enable_cxx_compiler_flag(-fcolor-diagnostics)
endif()

View File

@@ -1,9 +0,0 @@
find_program(CMAKE_AR NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ar")
find_program(CMAKE_NM NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/nm")
find_program(CMAKE_RANLIB NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS ON)
check_enable_cxx_compiler_flag(-Wno-invalid-offsetof)
list(APPEND CMAKE_LIBRARY_PATH "/usr/lib/e2k-linux-gnu")

View File

@@ -1,3 +0,0 @@
if(CMAKE_COLOR_MAKEFILE)
check_enable_cxx_compiler_flag(-fdiagnostics-color=auto)
endif()

View File

@@ -1,18 +1,14 @@
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
if(${CMAKE_VERSION} VERSION_LESS 3.17.0)
set(MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
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})
endif()
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
set(options)
set(oneValueArgs CONFIG)
set(multiValueArgs)
@@ -32,6 +28,12 @@ function(myx_uncrustify TARGET_NAME)
return()
endif()
get_filename_component(CONFIG_DIR ${ARG_CONFIG} DIRECTORY)
if(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CONFIG_DIR}")
myx_message("MyxCMake: skip uncrustify for project ${PROJECT_NAME}")
return()
endif()
if(NOT TARGET myx-uncrustify)
add_custom_target(myx-uncrustify)
endif()
@@ -43,51 +45,50 @@ function(myx_uncrustify TARGET_NAME)
endif()
# Динамически сгенерированные файлы исключаются
get_target_property(__target_type ${TARGET_NAME} TYPE)
if((${__target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS "3.17.0"))
get_target_property(__s1 ${TARGET_NAME} INTERFACE_SOURCES)
if(__s1)
list(APPEND __all_sources ${__s1})
get_target_property(target_type ${TARGET_NAME} TYPE)
if((${target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS 3.17.0))
get_target_property(target_sources ${TARGET_NAME} INTERFACE_SOURCES)
if(target_sources)
list(APPEND all_sources ${target_sources})
endif()
else()
get_target_property(__s2 ${TARGET_NAME} SOURCES)
if(__s2)
list(APPEND __all_sources ${__s2})
get_target_property(target_sources ${TARGET_NAME} SOURCES)
if(target_sources)
list(APPEND all_sources ${target_sources})
endif()
endif()
foreach(iter ${__all_sources})
foreach(iter ${all_sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND __sources ${iter})
list(APPEND sources ${iter})
endif()
endforeach()
target_sources(${TARGET_NAME} PRIVATE ${ARG_CONFIG})
set(__fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
add_custom_command(OUTPUT ${__fixed_config}
set(fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
add_custom_command(OUTPUT ${fixed_config}
DEPENDS ${ARG_CONFIG}
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
-c ${ARG_CONFIG} -o ${__fixed_config})
list(APPEND __options -c ${__fixed_config})
-c ${ARG_CONFIG} -o ${fixed_config})
list(APPEND options -c ${fixed_config})
# cmake-format: off
add_custom_target(${TARGET_NAME}-uncrustify-check
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${__sources})
DEPENDS ${fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${options} --check ${sources})
list(APPEND __options --replace --no-backup)
list(APPEND options --replace --no-backup)
add_custom_target(${TARGET_NAME}-uncrustify
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${__sources})
DEPENDS ${fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${options} --mtime ${sources})
add_custom_target(${TARGET_NAME}-uncrustify-append-comments
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options}
DEPENDS ${fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${options}
--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_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt
--set cmt_insert_func_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/funcheader.txt
--set cmt_insert_before_ctor_dtor=true --mtime ${__sources})
--set cmt_insert_before_ctor_dtor=true --mtime ${sources})
# cmake-format: on
add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)

View File

@@ -4,7 +4,7 @@
По умолчанию предполагается использование версии MyxCMake,
файлы которой находятся в каталоге `cmake/myx` текущего проекта.
Для удобства разботки библиотеки MyxCMake можно указать путь
Для удобства разработки библиотеки MyxCMake можно указать путь
к её репозиторию с помощью переменной проекта CMake `MYX_CMAKE_DIR`
или переменной окружения `MYX_CMAKE_DIR`.
@@ -12,7 +12,7 @@
поиск версии в каталогах перечисленных в переменной `CMAKE_MODULES_DIR`.
Кроме того выполняется попытка поиска (MyxxCMake)[../../../../myxx] --
расширения для библиотеки, позволяющиего в режиме разработки программного
расширения для библиотеки, позволяющего в режиме разработки программного
проекта использовать дополнительные инструменты для его сопровождения.
#]=======================================================================]
@@ -20,15 +20,15 @@ if(ENV{MYX_CMAKE_DIR})
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
endif()
if(MYX_CMAKE_DIR)
find_package(MyxCMake 2.3.1 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
find_package(MyxCMake 2.4.38 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.3.1 REQUIRED)
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
find_package(MyxCMake 2.4.38 REQUIRED)
myx_message_notice("== MyxCMake directory: ${MyxCMake_CONFIG} ==")
else()
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
myx_message_notice("=== MyxCMake directory: ${PROJECT_SOURCE_DIR}/cmake/myx ===")
myx_message_notice("== MyxCMake directory: ${PROJECT_SOURCE_DIR}/cmake/myx ==")
endif()
endif()

View File

@@ -0,0 +1,14 @@
# Подключение файла с функцией для загрузки содержимого
# командой cmake в режиме запуска скриптов. Пример команды:
#
# cmake -P myx_download_content.cmake
#
if(CMAKE_SCRIPT_MODE_FILE)
include("cmake/myx/lib/DownloadContent.cmake")
endif()
myx_download_content(myx-example-interface-library
GIT_REPOSITORY https://git.246060.ru/cmake/myx-example-interface-library)
myx_download_content(myx-example-object-library
GIT_REPOSITORY https://git.246060.ru/cmake/myx-example-object-library)

View File

@@ -1,4 +1,4 @@
# Uncrustify-0.75.0_f
# Uncrustify-0.78.0_f
#
# General options
@@ -99,6 +99,12 @@ sp_cpp_lambda_square_paren = remove # ignore/add/remove/force/not_defined
# no argument list is present, as in '[] <here> { ... }'.
sp_cpp_lambda_square_brace = ignore # ignore/add/remove/force/not_defined
# Add or remove space after the opening parenthesis and before the closing
# parenthesis of a argument list of a C++11 lambda, as in
# '[]( <here> ){ ... }'
# with an empty list.
sp_cpp_lambda_argument_list_empty = ignore # ignore/add/remove/force/not_defined
# Add or remove space after the opening parenthesis and before the closing
# parenthesis of a argument list of a C++11 lambda, as in
# '[]( <here> int x <here> ){ ... }'.
@@ -195,9 +201,36 @@ sp_before_ptr_star = remove # ignore/add/remove/force/not_defined
# variable name. If set to ignore, sp_before_ptr_star is used instead.
sp_before_unnamed_ptr_star = remove # ignore/add/remove/force/not_defined
# Add or remove space before pointer star '*' that is followed by a qualifier.
# If set to ignore, sp_before_unnamed_ptr_star is used instead.
sp_before_qualifier_ptr_star = ignore # ignore/add/remove/force/not_defined
# Add or remove space before pointer star '*' that is followed by 'operator' keyword.
# If set to ignore, sp_before_unnamed_ptr_star is used instead.
sp_before_operator_ptr_star = ignore # ignore/add/remove/force/not_defined
# Add or remove space before pointer star '*' that is followed by
# a class scope (as in 'int *MyClass::method()') or namespace scope
# (as in 'int *my_ns::func()').
# If set to ignore, sp_before_unnamed_ptr_star is used instead.
sp_before_scope_ptr_star = ignore # ignore/add/remove/force/not_defined
# Add or remove space before pointer star '*' that is followed by '::',
# as in 'int *::func()'.
# If set to ignore, sp_before_unnamed_ptr_star is used instead.
sp_before_global_scope_ptr_star = ignore # ignore/add/remove/force/not_defined
# Add or remove space between a qualifier and a pointer star '*' that isn't
# followed by a variable name, as in '(char const *)'. If set to ignore,
# sp_before_ptr_star is used instead.
sp_qualifier_unnamed_ptr_star = ignore # ignore/add/remove/force/not_defined
# Add or remove space between pointer stars '*', as in 'int ***a;'.
sp_between_ptr_star = remove # ignore/add/remove/force/not_defined
# Add or remove space between pointer star '*' and reference '&', as in 'int *& a;'.
sp_between_ptr_ref = ignore # ignore/add/remove/force/not_defined
# Add or remove space after pointer star '*', if followed by a word.
#
# Overrides sp_type_func.
@@ -232,13 +265,24 @@ sp_ptr_star_func_type = remove # ignore/add/remove/force/not_defined
sp_ptr_star_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a pointer star '*', if followed by a function
# prototype or function definition.
# prototype or function definition. If set to ignore, sp_before_ptr_star is
# used instead.
sp_before_ptr_star_func = remove # ignore/add/remove/force/not_defined
# Add or remove space between a qualifier and a pointer star '*' followed by
# the name of the function in a function prototype or definition, as in
# 'char const *foo()`. If set to ignore, sp_before_ptr_star is used instead.
sp_qualifier_ptr_star_func = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a pointer star '*' in the trailing return of a
# function prototype or function definition.
sp_before_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined
# Add or remove space between a qualifier and a pointer star '*' in the
# trailing return of a function prototype or function definition, as in
# 'auto foo() -> char const *'.
sp_qualifier_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a reference sign '&'.
sp_before_byref = remove # ignore/add/remove/force/not_defined
@@ -297,6 +341,7 @@ sp_before_angle = ignore # ignore/add/remove/force/not_defined
sp_inside_angle = force # ignore/add/remove/force/not_defined
# Add or remove space inside '<>'.
# if empty.
sp_inside_angle_empty = ignore # ignore/add/remove/force/not_defined
# Add or remove space between '>' and ':'.
@@ -392,11 +437,11 @@ sp_before_semi_for = remove # ignore/add/remove/force/not_defined
# Add or remove space before a semicolon of an empty left part of a for
# statement, as in 'for ( <here> ; ; )'.
sp_before_semi_for_empty = remove # ignore/add/remove/force/not_defined
sp_before_semi_for_empty = force # ignore/add/remove/force/not_defined
# Add or remove space between the semicolons of an empty middle part of a for
# statement, as in 'for ( ; <here> ; )'.
sp_between_semi_for_empty = remove # ignore/add/remove/force/not_defined
sp_between_semi_for_empty = force # ignore/add/remove/force/not_defined
# Add or remove space after ';', except when followed by a comment.
#
@@ -410,7 +455,7 @@ sp_after_semi_for = force # ignore/add/remove/force/not_defined
# Add or remove space after the final semicolon of an empty part of a for
# statement, as in 'for ( ; ; <here> )'.
sp_after_semi_for_empty = remove # ignore/add/remove/force/not_defined
sp_after_semi_for_empty = force # ignore/add/remove/force/not_defined
# Add or remove space before '[' (except '[]').
sp_before_square = ignore # ignore/add/remove/force/not_defined
@@ -433,6 +478,7 @@ sp_cpp_before_struct_binding = ignore # ignore/add/remove/force/not_defined
sp_inside_square = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside '[]'.
# if empty.
sp_inside_square_empty = remove # ignore/add/remove/force/not_defined
# (OC) Add or remove space inside a non-empty Objective-C boxed array '@[' and
@@ -447,15 +493,15 @@ sp_after_comma = force # ignore/add/remove/force/not_defined
# Default: remove
sp_before_comma = remove # ignore/add/remove/force/not_defined
# (C#) Add or remove space between ',' and ']' in multidimensional array type
# (C#, Vala) Add or remove space between ',' and ']' in multidimensional array type
# like 'int[,,]'.
sp_after_mdatype_commas = ignore # ignore/add/remove/force/not_defined
# (C#) Add or remove space between '[' and ',' in multidimensional array type
# (C#, Vala) Add or remove space between '[' and ',' in multidimensional array type
# like 'int[,,]'.
sp_before_mdatype_commas = ignore # ignore/add/remove/force/not_defined
# (C#) Add or remove space between ',' in multidimensional array type
# (C#, Vala) Add or remove space between ',' in multidimensional array type
# like 'int[,,]'.
sp_between_mdatype_commas = ignore # ignore/add/remove/force/not_defined
@@ -591,6 +637,7 @@ sp_inside_type_brace_init_lst = ignore # ignore/add/remove/force/not_defined
sp_inside_braces = force # ignore/add/remove/force/not_defined
# Add or remove space inside '{}'.
# if empty.
sp_inside_braces_empty = remove # ignore/add/remove/force/not_defined
# Add or remove space around trailing return operator '->'.
@@ -608,7 +655,7 @@ sp_type_brace_init_lst = ignore # ignore/add/remove/force/not_defined
sp_func_proto_paren = remove # ignore/add/remove/force/not_defined
# Add or remove space between function name and '()' on function declaration
# without parameters.
# if empty.
sp_func_proto_paren_empty = remove # ignore/add/remove/force/not_defined
# Add or remove space between function name and '(' with a typedef specifier.
@@ -618,7 +665,7 @@ sp_func_type_paren = ignore # ignore/add/remove/force/not_defined
sp_func_def_paren = remove # ignore/add/remove/force/not_defined
# Add or remove space between function name and '()' on function definition
# without parameters.
# if empty.
sp_func_def_paren_empty = remove # ignore/add/remove/force/not_defined
# Add or remove space inside empty function '()'.
@@ -628,6 +675,16 @@ sp_inside_fparens = remove # ignore/add/remove/force/not_defined
# Add or remove space inside function '(' and ')'.
sp_inside_fparen = force # ignore/add/remove/force/not_defined
# Add or remove space inside user functor '(' and ')'.
sp_func_call_user_inside_rparen = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside empty functor '()'.
# Overrides sp_after_angle unless use_sp_after_angle_always is set to true.
sp_inside_rparens = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside functor '(' and ')'.
sp_inside_rparen = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside the first parentheses in a function type, as in
# 'void (*x)(...)'.
sp_inside_tparen = ignore # ignore/add/remove/force/not_defined
@@ -744,10 +801,10 @@ sp_macro = ignore # ignore/add/remove/force/not_defined
sp_macro_func = ignore # ignore/add/remove/force/not_defined
# Add or remove space between 'else' and '{' if on the same line.
sp_else_brace = ignore # ignore/add/remove/force/not_defined
sp_else_brace = force # ignore/add/remove/force/not_defined
# Add or remove space between '}' and 'else' if on the same line.
sp_brace_else = ignore # ignore/add/remove/force/not_defined
sp_brace_else = force # ignore/add/remove/force/not_defined
# Add or remove space between '}' and the name of a typedef on the same line.
sp_brace_typedef = ignore # ignore/add/remove/force/not_defined
@@ -782,7 +839,7 @@ sp_getset_brace = ignore # ignore/add/remove/force/not_defined
# Add or remove space between a variable and '{' for C++ uniform
# initialization.
sp_word_brace_init_lst = force # ignore/add/remove/force/not_defined
sp_word_brace_init_lst = add # ignore/add/remove/force/not_defined
# Add or remove space between a variable and '{' for a namespace.
#
@@ -965,7 +1022,15 @@ sp_before_for_colon = remove # ignore/add/remove/force/not_defined
sp_extern_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space after the opening of a C++ comment, as in '// <here> A'.
sp_cmt_cpp_start = ignore # ignore/add/remove/force/not_defined
sp_cmt_cpp_start = add # ignore/add/remove/force/not_defined
# remove space after the '//' and the pvs command '-V1234',
# only works with sp_cmt_cpp_start set to add or force.
sp_cmt_cpp_pvs = true # true/false
# remove space after the '//' and the command 'lint',
# only works with sp_cmt_cpp_start set to add or force.
sp_cmt_cpp_lint = true # true/false
# Add or remove space in a C++ region marker comment, as in '// <here> BEGIN'.
# A region marker is defined as a comment which is not preceded by other text
@@ -995,7 +1060,7 @@ sp_between_new_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space between ')' and type in 'new(foo) BAR'.
sp_after_newop_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside parenthesis of the new operator
# Add or remove space inside parentheses of the new operator
# as in 'new(foo) BAR'.
sp_inside_newop_paren = ignore # ignore/add/remove/force/not_defined
@@ -1049,6 +1114,12 @@ sp_after_noexcept = ignore # ignore/add/remove/force/not_defined
# Add or remove space after '_'.
sp_vala_after_translation = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a bit colon ':'.
sp_before_bit_colon = force # ignore/add/remove/force/not_defined
# Add or remove space after a bit colon ':'.
sp_after_bit_colon = force # ignore/add/remove/force/not_defined
# If true, a <TAB> is inserted after #define.
force_tab_after_define = false # true/false
@@ -1537,7 +1608,7 @@ indent_using_block = true # true/false
# How to indent the continuation of ternary operator.
#
# 0: Off (default)
# 1: When the `if_false` is a continuation, indent it under `if_false`
# 1: When the `if_false` is a continuation, indent it under the `if_true` branch
# 2: When the `:` is a continuation, indent it under `?`
indent_ternary_operator = 2 # unsigned number
@@ -1565,9 +1636,14 @@ donot_indent_func_def_close_paren = false # true/false
# Newline adding and removing options
#
# Whether to collapse empty blocks between '{' and '}'.
# If true, overrides nl_inside_empty_func
nl_collapse_empty_body = false # true/false
# Whether to collapse empty blocks between '{' and '}' except for functions.
# Use nl_collapse_empty_body_functions to specify how empty function braces
# should be formatted.
nl_collapse_empty_body = true # true/false
# Whether to collapse empty blocks between '{' and '}' for functions only.
# If true, overrides nl_inside_empty_func.
nl_collapse_empty_body_functions = true # true/false
# Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'.
nl_assign_leave_one_liners = true # true/false
@@ -1656,7 +1732,7 @@ nl_after_square_assign = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between a function call's ')' and '{', as in
# 'list_for_each(item, &list) { }'.
nl_fcall_brace = add # ignore/add/remove/force/not_defined
nl_fcall_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'enum' and '{'.
nl_enum_brace = force # ignore/add/remove/force/not_defined
@@ -1680,17 +1756,17 @@ nl_struct_brace = force # ignore/add/remove/force/not_defined
nl_union_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'if' and '{'.
nl_if_brace = force # ignore/add/remove/force/not_defined
nl_if_brace = remove # ignore/add/remove/force/not_defined
# Add or remove newline between '}' and 'else'.
nl_brace_else = force # ignore/add/remove/force/not_defined
nl_brace_else = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'else if' and '{'. If set to ignore,
# nl_if_brace is used instead.
nl_elseif_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'else' and '{'.
nl_else_brace = force # ignore/add/remove/force/not_defined
nl_else_brace = remove # ignore/add/remove/force/not_defined
# Add or remove newline between 'else' and 'if'.
nl_else_if = force # ignore/add/remove/force/not_defined
@@ -1714,7 +1790,7 @@ nl_try_brace = ignore # ignore/add/remove/force/not_defined
nl_getset_brace = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'for' and '{'.
nl_for_brace = add # ignore/add/remove/force/not_defined
nl_for_brace = remove # ignore/add/remove/force/not_defined
# Add or remove newline before the '{' of a 'catch' statement, as in
# 'catch (decl) <here> {'.
@@ -1738,7 +1814,7 @@ nl_brace_square = ignore # ignore/add/remove/force/not_defined
nl_brace_fparen = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'while' and '{'.
nl_while_brace = add # ignore/add/remove/force/not_defined
nl_while_brace = remove # ignore/add/remove/force/not_defined
# (D) Add or remove newline between 'scope (x)' and '{'.
nl_scope_brace = ignore # ignore/add/remove/force/not_defined
@@ -1763,7 +1839,7 @@ nl_do_brace = ignore # ignore/add/remove/force/not_defined
nl_brace_while = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'switch' and '{'.
nl_switch_brace = add # ignore/add/remove/force/not_defined
nl_switch_brace = remove # ignore/add/remove/force/not_defined
# Add or remove newline between 'synchronized' and '{'.
nl_synchronized_brace = ignore # ignore/add/remove/force/not_defined
@@ -1862,7 +1938,7 @@ nl_template_var = ignore # ignore/add/remove/force/not_defined
nl_template_using = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'class' and '{'.
nl_class_brace = add # ignore/add/remove/force/not_defined
nl_class_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline before or after (depending on pos_class_comma,
# may not be IGNORE) each',' in the base class list.
@@ -2021,6 +2097,12 @@ nl_template_end = false # true/false
# See nl_oc_msg_leave_one_liner.
nl_oc_msg_args = false # true/false
# (OC) Minimum number of Objective-C message parameters before applying nl_oc_msg_args.
nl_oc_msg_args_min_params = 0 # unsigned number
# (OC) Max code width of Objective-C message before applying nl_oc_msg_args.
nl_oc_msg_args_max_code_width = 0 # unsigned number
# Add or remove newline between function signature and '{'.
nl_fdef_brace = add # ignore/add/remove/force/not_defined
@@ -2034,6 +2116,9 @@ nl_cpp_ldef_brace = remove # ignore/add/remove/force/not_defined
# Add or remove newline between 'return' and the return expression.
nl_return_expr = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'throw' and the throw expression.
nl_throw_expr = ignore # ignore/add/remove/force/not_defined
# Whether to add a newline after semicolons, except in 'for' statements.
nl_after_semicolon = false # true/false
@@ -2227,7 +2312,7 @@ nl_max_blank_in_func = 2 # unsigned number
# The number of newlines inside an empty function body.
# This option overrides eat_blanks_after_open_brace and
# eat_blanks_before_close_brace, but is ignored when
# nl_collapse_empty_body=true
# nl_collapse_empty_body_functions=true
nl_inside_empty_func = 0 # unsigned number
# The number of newlines before a function prototype.
@@ -2265,8 +2350,21 @@ nl_after_func_class_proto_group = 0 # unsigned number
nl_class_leave_one_liner_groups = false # true/false
# The number of newlines after '}' of a multi-line function body.
#
# Overrides nl_min_after_func_body and nl_max_after_func_body.
nl_after_func_body = 3 # unsigned number
# The minimum number of newlines after '}' of a multi-line function body.
#
# Only works when nl_after_func_body is 0.
nl_min_after_func_body = 0 # unsigned number
# The maximum number of newlines after '}' of a multi-line function body.
#
# Only works when nl_after_func_body is 0.
# Takes precedence over nl_min_after_func_body.
nl_max_after_func_body = 0 # unsigned number
# The number of newlines after '}' of a multi-line function body in a class
# declaration. Also affects class constructors/destructors.
#
@@ -2279,12 +2377,6 @@ nl_after_func_body_class = 2 # unsigned number
# Overrides nl_after_func_body and nl_after_func_body_class.
nl_after_func_body_one_liner = 0 # unsigned number
# The number of blank lines after a block of variable definitions at the top
# of a function body.
#
# 0: No change (default).
nl_func_var_def_blk = 1 # unsigned number
# The number of newlines before a block of typedefs. If nl_after_access_spec
# is non-zero, that option takes precedence.
#
@@ -2294,22 +2386,34 @@ nl_typedef_blk_start = 0 # unsigned number
# The number of newlines after a block of typedefs.
#
# 0: No change (default).
nl_typedef_blk_end = 1 # unsigned number
nl_typedef_blk_end = 0 # unsigned number
# The maximum number of consecutive newlines within a block of typedefs.
#
# 0: No change (default).
nl_typedef_blk_in = 0 # unsigned number
# The number of empty newlines before a block of variable definitions
# not at the top of a function body. If nl_after_access_spec is non-zero,
# that option takes precedence.
# The minimum number of blank lines after a block of variable definitions
# at the top of a function body. If any preprocessor directives appear
# between the opening brace of the function and the variable block, then
# it is considered as not at the top of the function.Newlines are added
# before trailing preprocessor directives, if any exist.
#
# 0: No change (default).
nl_var_def_blk_start = 1 # unsigned number
nl_var_def_blk_end_func_top = 0 # unsigned number
# The number of empty newlines after a block of variable definitions
# not at the top of a function body.
# The minimum number of empty newlines before a block of variable definitions
# not at the top of a function body. If nl_after_access_spec is non-zero,
# that option takes precedence. Newlines are not added at the top of the
# file or just after an opening brace. Newlines are added above any
# preprocessor directives before the block.
#
# 0: No change (default).
nl_var_def_blk_start = 0 # unsigned number
# The minimum number of empty newlines after a block of variable definitions
# not at the top of a function body. Newlines are not added if the block
# is at the bottom of the file or just before a preprocessor directive.
#
# 0: No change (default).
nl_var_def_blk_end = 0 # unsigned number
@@ -2625,11 +2729,6 @@ align_var_def_inline = false # true/false
# 0: Don't align (default).
align_assign_span = 1 # unsigned number
# The span for aligning on '{' in braced init list.
#
# 0: Don't align (default).
align_braced_init_list_span = 0 # unsigned number
# The span for aligning on '=' in function prototype modifier.
#
# 0: Don't align (default).
@@ -2646,6 +2745,11 @@ align_assign_thresh = 0 # number
# Depends on 'align_assign_span' and 'align_assign_thresh' settings.
align_assign_on_multi_var_defs = true # true/false
# The span for aligning on '{' in braced init list.
#
# 0: Don't align (default).
align_braced_init_list_span = 0 # unsigned number
# The threshold for aligning on '{' in braced init list.
# Use a negative number for absolute thresholds.
#
@@ -2764,6 +2868,13 @@ align_right_cmt_at_col = 1 # unsigned number
# 0: Don't align (default).
align_func_proto_span = 0 # unsigned number
# Whether to ignore continuation lines when evaluating the number of
# new lines for the function prototype alignment's span.
#
# false: continuation lines are part of the newlines count
# true: continuation lines are not counted
align_func_proto_span_ignore_cont_lines = false # true/false
# How to consider (or treat) the '*' in the alignment of function prototypes.
#
# 0: Part of the type 'void * foo();' (default)
@@ -2813,9 +2924,22 @@ align_single_line_brace_gap = 0 # unsigned number
# 0: Don't align (default).
align_oc_msg_spec_span = 0 # unsigned number
# Whether to align macros wrapped with a backslash and a newline. This will
# not work right if the macro contains a multi-line comment.
align_nl_cont = false # true/false
# Whether and how to align backslashes that split a macro onto multiple lines.
# This will not work right if the macro contains a multi-line comment.
#
# 0: Do nothing (default)
# 1: Align the backslashes in the column at the end of the longest line
# 2: Align with the backslash that is farthest to the left, or, if that
# backslash is farther left than the end of the longest line, at the end of
# the longest line
# 3: Align with the backslash that is farthest to the right
align_nl_cont = 0 # unsigned number
# The minimum number of spaces between the end of a line and its continuation
# backslash. Requires align_nl_cont.
#
# Default: 1
align_nl_cont_spaces = 1 # unsigned number
# Whether to align macro functions and variables together.
align_pp_define_together = false # true/false
@@ -3099,9 +3223,12 @@ mod_full_brace_nl = 0 # unsigned number
# mod_full_brace_function
mod_full_brace_nl_block_rem_mlcond = false # true/false
# Add or remove unnecessary parenthesis on 'return' statement.
# Add or remove unnecessary parentheses on 'return' statement.
mod_paren_on_return = add # ignore/add/remove/force/not_defined
# Add or remove unnecessary parentheses on 'throw' statement.
mod_paren_on_throw = ignore # ignore/add/remove/force/not_defined
# (Pawn) Whether to change optional semicolons to real semicolons.
mod_pawn_semicolon = false # true/false
@@ -3123,6 +3250,12 @@ mod_remove_extra_semicolon = true # true/false
# Whether to remove duplicate include.
mod_remove_duplicate_include = true # true/false
# the following options (mod_XX_closebrace_comment) use different comment,
# depending of the setting of the next option.
# false: Use the c comment (default)
# true : Use the cpp comment
mod_add_force_c_closebrace_comment = false # true/false
# If a function body exceeds the specified number of newlines and doesn't have
# a comment after the close brace, a comment will be added.
mod_add_long_function_closebrace_comment = 20 # unsigned number
@@ -3199,6 +3332,49 @@ mod_remove_empty_return = false # true/false
# Add or remove the comma after the last value of an enumeration.
mod_enum_last_comma = ignore # ignore/add/remove/force/not_defined
# Syntax to use for infinite loops.
#
# 0: Leave syntax alone (default)
# 1: Rewrite as `for(;;)`
# 2: Rewrite as `while(true)`
# 3: Rewrite as `do`...`while(true);`
# 4: Rewrite as `while(1)`
# 5: Rewrite as `do`...`while(1);`
#
# Infinite loops that do not already match one of these syntaxes are ignored.
# Other options that affect loop formatting will be applied after transforming
# the syntax.
mod_infinite_loop = 0 # unsigned number
# Add or remove the 'int' keyword in 'int short'.
mod_int_short = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'short int'.
mod_short_int = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'int long'.
mod_int_long = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'long int'.
mod_long_int = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'int signed'.
mod_int_signed = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'signed int'.
mod_signed_int = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'int unsigned'.
mod_int_unsigned = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'unsigned int'.
mod_unsigned_int = ignore # ignore/add/remove/force/not_defined
# If there is a situation where mod_int_* and mod_*_int would result in
# multiple int keywords, whether to keep the rightmost int (the default) or the
# leftmost int.
mod_int_prefer_int_on_left = false # true/false
# (OC) Whether to organize the properties. If true, properties will be
# rearranged according to the mod_sort_oc_property_*_weight factors.
mod_sort_oc_properties = false # true/false
@@ -3230,6 +3406,16 @@ mod_sort_oc_property_nullability_weight = 0 # number
# Preprocessor options
#
# How to use tabs when indenting preprocessor code.
#
# -1: Use 'indent_with_tabs' setting (default)
# 0: Spaces only
# 1: Indent with tabs to brace level, align with spaces
# 2: Indent and align with tabs, using spaces when not on a tabstop
#
# Default: -1
pp_indent_with_tabs = -1 # number
# Add or remove indentation of preprocessor directives inside #if blocks
# at brace level 0 (file-level).
pp_indent = ignore # ignore/add/remove/force/not_defined
@@ -3250,10 +3436,11 @@ pp_indent_at_level0 = false # true/false
# Default: 1
pp_indent_count = 4 # unsigned number
# Add or remove space after # based on pp_level of #if blocks.
pp_space = remove # ignore/add/remove/force/not_defined
# Add or remove space after # based on pp level of #if blocks.
pp_space = remove # compat
pp_space_after = remove # ignore/add/remove/force/not_defined
# Sets the number of spaces per level added with pp_space.
# Sets the number of spaces per level added with pp_space_after.
pp_space_count = 0 # unsigned number
# The indent for '#region' and '#endregion' in C# and '#pragma region' in
@@ -3286,22 +3473,34 @@ pp_include_at_level = false # true/false
# Whether to ignore the '#define' body while formatting.
pp_ignore_define_body = false # true/false
# An offset value that controls the indentation of the body of a multiline #define.
# 'body' refers to all the lines of a multiline #define except the first line.
# Requires 'pp_ignore_define_body = false'.
#
# <0: Absolute column: the body indentation starts off at the specified column
# (ex. -3 ==> the body is indented starting from column 3)
# >=0: Relative to the column of the '#' of '#define'
# (ex. 3 ==> the body is indented starting 3 columns at the right of '#')
#
# Default: 8
pp_multiline_define_body_indent = 8 # number
# Whether to indent case statements between #if, #else, and #endif.
# Only applies to the indent of the preprocesser that the case statements
# Only applies to the indent of the preprocessor that the case statements
# directly inside of.
#
# Default: true
pp_indent_case = true # true/false
# Whether to indent whole function definitions between #if, #else, and #endif.
# Only applies to the indent of the preprocesser that the function definition
# Only applies to the indent of the preprocessor that the function definition
# is directly inside of.
#
# Default: true
pp_indent_func_def = true # true/false
# Whether to indent extern C blocks between #if, #else, and #endif.
# Only applies to the indent of the preprocesser that the extern block is
# Only applies to the indent of the preprocessor that the extern block is
# directly inside of.
#
# Default: true
@@ -3309,7 +3508,7 @@ pp_indent_extern = true # true/false
# How to indent braces directly inside #if, #else, and #endif.
# Requires pp_if_indent_code=true and only applies to the indent of the
# preprocesser that the braces are directly inside of.
# preprocessor that the braces are directly inside of.
# 0: No extra indent
# 1: Indent by one level
# -1: Preserve original indentation
@@ -3382,10 +3581,10 @@ use_indent_continue_only_once = false # true/false
# The indentation can be:
# - after the assignment, at the '[' character
# - at the begin of the lambda body
# - at the beginning of the lambda body
#
# true: indentation will be after the assignment
# false: indentation will be at the begin of the lambda body (default)
# true: indentation will be at the beginning of the lambda body
# false: indentation will be after the assignment (default)
indent_cpp_lambda_only_once = true # true/false
# Whether sp_after_angle takes precedence over sp_inside_fparen. This was the
@@ -3437,6 +3636,23 @@ debug_timeout = 0 # number
# 0: do not truncate.
debug_truncate = 0 # unsigned number
# sort (or not) the tracking info.
#
# Default: true
debug_sort_the_tracks = true # true/false
# decode (or not) the flags as a new line.
# only if the -p option is set.
debug_decode_the_flags = false # true/false
# use (or not) the exit(EX_SOFTWARE) function.
#
# Default: true
debug_use_the_exit_function_pop = true # true/false
# insert the number of the line at the beginning of each line
set_numbering_for_html_output = false # true/false
# Meaning of the settings:
# Ignore - do not do any changes
# Add - makes sure there is 1 or more space/brace/newline/etc
@@ -3489,5 +3705,5 @@ debug_truncate = 0 # unsigned number
# `macro-close END_MESSAGE_MAP`
#
#
# option(s) with 'not default' value: 214
# option(s) with 'not default' value: 219
#