Compare commits
No commits in common. "20ecbca42abf0854ea63844a9cc0b1e24f82f6fd" and "142ae3d65fda20404f1cb022cdd51ca2e178811c" have entirely different histories.
20ecbca42a
...
142ae3d65f
@ -1,20 +0,0 @@
|
|||||||
include:
|
|
||||||
- project: 'f1x1t/gitlab-ci'
|
|
||||||
ref: master
|
|
||||||
file: 'scheduled.yml'
|
|
||||||
|
|
||||||
smolensk15-nightly:
|
|
||||||
extends: .scheduled-smolensk15
|
|
||||||
|
|
||||||
orel212-nightly:
|
|
||||||
extends: .scheduled-orel212
|
|
||||||
|
|
||||||
focal-nightly:
|
|
||||||
extends: .scheduled-focal
|
|
||||||
|
|
||||||
jammy-nightly:
|
|
||||||
extends: .scheduled-jammy
|
|
||||||
|
|
||||||
elbrus-nightly:
|
|
||||||
extends: .scheduled-elbrus
|
|
||||||
|
|
@ -5,43 +5,29 @@ cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
|
|||||||
cmake_policy(VERSION 3.6..3.7)
|
cmake_policy(VERSION 3.6..3.7)
|
||||||
|
|
||||||
# Название и версия проекта и используемые языки программирования
|
# Название и версия проекта и используемые языки программирования
|
||||||
project(myx-example-app-ext VERSION 0.4.0 LANGUAGES C CXX)
|
project(myx-example-app-ext VERSION 0.3.0 LANGUAGES C CXX)
|
||||||
|
|
||||||
# Имя и почта автора (требуются для создания пакетов)
|
|
||||||
set(${PROJECT_NAME}_AUTHOR_NAME "Andrey Astafyev")
|
|
||||||
set(${PROJECT_NAME}_AUTHOR_EMAIL "dev@246060.ru")
|
|
||||||
|
|
||||||
# Рекомендуемый способ подключения MyxCMake
|
# Рекомендуемый способ подключения MyxCMake
|
||||||
include(cmake/myx_setup.cmake)
|
include(cmake/myx_setup.cmake)
|
||||||
|
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
myx_add_external_target(myx-example-interface-library
|
FetchContent_Add(myx-example-interface-library
|
||||||
GIT_REPOSITORY git@gitlab.2:myx/examples/myx-example-interface-library)
|
GIT_REPOSITORY gitlab.2:myx/examples/myx-example-interface-library
|
||||||
myx_add_external_target(myx-example-object-library
|
GIT_PATH myx/examples/myx-example-interface-library
|
||||||
GIT_REPOSITORY git@gitlab.2:myx/examples/myx-example-object-library)
|
GIT_REMOTE origin
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Add(myx-example-object-library
|
||||||
|
GIT_REPOSITORY 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()
|
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)
|
add_executable(${PROJECT_NAME})
|
||||||
|
|
||||||
#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()
|
|
||||||
|
|
||||||
# Цель для создания исполняемого файла
|
|
||||||
myx_add_executable(${PROJECT_NAME})
|
|
||||||
|
|
||||||
# Настройка свойств цели
|
# Настройка свойств цели
|
||||||
myx_target_setup(${PROJECT_NAME}
|
myx_target_setup(${PROJECT_NAME}
|
||||||
@ -52,15 +38,11 @@ myx_target_setup(${PROJECT_NAME}
|
|||||||
myx-example-object-library
|
myx-example-object-library
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Форматирование кода с помощью uncrustify
|
||||||
|
myx_uncrustify(${PROJECT_NAME})
|
||||||
|
|
||||||
# Автоматически генерируемый файл с информацией о репозитории
|
# Автоматически генерируемый файл с информацией о репозитории
|
||||||
myx_generate_git_info_header(${PROJECT_NAME} "git_info_p.hpp")
|
myx_generate_git_info_header(${PROJECT_NAME} "git_info_p.hpp")
|
||||||
|
|
||||||
# Автоматически генерируемый приватный заголовочный файл
|
# Автоматически генерируемый приватный заголовочный файл
|
||||||
myx_generate_private_config_header(${PROJECT_NAME} "config_p.hpp")
|
myx_generate_private_config_header(${PROJECT_NAME} "config_p.hpp")
|
||||||
|
|
||||||
# Форматирование исходных текстов с помощью uncrustify
|
|
||||||
myx_uncrustify(${PROJECT_NAME})
|
|
||||||
|
|
||||||
# Правила для сборки пакетов
|
|
||||||
myx_create_packages(${PROJECT_NAME})
|
|
||||||
|
|
||||||
|
@ -1,76 +1,40 @@
|
|||||||
cmake_policy(PUSH)
|
cmake_policy(PUSH)
|
||||||
cmake_policy(SET CMP0057 NEW) # IN_LIST operator
|
cmake_policy(SET CMP0057 NEW) # IN_LIST operator
|
||||||
|
|
||||||
# CMake выполняет проверку системного окружения с помощью модулей,
|
# Каталог для модулей, выполняющих поиск библиотек
|
||||||
# расположенных в следующих каталогах:
|
list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake/find")
|
||||||
# /usr/share/cmake-${CMAKE_VERSION}/Modules
|
|
||||||
# /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake
|
|
||||||
# /usr/lib/cmake
|
|
||||||
# Если для используемой программы или библиотеки нет стандартного
|
|
||||||
# модуля для поиска, то можно использовать собственный.
|
|
||||||
# С помощью переменной `CMAKE_MODULE_PATH` указывается перечень
|
|
||||||
# дополнительных каталогов, в которых производится поиск модулей.
|
|
||||||
set(MYX_CMAKE_FIND_DIR "${PROJECT_SOURCE_DIR}/cmake/find")
|
|
||||||
if(IS_DIRECTORY "${MYX_CMAKE_FIND_DIR}")
|
|
||||||
if(NOT ${MYX_CMAKE_FIND_DIR} IN_LIST CMAKE_MODULE_PATH)
|
|
||||||
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FIND_DIR}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
|
get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
|
||||||
|
|
||||||
set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports")
|
set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports")
|
||||||
set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
|
set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
|
||||||
|
|
||||||
# Модули для обеспечения обратной совместимости со старыми версиями CMake
|
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake)
|
||||||
|
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)
|
||||||
|
|
||||||
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
|
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
|
||||||
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
|
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||||
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
|
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
|
||||||
else()
|
|
||||||
include(FetchContent)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Загрузка стандартных модулей
|
include(${MYX_CMAKE_LIB_DIR}/Includes.cmake)
|
||||||
include(GNUInstallDirs)
|
|
||||||
include(CMakeDependentOption)
|
|
||||||
|
|
||||||
# Полезные макросы
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake)
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.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}/ColoredMessages.cmake)
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/PopulateCMakeBinaryDir.cmake)
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/CurrentDate.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/CurrentDate.cmake)
|
||||||
|
include(${MYX_CMAKE_LIB_DIR}/ColoredMessages.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWarning.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWarning.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/DirectoriesGuards.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/DirectoriesGuards.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/SemanticProjectVersion.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/SemanticProjectVersion.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWrapper.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}/FetchContentAdd.cmake)
|
||||||
|
|
||||||
set(MYX_CMAKE_TOOLCHAINS_DIR "${MYX_CMAKE_LIB_DIR}/toolchains")
|
include(${MYX_CMAKE_LIB_DIR}/AddLibrary.cmake)
|
||||||
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}/TargetSetup.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
|
||||||
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/uncrustify/Uncrustify.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/Uncrustify.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/doc/Doxygen.cmake)
|
|
||||||
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/generators/PrivateConfigHeader.cmake)
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/generators/GitInfoHeader.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/generators/GitInfoHeader.cmake)
|
||||||
|
include(${MYX_CMAKE_LIB_DIR}/generators/PrivateConfigHeader.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/CreatePackages.cmake)
|
|
||||||
include(${MYX_CMAKE_LIB_DIR}/Uninstall.cmake)
|
|
||||||
|
|
||||||
unset(MYX_CMAKE_SOURCE_DIR)
|
unset(MYX_CMAKE_SOURCE_DIR)
|
||||||
unset(MYX_CMAKE_BACKPORTS_DIR)
|
unset(MYX_CMAKE_BACKPORTS_DIR)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set(MYX_CMAKE_PACKAGE_VERSION "2.3.1")
|
set(MYX_CMAKE_PACKAGE_VERSION "1.99.77")
|
||||||
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
else()
|
else()
|
||||||
|
@ -199,8 +199,6 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
SUBBUILD_DIR
|
SUBBUILD_DIR
|
||||||
SOURCE_DIR
|
SOURCE_DIR
|
||||||
BINARY_DIR
|
BINARY_DIR
|
||||||
# We need special processing if DOWNLOAD_NO_EXTRACT is true
|
|
||||||
DOWNLOAD_NO_EXTRACT
|
|
||||||
# Prevent the following from being passed through
|
# Prevent the following from being passed through
|
||||||
CONFIGURE_COMMAND
|
CONFIGURE_COMMAND
|
||||||
BUILD_COMMAND
|
BUILD_COMMAND
|
||||||
@ -251,26 +249,6 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
|
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(ARG_DOWNLOAD_NO_EXTRACT)
|
|
||||||
set(ARG_EXTRA "${ARG_EXTRA} DOWNLOAD_NO_EXTRACT YES")
|
|
||||||
set(__FETCHCONTENT_COPY_FILE
|
|
||||||
"
|
|
||||||
ExternalProject_Get_Property(${contentName}-populate DOWNLOADED_FILE)
|
|
||||||
get_filename_component(dlFileName \"\${DOWNLOADED_FILE}\" NAME)
|
|
||||||
|
|
||||||
ExternalProject_Add_Step(${contentName}-populate copyfile
|
|
||||||
COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different
|
|
||||||
\"<DOWNLOADED_FILE>\" \"${ARG_SOURCE_DIR}\"
|
|
||||||
DEPENDEES patch
|
|
||||||
DEPENDERS configure
|
|
||||||
BYPRODUCTS \"${ARG_SOURCE_DIR}/\${dlFileName}\"
|
|
||||||
COMMENT \"Copying file to SOURCE_DIR\"
|
|
||||||
)
|
|
||||||
")
|
|
||||||
else()
|
|
||||||
unset(__FETCHCONTENT_COPY_FILE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Hide output if requested, but save it to a variable in case there's an
|
# Hide output if requested, but save it to a variable in case there's an
|
||||||
# error so we can show the output upon failure. When not quiet, don't
|
# error so we can show the output upon failure. When not quiet, don't
|
||||||
# capture the output to a variable because the user may want to see the
|
# capture the output to a variable because the user may want to see the
|
||||||
@ -288,16 +266,16 @@ ExternalProject_Add_Step(${contentName}-populate copyfile
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_GENERATOR)
|
if(CMAKE_GENERATOR)
|
||||||
set(subCMakeOpts "-G${CMAKE_GENERATOR}")
|
set(generatorOpts "-G${CMAKE_GENERATOR}")
|
||||||
if(CMAKE_GENERATOR_PLATFORM)
|
if(CMAKE_GENERATOR_PLATFORM)
|
||||||
list(APPEND subCMakeOpts "-A${CMAKE_GENERATOR_PLATFORM}")
|
list(APPEND generatorOpts "-A${CMAKE_GENERATOR_PLATFORM}")
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_GENERATOR_TOOLSET)
|
if(CMAKE_GENERATOR_TOOLSET)
|
||||||
list(APPEND subCMakeOpts "-T${CMAKE_GENERATOR_TOOLSET}")
|
list(APPEND generatorOpts "-T${CMAKE_GENERATOR_TOOLSET}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_MAKE_PROGRAM)
|
if(CMAKE_MAKE_PROGRAM)
|
||||||
list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
|
list(APPEND generatorOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
@ -305,7 +283,7 @@ ExternalProject_Add_Step(${contentName}-populate copyfile
|
|||||||
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
|
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
|
||||||
# trusted even if provided). We will have to rely on being
|
# trusted even if provided). We will have to rely on being
|
||||||
# able to find the default generator and build tool.
|
# able to find the default generator and build tool.
|
||||||
unset(subCMakeOpts)
|
unset(generatorOpts)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create and build a separate CMake project to carry out the population.
|
# Create and build a separate CMake project to carry out the population.
|
||||||
@ -316,7 +294,7 @@ ExternalProject_Add_Step(${contentName}-populate copyfile
|
|||||||
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
|
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
|
||||||
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
|
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} ${subCMakeOpts} .
|
COMMAND ${CMAKE_COMMAND} ${generatorOpts} .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
${outputOptions}
|
${outputOptions}
|
||||||
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
|
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# Макрос реализован для обратной совместимости
|
# Макрос реализован для обратной совместимости
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.10.0")
|
if(${CMAKE_VERSION} VERSION_LESS "3.10.0")
|
||||||
macro(include_guard)
|
macro(include_guard)
|
||||||
if(CMAKE_FILE_${CMAKE_CURRENT_LIST_FILE}_ALREADY_INCLUDED)
|
if (CMAKE_FILE_${CMAKE_CURRENT_LIST_FILE}_ALREADY_INCLUDED)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_FILE_${CMAKE_CURRENT_LIST_FILE}_ALREADY_INCLUDED TRUE)
|
set(CMAKE_FILE_${CMAKE_CURRENT_LIST_FILE}_ALREADY_INCLUDED TRUE)
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.21)
|
if(CMAKE_VERSION VERSION_LESS 3.21)
|
||||||
get_property(__parent_directory DIRECTORY PROPERTY PARENT_DIRECTORY)
|
get_property(nt DIRECTORY PROPERTY PARENT_DIRECTORY)
|
||||||
if(NOT __parent_directory)
|
if(NOT nt)
|
||||||
set(PROJECT_IS_TOP_LEVEL true)
|
set(PROJECT_IS_TOP_LEVEL true)
|
||||||
endif()
|
endif()
|
||||||
unset(__parent_directory)
|
unset(nt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#[=======================================================================[.rst:
|
|
||||||
myx_add_executable
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Вспомогательная функция для создания исполняемого файла::
|
|
||||||
|
|
||||||
myx_add_executable(TARGET_NAME)
|
|
||||||
|
|
||||||
Используется для совместимости с версиями CMake раньше 3.11,
|
|
||||||
в которых было необходимо указать хотя бы один файл с исходными текстами.
|
|
||||||
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
function(myx_add_executable TARGET_NAME)
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
|
||||||
add_executable(${TARGET_NAME} ${ARGN} "")
|
|
||||||
else()
|
|
||||||
add_executable(${TARGET_NAME} ${ARGN})
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
@ -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)
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
|||||||
#[=======================================================================[.rst:
|
|
||||||
myx_add_interface_library
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
Вспомогательная функция для создания интерфейсной библиотеки::
|
|
||||||
|
|
||||||
myx_add_interface_library(TARGET_NAME
|
|
||||||
[ 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()`
|
|
||||||
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
include(GenerateExportHeader)
|
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
||||||
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")
|
|
||||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(TARGET ${TARGET_NAME})
|
|
||||||
myx_message_fatal_error("Target ${TARGET_NAME} already exists")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs OUTPUT_NAME)
|
|
||||||
set(multiValueArgs HEADERS LINK_LIBRARIES PACKAGES)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
if(NOT ARG_OUTPUT_NAME)
|
|
||||||
set(ARG_OUTPUT_NAME ${TARGET_NAME})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Вызов стандартной функции `add_library()`
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.19.0")
|
|
||||||
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})
|
|
||||||
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)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Библиотека, состоящая только из заголовочных файлов не требует сборки.
|
|
||||||
# Стандартные пути к заголовочным файлам
|
|
||||||
target_include_directories(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
|
||||||
|
|
||||||
# Если вызов был выполнен не из проекта верхнего уровня,
|
|
||||||
# то созданная цель исключается из цели `all`.
|
|
||||||
# При этом сама цель `${TARGET_NAME}` может участвовать в сборке,
|
|
||||||
# если окажется в перечне зависимостей.
|
|
||||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL True)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Правила для установки библиотек и относящихся к ним файлов.
|
|
||||||
# Если вызов был выполнен не из проекта верхнего уровня,
|
|
||||||
# то эти правила не обрабатываются.
|
|
||||||
write_basic_package_version_file(
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
|
||||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/library-config.cmake.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Config.cmake
|
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
|
||||||
NO_SET_AND_CHECK_MACRO
|
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
|
||||||
)
|
|
||||||
|
|
||||||
install(EXPORT ${TARGET_NAME}Targets
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
|
||||||
COMPONENT DEV)
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES
|
|
||||||
${PROJECT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake
|
|
||||||
${PROJECT_BINARY_DIR}/${TARGET_NAME}Config.cmake
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
|
||||||
COMPONENT DEV)
|
|
||||||
|
|
||||||
# Формирование файла для pkg-config
|
|
||||||
file(WRITE "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
|
||||||
"prefix=${CMAKE_INSTALL_PREFIX}\n"
|
|
||||||
"exec_prefix=${CMAKE_INSTALL_PREFIX}\n"
|
|
||||||
"includedir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n"
|
|
||||||
"\n"
|
|
||||||
"Name: ${TARGET_NAME}\n"
|
|
||||||
"Description: ${TARGET_NAME} library\n"
|
|
||||||
"Version: ${PROJECT_VERSION}\n"
|
|
||||||
"\n"
|
|
||||||
"Requires:\n"
|
|
||||||
"Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n")
|
|
||||||
|
|
||||||
# Установка файла для pkg-config
|
|
||||||
install(
|
|
||||||
FILES "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
|
||||||
COMPONENT DEV)
|
|
||||||
|
|
||||||
# Установка библиотеки из заголовочных файлов
|
|
||||||
target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
||||||
install(
|
|
||||||
TARGETS ${TARGET_NAME}
|
|
||||||
EXPORT ${TARGET_NAME}Targets
|
|
||||||
COMPONENT DEV)
|
|
||||||
|
|
||||||
# Установка публичных заголовочных файлов
|
|
||||||
if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS)
|
|
||||||
myx_install_relative(${PROJECT_SOURCE_DIR}
|
|
||||||
FILES ${ARG_HEADERS}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
|
||||||
COMPONENT DEV)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
226
cmake/myx/lib/AddLibrary.cmake
Normal file
226
cmake/myx/lib/AddLibrary.cmake
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
#[=======================================================================[.rst:
|
||||||
|
myx_add_library
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Вспомогательная функция для создания библиотеки::
|
||||||
|
|
||||||
|
myx_add_library(NAME TYPE
|
||||||
|
[ OUTPUT_NAME output_name ] |
|
||||||
|
[ EXPORT_FILE_NAME file_name ] |
|
||||||
|
[ EXPORT_BASE_NAME base_name ])
|
||||||
|
|
||||||
|
Обязательные параметры: `NAME` - имя библиотеки и `TYPE` - тип цели.
|
||||||
|
Параметр `OUTPUT_NAME` определяет базовое имя выходных файлов.
|
||||||
|
Параметр `EXPORT_FILE_NAME` задаёт имя заголовочного файла экспортируемых
|
||||||
|
переменных, а `EXPORT_BASE_NAME` - базовый суффикс для формирования имён переменных.
|
||||||
|
Все остальные параметры передаются в стандартную функцию `add_library()`
|
||||||
|
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет определить
|
||||||
|
# каталог файла.
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||||
|
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
include(GenerateExportHeader)
|
||||||
|
|
||||||
|
function(myx_add_library NAME TYPE)
|
||||||
|
set(options)
|
||||||
|
set(oneValueArgs OUTPUT_NAME EXPORT_FILE_NAME EXPORT_BASE_NAME)
|
||||||
|
set(multiValueArgs)
|
||||||
|
|
||||||
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT ARG_OUTPUT_NAME)
|
||||||
|
set(ARG_OUTPUT_NAME ${NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Вызов стандартной функции `add_library()`
|
||||||
|
add_library(${NAME} ${TYPE} ${ARG_UNPARSED_ARGUMENTS})
|
||||||
|
|
||||||
|
if(TYPE STREQUAL "INTERFACE")
|
||||||
|
# Библиотека, состоящая только из заголовочных файлов не требует сборки.
|
||||||
|
# Стандартные пути к заголовочным файлам
|
||||||
|
target_include_directories(${NAME}
|
||||||
|
INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
string(TOUPPER ${NAME} PROJECT_NAME_UPPER)
|
||||||
|
# Опция для разрешения сборки динамической библиотеки
|
||||||
|
cmake_dependent_option(${PROJECT_NAME_UPPER}_BUILD_SHARED
|
||||||
|
"Build shared library for ${NAME}" ON "BUILD_SHARED_LIBS" OFF)
|
||||||
|
# Опция для разрешения сборки статической библиотеки
|
||||||
|
cmake_dependent_option(${PROJECT_NAME_UPPER}_BUILD_STATIC
|
||||||
|
"Build static library for ${NAME}" ON "NOT BUILD_SHARED_LIBS" OFF)
|
||||||
|
|
||||||
|
# Стандартные пути к заголовочным файлам
|
||||||
|
target_include_directories(${NAME}
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
|
PRIVATE
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
|
)
|
||||||
|
|
||||||
|
# Сборка позиционно-независимых объектных файлов нужна
|
||||||
|
# для создания динамической библиотеки
|
||||||
|
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
if(NOT EXPORT_BASE_NAME)
|
||||||
|
string(TOUPPER ${NAME} ARG_EXPORT_BASE_NAME)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ARG_EXPORT_FILE_NAME)
|
||||||
|
set(ARG_EXPORT_FILE_NAME "${PROJECT_SOURCE_DIR}/include/${NAME}/${NAME}_export.hpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
generate_export_header(${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 ${NAME} APPEND PROPERTY INTERFACE_HEADER_FILES "${ARG_EXPORT_FILE_NAME}")
|
||||||
|
|
||||||
|
# Цель для создания динамической библиотеки из объектных файлов
|
||||||
|
if(${PROJECT_NAME_UPPER}_BUILD_SHARED)
|
||||||
|
# Для создания динамической библиотеки используются объектные файлы цели ${NAME}
|
||||||
|
add_library(${NAME}_shared SHARED $<TARGET_OBJECTS:${NAME}>)
|
||||||
|
# Установка дополнительных свойств для цели ${NAME}_shared
|
||||||
|
# VERSION: версия библиотеки
|
||||||
|
# SOVERSION: мажорная версия библиотеки
|
||||||
|
# LIBRARY_OUTPUT_DIRECTORY: каталог для записи результатов сборки
|
||||||
|
# OUTPUT_NAME: базовое имя выходного файла (без учёта расширения)
|
||||||
|
set_target_properties(${NAME}_shared
|
||||||
|
PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||||
|
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Цель для создания статической библиотеки из объектных файлов
|
||||||
|
if(${PROJECT_NAME_UPPER}_BUILD_STATIC)
|
||||||
|
# Для создания статической библиотеки используются объектные файлы цели ${NAME}
|
||||||
|
add_library(${NAME}_static STATIC $<TARGET_OBJECTS:${NAME}>)
|
||||||
|
# Установка дополнительных свойств для цели ${NAME}_static
|
||||||
|
# ARCHIVE_OUTPUT_DIRECTORY: каталог для записи результатов сборки
|
||||||
|
# OUTPUT_NAME: базовое имя выходного файла (без учёта расширения)
|
||||||
|
set_target_properties(${NAME}_static
|
||||||
|
PROPERTIES
|
||||||
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||||
|
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Если вызов был выполнен не из проекта верхнего уровня,
|
||||||
|
# то созданная цель исключается из цели `all`.
|
||||||
|
# При этом сама цель `${NAME}` может участвовать в сборке,
|
||||||
|
# если окажется в перечне зависимостей.
|
||||||
|
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||||
|
set_target_properties(${NAME} PROPERTIES EXCLUDE_FROM_ALL True)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Правила для установки библиотек и относящихся к ним файлов.
|
||||||
|
# Если вызов был выполнен не из проекта верхнего уровня,
|
||||||
|
# то эти правила не обрабатываются.
|
||||||
|
write_basic_package_version_file(
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY AnyNewerVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/library-config.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/${NAME}Config.cmake
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||||
|
NO_SET_AND_CHECK_MACRO
|
||||||
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||||
|
)
|
||||||
|
|
||||||
|
install(EXPORT ${NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||||
|
COMPONENT dev
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||||
|
${PROJECT_BINARY_DIR}/${NAME}Config.cmake
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||||
|
COMPONENT dev
|
||||||
|
)
|
||||||
|
|
||||||
|
# Формирование файла для pkg-config
|
||||||
|
file(WRITE "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||||
|
"prefix=${CMAKE_INSTALL_PREFIX}\n"
|
||||||
|
"exec_prefix=${CMAKE_INSTALL_PREFIX}\n"
|
||||||
|
"includedir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n")
|
||||||
|
|
||||||
|
if(NOT TYPE STREQUAL "INTERFACE")
|
||||||
|
file(APPEND "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||||
|
"libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\n")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(APPEND "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||||
|
"\n"
|
||||||
|
"Name: ${NAME}\n"
|
||||||
|
"Description: ${NAME} library\n"
|
||||||
|
"Version: ${PROJECT_VERSION}\n"
|
||||||
|
"\n"
|
||||||
|
"Requires:\n"
|
||||||
|
"Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n")
|
||||||
|
|
||||||
|
if(NOT TYPE STREQUAL "INTERFACE")
|
||||||
|
file(APPEND "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||||
|
"Libs: -L${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} -l${NAME}\n")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Установка файла для pkg-config
|
||||||
|
install(
|
||||||
|
FILES "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||||
|
COMPONENT dev
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
|
||||||
|
if(TYPE STREQUAL "OBJECT")
|
||||||
|
# Установка динамической библиотеки
|
||||||
|
if(TARGET ${NAME}_shared)
|
||||||
|
install(
|
||||||
|
TARGETS ${NAME}_shared
|
||||||
|
EXPORT ${NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
COMPONENT lib
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(TARGET ${NAME}_static)
|
||||||
|
# Установка статической библиотеки
|
||||||
|
install(
|
||||||
|
TARGETS ${NAME}_static
|
||||||
|
EXPORT ${NAME}Targets
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
COMPONENT static
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(TYPE STREQUAL "INTERFACE")
|
||||||
|
# Установка библиотеки из заголовочных файлов
|
||||||
|
install(
|
||||||
|
TARGETS ${NAME}
|
||||||
|
EXPORT ${NAME}Targets
|
||||||
|
COMPONENT lib
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
@ -1,195 +0,0 @@
|
|||||||
#[=======================================================================[.rst:
|
|
||||||
myx_add_object_library
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
Вспомогательная функция для создания объектной библиотеки::
|
|
||||||
|
|
||||||
myx_add_object_library(TARGET_NAME
|
|
||||||
[ OUTPUT_NAME output_name ] |
|
|
||||||
[ EXPORT_FILE_NAME file_name ] |
|
|
||||||
[ EXPORT_BASE_NAME base_name ])
|
|
||||||
|
|
||||||
Обязательные параметры: `TARGET_NAME` - имя библиотеки.
|
|
||||||
Параметр `OUTPUT_NAME` определяет базовое имя выходных файлов.
|
|
||||||
Параметр `EXPORT_FILE_NAME` задаёт имя заголовочного файла экспортируемых
|
|
||||||
переменных, а `EXPORT_BASE_NAME` - базовый суффикс для формирования имён переменных.
|
|
||||||
Все остальные параметры передаются в стандартную функцию `add_library()`
|
|
||||||
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
||||||
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")
|
|
||||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
include(GenerateExportHeader)
|
|
||||||
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs OUTPUT_NAME EXPORT_FILE_NAME EXPORT_BASE_NAME)
|
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
if(NOT ARG_OUTPUT_NAME)
|
|
||||||
set(ARG_OUTPUT_NAME ${TARGET_NAME})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Вызов стандартной функции `add_library()`
|
|
||||||
add_library(${TARGET_NAME} OBJECT ${ARG_UNPARSED_ARGUMENTS})
|
|
||||||
|
|
||||||
string(TOUPPER ${TARGET_NAME} __project_name_upper)
|
|
||||||
# Опция для разрешения сборки динамической библиотеки
|
|
||||||
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
|
|
||||||
"Build static library for ${TARGET_NAME}" ON "NOT BUILD_SHARED_LIBS" OFF)
|
|
||||||
|
|
||||||
# Стандартные пути к заголовочным файлам
|
|
||||||
target_include_directories(${TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
|
||||||
PRIVATE
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
)
|
|
||||||
|
|
||||||
# Сборка позиционно-независимых объектных файлов нужна
|
|
||||||
# для создания динамической библиотеки
|
|
||||||
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_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}")
|
|
||||||
|
|
||||||
# Цель для создания динамической библиотеки из объектных файлов
|
|
||||||
if(${__project_name_upper}_BUILD_SHARED)
|
|
||||||
# Для создания динамической библиотеки используются объектные файлы цели ${TARGET_NAME}
|
|
||||||
add_library(${TARGET_NAME}_shared SHARED $<TARGET_OBJECTS:${TARGET_NAME}>)
|
|
||||||
# Установка дополнительных свойств для цели ${TARGET_NAME}_shared
|
|
||||||
# VERSION: версия библиотеки
|
|
||||||
# SOVERSION: мажорная версия библиотеки
|
|
||||||
# LIBRARY_OUTPUT_DIRECTORY: каталог для записи результатов сборки
|
|
||||||
# OUTPUT_NAME: базовое имя выходного файла (без учёта расширения)
|
|
||||||
set_target_properties(${TARGET_NAME}_shared PROPERTIES
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
|
||||||
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Цель для создания статической библиотеки из объектных файлов
|
|
||||||
if(${__project_name_upper}_BUILD_STATIC)
|
|
||||||
# Для создания статической библиотеки используются
|
|
||||||
# объектные файлы цели ${TARGET_NAME}
|
|
||||||
add_library(${TARGET_NAME}_static STATIC $<TARGET_OBJECTS:${TARGET_NAME}>)
|
|
||||||
# Установка дополнительных свойств для цели ${TARGET_NAME}_static
|
|
||||||
# ARCHIVE_OUTPUT_DIRECTORY: каталог для записи результатов сборки
|
|
||||||
# OUTPUT_NAME: базовое имя выходного файла (без учёта расширения)
|
|
||||||
set_target_properties(${TARGET_NAME}_static PROPERTIES
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
|
||||||
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Если вызов был выполнен не из проекта верхнего уровня,
|
|
||||||
# то созданная цель исключается из цели `all`.
|
|
||||||
# При этом сама цель `${TARGET_NAME}` может участвовать в сборке,
|
|
||||||
# если окажется в перечне зависимостей.
|
|
||||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL True)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Правила для установки библиотек и относящихся к ним файлов.
|
|
||||||
# Если вызов был выполнен не из проекта верхнего уровня,
|
|
||||||
# то эти правила не обрабатываются.
|
|
||||||
write_basic_package_version_file(
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
|
||||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/library-config.cmake.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Config.cmake
|
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
|
||||||
NO_SET_AND_CHECK_MACRO
|
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
|
||||||
)
|
|
||||||
|
|
||||||
install(EXPORT ${TARGET_NAME}Targets
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
|
||||||
COMPONENT DEV
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES
|
|
||||||
${PROJECT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake
|
|
||||||
${PROJECT_BINARY_DIR}/${TARGET_NAME}Config.cmake
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
|
||||||
COMPONENT DEV
|
|
||||||
)
|
|
||||||
|
|
||||||
# Формирование файла для pkg-config
|
|
||||||
file(WRITE "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
|
||||||
"prefix=${CMAKE_INSTALL_PREFIX}\n"
|
|
||||||
"exec_prefix=${CMAKE_INSTALL_PREFIX}\n"
|
|
||||||
"includedir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n"
|
|
||||||
"libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\n"
|
|
||||||
"\n"
|
|
||||||
"Name: ${TARGET_NAME}\n"
|
|
||||||
"Description: ${TARGET_NAME} library\n"
|
|
||||||
"Version: ${PROJECT_VERSION}\n"
|
|
||||||
"\n"
|
|
||||||
"Requires:\n"
|
|
||||||
"Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n"
|
|
||||||
"Libs: -L${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} -l${TARGET_NAME}\n")
|
|
||||||
|
|
||||||
# Установка файла для pkg-config
|
|
||||||
install(
|
|
||||||
FILES "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
|
||||||
COMPONENT DEV
|
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
||||||
|
|
||||||
# Установка динамической библиотеки
|
|
||||||
if(TARGET ${TARGET_NAME}_shared)
|
|
||||||
install(
|
|
||||||
TARGETS ${TARGET_NAME}_shared
|
|
||||||
EXPORT ${TARGET_NAME}Targets
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
COMPONENT LIB
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Установка статической библиотеки
|
|
||||||
if(TARGET ${TARGET_NAME}_static)
|
|
||||||
install(
|
|
||||||
TARGETS ${TARGET_NAME}_static
|
|
||||||
EXPORT ${TARGET_NAME}Targets
|
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
COMPONENT STATIC
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
@ -1,194 +0,0 @@
|
|||||||
function(myx_create_packages TARGET_NAME)
|
|
||||||
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs DEBIAN_PACKAGE_TYPE CPACK_DEBIAN_PACKAGE_SECTION CPACK_DEBIAN_PACKAGE_PRIORITY
|
|
||||||
CMAKE_INSTALL_DEFAULT_COMPONENT_NAME CPACK_PACKAGE_CONTACT CPACK_PACKAGING_INSTALL_PREFIX)
|
|
||||||
set(multiValueArgs CPACK_SOURCE_GENERATOR CPACK_GENERATOR CPACK_SOURCE_IGNORE_FILES)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
# Общие настройки для пакета: организация, автор, версия
|
|
||||||
if(NOT ${PROJECT_NAME}_CONTACT)
|
|
||||||
if(${PROJECT_NAME}_AUTHOR_NAME AND ${PROJECT_NAME}_AUTHOR_EMAIL)
|
|
||||||
set(CPACK_PACKAGE_CONTACT "${${PROJECT_NAME}_AUTHOR_NAME} <${${PROJECT_NAME}_AUTHOR_EMAIL}>")
|
|
||||||
else()
|
|
||||||
set(CPACK_PACKAGE_CONTACT "unknown maintainer <nonexistent@mailbox>")
|
|
||||||
myx_message_warning("\${PROJECT_NAME}_CONTACT variable is required for packaging but unset")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(CPACK_PACKAGE_CONTACT ${${PROJECT_NAME}_CONTACT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ${PROJECT_NAME}_VENDOR)
|
|
||||||
if(${PROJECT_NAME}_AUTHOR_NAME)
|
|
||||||
set(CPACK_PACKAGE_VENDOR "${${PROJECT_NAME}_AUTHOR_NAME}")
|
|
||||||
else()
|
|
||||||
set(CPACK_PACKAGE_VENDOR "unknown vendor")
|
|
||||||
myx_message_warning("\${PROJECT_NAME}_VENDOR variable is required for packaging but unset")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(CPACK_PACKAGE_VENDOR ${${PROJECT_NAME}_VENDOR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(TOLOWER ${PROJECT_NAME} PN)
|
|
||||||
set(CPACK_PACKAGE_NAME ${PN})
|
|
||||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
|
||||||
|
|
||||||
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
|
|
||||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Параметры для архива исходных текстов
|
|
||||||
if(NOT ARG_CPACK_SOURCE_GENERATOR)
|
|
||||||
set(CPACK_SOURCE_GENERATOR "TXZ")
|
|
||||||
else()
|
|
||||||
set(ARG_CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR})
|
|
||||||
endif()
|
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PN}-${CPACK_PACKAGE_VERSION}")
|
|
||||||
|
|
||||||
# Типы генераторов для бинарных архивов
|
|
||||||
if(NOT ARG_CPACK_GENERATOR)
|
|
||||||
set(CPACK_GENERATOR "TXZ" "DEB")
|
|
||||||
else()
|
|
||||||
set(CPACK_GENERATOR ${ARG_CPACK_GENERATOR})
|
|
||||||
endif()
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
|
|
||||||
list(REMOVE_ITEM CPACK_GENERATOR "DEB")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Параметры для архива собранного проекта
|
|
||||||
set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
|
||||||
set(CPACK_TARGET_ARCH "amd64")
|
|
||||||
endif()
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME "${PN}_${CPACK_PACKAGE_VERSION}")
|
|
||||||
|
|
||||||
# Список масок для исключения из архива исходных текстов
|
|
||||||
set(CPACK_SOURCE_IGNORE_FILES
|
|
||||||
${ARG_CPACK_SOURCE_IGNORE_FILES}
|
|
||||||
${CMAKE_BINARY_DIR}
|
|
||||||
"^${CMAKE_SOURCE_DIR}/.?build.?/"
|
|
||||||
"^${CMAKE_SOURCE_DIR}/.?output.?/"
|
|
||||||
"^${CMAKE_SOURCE_DIR}/files/var"
|
|
||||||
"^${CMAKE_SOURCE_DIR}/files/log"
|
|
||||||
"CMakeLists.txt.user.*"
|
|
||||||
".*.autosave"
|
|
||||||
".*.status"
|
|
||||||
"~$"
|
|
||||||
"\\\\.swp$")
|
|
||||||
|
|
||||||
option(MYX_COMPACT_SOURCE_PACKAGE "Make compact source package" ON)
|
|
||||||
if(MYX_COMPACT_SOURCE_PACKAGE)
|
|
||||||
# Список масок для исключения из архива исходных текстов для более компактного архива
|
|
||||||
set(CPACK_SOURCE_IGNORE_FILES
|
|
||||||
${CPACK_SOURCE_IGNORE_FILES}
|
|
||||||
"\\\\.git"
|
|
||||||
"/\\\\.git/"
|
|
||||||
"/\\\\.gitlab-ci/"
|
|
||||||
"\\\\.clang-tidy$"
|
|
||||||
"\\\\.cmake-format$"
|
|
||||||
"\\\\.gitignore$"
|
|
||||||
"\\\\.gitattributes$"
|
|
||||||
"\\\\.gitmodules$"
|
|
||||||
"\\\\.gitlab-ci.yml$")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("TXZ" IN_LIST CPACK_GENERATOR)
|
|
||||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF)
|
|
||||||
set(CPACK_ARCHIVE_FILE_NAME "${PN}_${CPACK_TARGET_ARCH}_${CPACK_PACKAGE_VERSION}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("DEB" IN_LIST CPACK_GENERATOR)
|
|
||||||
set(CPACK_DEB_MONOLITHIC_INSTALL OFF)
|
|
||||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
||||||
|
|
||||||
# По умолчанию пакет собирается для дистрибутива unstable
|
|
||||||
if(NOT ARG_DEBIAN_PACKAGE_TYPE)
|
|
||||||
set(DEBIAN_PACKAGE_TYPE "unstable")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ARG_CPACK_DEBIAN_PACKAGE_SECTION)
|
|
||||||
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ARG_CPACK_DEBIAN_PACKAGE_PRIORITY)
|
|
||||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# По умолчанию пакет для Debian делится на компоненты
|
|
||||||
if(NOT ARG_CPACK_DEB_COMPONENT_INSTALL)
|
|
||||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Если имя компонента по умолчанию не определено, то устанавливается main
|
|
||||||
if(NOT CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
|
|
||||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME MAIN)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# В списке компонентов обязательно должны быть main, lib, dev, static и doc
|
|
||||||
#list(APPEND CPACK_COMPONENTS_ALL main lib dev static doc)
|
|
||||||
# TODO
|
|
||||||
#list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
|
|
||||||
|
|
||||||
set(deb_arch_suffix "${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb")
|
|
||||||
# Правило формирования имени пакета и файла для компонента main
|
|
||||||
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${PN}")
|
|
||||||
set(CPACK_DEBIAN_MAIN_FILE_NAME ${CPACK_DEBIAN_MAIN_PACKAGE_NAME}_${deb_arch_suffix})
|
|
||||||
|
|
||||||
# Правило формирования имени пакета и файла для компонента lib
|
|
||||||
set(CPACK_DEBIAN_LIB_PACKAGE_NAME "lib${PN}${PROJECT_VERSION_MAJOR}")
|
|
||||||
set(CPACK_DEBIAN_LIB_FILE_NAME ${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${deb_arch_suffix})
|
|
||||||
|
|
||||||
# Правило формирования имени пакета и файла для компонента dev
|
|
||||||
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${PN}-dev")
|
|
||||||
set(CPACK_DEBIAN_DEV_FILE_NAME ${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${deb_arch_suffix})
|
|
||||||
|
|
||||||
# Правило формирования имени пакета и файла для компонента static
|
|
||||||
set(CPACK_DEBIAN_STATIC_PACKAGE_NAME "lib${PN}${PROJECT_VERSION_MAJOR}-static-dev")
|
|
||||||
set(CPACK_DEBIAN_STATIC_FILE_NAME ${CPACK_DEBIAN_STATIC_PACKAGE_NAME}_${deb_arch_suffix})
|
|
||||||
set(CPACK_DEBIAN_STATIC_PACKAGE_DEPENDS "lib${PN}-dev")
|
|
||||||
|
|
||||||
# Правило формирования имени пакета и файла для компонента doc
|
|
||||||
set(CPACK_DEBIAN_DOC_PACKAGE_NAME "${PN}-doc")
|
|
||||||
set(CPACK_DEBIAN_DOC_FILE_NAME ${PN}-doc_${CPACK_PACKAGE_VERSION}_all.deb)
|
|
||||||
|
|
||||||
foreach(iter ${CPACK_COMPONENTS_ALL})
|
|
||||||
string(TOLOWER ${iter} _cl)
|
|
||||||
string(TOUPPER ${iter} _cu)
|
|
||||||
# Правила формирования имени пакета и файла для остальных компонентов
|
|
||||||
if((NOT ${_cu} STREQUAL MAIN) AND
|
|
||||||
(NOT ${_cu} STREQUAL LIB) AND
|
|
||||||
(NOT ${_cu} STREQUAL DEV) AND
|
|
||||||
(NOT ${_cu} STREQUAL STATIC) AND
|
|
||||||
(NOT ${_cu} STREQUAL DOC))
|
|
||||||
set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${PN}-${_cl}")
|
|
||||||
set(CPACK_DEBIAN_${_cu}_FILE_NAME "${CPACK_DEBIAN_${_cu}_PACKAGE_NAME}_${deb_arch_suffix}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Если в каталоге ${CMAKE_SOURCE_DIR}/cmake/deb/${_cl} находятся сценарии сопровождающего
|
|
||||||
# postinst, preinst, postrm и prerm, то они будут добавлены к пакету.
|
|
||||||
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
|
|
||||||
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
|
|
||||||
endif()
|
|
||||||
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
|
|
||||||
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
|
|
||||||
endif()
|
|
||||||
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
|
|
||||||
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
|
|
||||||
endif()
|
|
||||||
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
|
|
||||||
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
if(UNIX AND NOT TARGET deb)
|
|
||||||
add_custom_target(deb WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND cpack -G DEB)
|
|
||||||
add_dependencies(deb ${TARGET_NAME})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Подключение модуля, выполняющего сборку архивов и пакетов
|
|
||||||
include(CPack)
|
|
||||||
endfunction(myx_create_packages TARGET_NAME)
|
|
@ -1,7 +1,7 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
if(NOT MYX_TODAY)
|
if(NOT MYX_TODAY)
|
||||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
|
if(WIN32)
|
||||||
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_TODAY)
|
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_TODAY)
|
||||||
else()
|
else()
|
||||||
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_TODAY)
|
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_TODAY)
|
||||||
@ -10,7 +10,7 @@ if(NOT MYX_TODAY)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MYX_YEAR)
|
if(NOT MYX_YEAR)
|
||||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
|
if(WIN32)
|
||||||
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_YEAR)
|
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_YEAR)
|
||||||
else()
|
else()
|
||||||
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_YEAR)
|
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_YEAR)
|
||||||
|
@ -46,27 +46,6 @@ if(project_binary_dir STREQUAL project_source_dir)
|
|||||||
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
|
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Очистка от сгенерированных файлов
|
|
||||||
file(GLOB_RECURSE cmakelists_files RELATIVE ${cmake_source_dir} CMakeLists.txt)
|
|
||||||
foreach(it ${cmakelists_files})
|
|
||||||
get_filename_component(file ${it} REALPATH)
|
|
||||||
get_filename_component(dir ${file} DIRECTORY)
|
|
||||||
file(REMOVE_RECURSE
|
|
||||||
${dir}/.cmake
|
|
||||||
${dir}/CMakeFiles)
|
|
||||||
file(REMOVE
|
|
||||||
${dir}/CMakeFiles
|
|
||||||
${dir}/CMakeCache.txt
|
|
||||||
${dir}/cmake_install.cmake
|
|
||||||
${dir}/compile_commands.json
|
|
||||||
${dir}/Makefile
|
|
||||||
${dir}/.ninja_deps
|
|
||||||
${dir}/.ninja_logs
|
|
||||||
${dir}/build.ninja
|
|
||||||
${dir}/rules.ninja)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
unset(cmakelists_files)
|
|
||||||
unset(cmake_source_dir)
|
unset(cmake_source_dir)
|
||||||
unset(cmake_binary_dir)
|
unset(cmake_binary_dir)
|
||||||
unset(project_source_dir)
|
unset(project_source_dir)
|
||||||
|
@ -24,7 +24,7 @@ include_guard(GLOBAL)
|
|||||||
# Обязательно в глобальной области
|
# Обязательно в глобальной области
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
|
||||||
function(FetchContent_Add TARGET_NAME)
|
function(FetchContent_Add NAME)
|
||||||
set(options "")
|
set(options "")
|
||||||
set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH)
|
set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH)
|
||||||
set(multiValueArgs "")
|
set(multiValueArgs "")
|
||||||
@ -45,12 +45,15 @@ function(FetchContent_Add TARGET_NAME)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
${TARGET_NAME}
|
${NAME}
|
||||||
${ARG_UNPARSED_ARGUMENTS}
|
${ARG_UNPARSED_ARGUMENTS}
|
||||||
GIT_REPOSITORY ${ARG_GIT_REPOSITORY}
|
GIT_REPOSITORY ${ARG_GIT_REPOSITORY}
|
||||||
GIT_SHALLOW 1
|
GIT_SHALLOW 1
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FETCHCONTENT_QUIET off)
|
if(NOT ${NAME}_POPULATED)
|
||||||
FetchContent_MakeAvailable(${TARGET_NAME})
|
FetchContent_Populate(${NAME})
|
||||||
|
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
5
cmake/myx/lib/Includes.cmake
Normal file
5
cmake/myx/lib/Includes.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(CMakeDependentOption)
|
@ -4,5 +4,5 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.8.0" AND CMAKE_GENERATOR MATCHES Ninja)
|
if(${CMAKE_VERSION} VERSION_LESS "3.8.0" AND CMAKE_GENERATOR MATCHES Ninja)
|
||||||
myx_message_send_error("Myx: Old CMake versions should use Makefile generator")
|
myx_message_error("Myx: Old CMake versions should use Makefile generator")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
# Создание в каталоге ${CMAKE_BINARY_DIR} стандартных каталогов bin,include,lib,
|
|
||||||
# а также символических ссылок на каталоги в ${CMAKE_SOURCE_DIR}/files
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
|
||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include)
|
|
||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
|
|
||||||
|
|
||||||
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/etc" "${CMAKE_BINARY_DIR}/etc")
|
|
||||||
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/log" "${CMAKE_BINARY_DIR}/log")
|
|
||||||
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/share" "${CMAKE_BINARY_DIR}/share")
|
|
||||||
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/var" "${CMAKE_BINARY_DIR}/var")
|
|
@ -1,50 +1,45 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
function(myx_qt5_target_setup TARGET_NAME)
|
function(myx_qt5_target_setup NAME)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs)
|
set(oneValueArgs)
|
||||||
set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS)
|
set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS)
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
get_target_property(__target_type ${TARGET_NAME} TYPE)
|
get_target_property(target_type ${NAME} TYPE)
|
||||||
|
|
||||||
foreach(iter ${ARG_COMPONENTS})
|
foreach(iter ${ARG_COMPONENTS})
|
||||||
if(__target_type STREQUAL "INTERFACE_LIBRARY")
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
||||||
target_include_directories(${TARGET_NAME} INTERFACE ${Qt5${iter}_INCLUDE_DIRS})
|
target_include_directories(${NAME} INTERFACE ${Qt5${iter}_INCLUDE_DIRS})
|
||||||
else()
|
else()
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${Qt5${iter}_INCLUDE_DIRS})
|
target_include_directories(${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()
|
endif()
|
||||||
|
if(target_type STREQUAL "EXECUTABLE" AND NOT iter STREQUAL "LinguistTools")
|
||||||
|
target_link_libraries(${NAME} PRIVATE "Qt5::${iter}")
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(iter ${ARG_PRIVATE})
|
foreach(iter ${ARG_PRIVATE})
|
||||||
if(__target_type STREQUAL "INTERFACE_LIBRARY")
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
||||||
target_include_directories(${TARGET_NAME} INTERFACE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
|
target_include_directories(${NAME} INTERFACE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
|
||||||
else()
|
else()
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
|
target_include_directories(${NAME} PRIVATE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(__target_type STREQUAL "EXECUTABLE")
|
if(target_type STREQUAL "EXECUTABLE")
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS})
|
target_compile_options(${NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_PUBLIC_MOC)
|
if(ARG_PUBLIC_MOC)
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
|
set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC})
|
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_PRIVATE_MOC)
|
if(ARG_PRIVATE_MOC)
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
|
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC})
|
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
|
if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
|
||||||
@ -57,53 +52,43 @@ function(myx_qt5_target_setup TARGET_NAME)
|
|||||||
|
|
||||||
if(ARG_UI AND "Widgets" IN_LIST ARG_COMPONENTS)
|
if(ARG_UI AND "Widgets" IN_LIST ARG_COMPONENTS)
|
||||||
qt5_wrap_ui(ui_h ${ARG_UI})
|
qt5_wrap_ui(ui_h ${ARG_UI})
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_UI})
|
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_UI})
|
||||||
# TODO
|
# TODO
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
|
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Перечень файлов, подлежащих переводу
|
# Перечень файлов, подлежащих переводу
|
||||||
if(__target_type STREQUAL "INTERFACE_LIBRARY")
|
get_target_property(tr ${NAME} TR_FILES)
|
||||||
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)
|
if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr)
|
||||||
# Заглавие файла ресурсов
|
# Заглавие файла ресурсов
|
||||||
file(WRITE ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "<RCC><qresource prefix=\"/qm\">\n")
|
file(WRITE ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc "<RCC><qresource prefix=\"/qm\">\n")
|
||||||
# Для каждого языка, указанное в параметре LANGS
|
# Для каждого языка, указанное в параметре LANGS
|
||||||
foreach(iter ${ARG_LANGS})
|
foreach(iter ${ARG_LANGS})
|
||||||
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
|
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
|
||||||
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
|
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
|
||||||
qt5_create_translation(qm ${tr}
|
qt5_create_translation(qm ${tr} "${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts")
|
||||||
"${PROJECT_SOURCE_DIR}/l10n/${TARGET_NAME}_${iter}.ts"
|
|
||||||
OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME})
|
|
||||||
# Добавление записи для скомпилированного файла переводов в ресурсный файл
|
# Добавление записи для скомпилированного файла переводов в ресурсный файл
|
||||||
file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc
|
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc
|
||||||
"<file alias=\"${TARGET_NAME}_${iter}\">${TARGET_NAME}_${iter}.qm</file>\n")
|
"<file alias=\"${NAME}_${iter}\">${NAME}_${iter}.qm</file>\n")
|
||||||
# Добавление скомпилированного файла переводов к списку зависимостей для цели
|
# Добавление скомпилированного файла переводов к списку зависимостей для цели
|
||||||
target_sources(${TARGET_NAME} PRIVATE ${qm})
|
target_sources(${NAME} PRIVATE ${qm})
|
||||||
endforeach()
|
endforeach()
|
||||||
# Окончение файла ресурсов
|
# Окончение файла ресурсов
|
||||||
file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "</qresource></RCC>\n")
|
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc "</qresource></RCC>\n")
|
||||||
# Комплияция файла ресурсов с переводами
|
# Комплияция файла ресурсов с переводами
|
||||||
qt5_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc)
|
qt5_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc)
|
||||||
target_sources(${TARGET_NAME} PRIVATE ${qrc_l10n})
|
target_sources(${NAME} PRIVATE ${qrc_l10n})
|
||||||
endif()
|
endif()
|
||||||
unset(tr)
|
unset(tr)
|
||||||
if(__target_type STREQUAL "INTERFACE_LIBRARY")
|
target_sources(${NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
|
||||||
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)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
myx_install_relative(${PROJECT_SOURCE_DIR}
|
install_relative(${PROJECT_SOURCE_DIR}
|
||||||
FILES ${ARG_PUBLIC_MOC}
|
FILES ${ARG_PUBLIC_MOC}
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
COMPONENT DEV
|
COMPONENT dev
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -1,124 +1,91 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
function(myx_target_setup TARGET_NAME)
|
function(myx_target_setup NAME)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs PCH)
|
set(oneValueArgs PCH)
|
||||||
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
|
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
|
||||||
CPP PUBLIC_HEADERS PRIVATE_HEADERS)
|
CPP INTERFACE_HEADERS PUBLIC_HEADERS PRIVATE_HEADERS)
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
if(NOT TARGET ${TARGET_NAME})
|
if(NOT TARGET ${NAME})
|
||||||
myx_message_fatal_error("Target ${TARGET_NAME} does not exists.")
|
myx_message_fatal_error("Target ${NAME} does not exists.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
get_target_property(__target_type ${TARGET_NAME} TYPE)
|
get_target_property(target_type ${NAME} TYPE)
|
||||||
if(${__target_type} STREQUAL "INTERFACE_LIBRARY")
|
|
||||||
myx_message_fatal_error("This function will not work for interface targets.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(iter ${ARG_PACKAGES})
|
foreach(iter ${ARG_PACKAGES})
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${${iter}_INCLUDE_DIRS})
|
target_include_directories(${NAME} PRIVATE ${${iter}_INCLUDE_DIRS})
|
||||||
target_compile_definitions(${TARGET_NAME} PRIVATE ${${iter}_COMPILE_DEFINITIONS})
|
target_compile_definitions(${NAME} PRIVATE ${${iter}_COMPILE_DEFINITIONS})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
|
||||||
|
|
||||||
if(ARG_CPP)
|
if(ARG_CPP)
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY CPP_FILES ${ARG_CPP})
|
set_property(TARGET ${NAME} APPEND PROPERTY CPP_FILES ${ARG_CPP})
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_CPP})
|
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_CPP})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_PUBLIC_HEADERS)
|
if(ARG_PUBLIC_HEADERS)
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_HEADERS}")
|
set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_HEADERS}")
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_HEADERS})
|
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_HEADERS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_PRIVATE_HEADERS)
|
if(ARG_PRIVATE_HEADERS)
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_HEADERS}")
|
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_HEADERS}")
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_HEADERS})
|
set_property(TARGET ${NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_HEADERS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARG_PCH)
|
if(ARG_PCH)
|
||||||
if((${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) AND (PROJECT_IS_TOP_LEVEL OR MYX_USE_LOCAL_DIRECTORIES))
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16 AND PROJECT_IS_TOP_LEVEL OR MYX_USE_LOCAL_DIRECTORIES)
|
||||||
target_precompile_headers(${TARGET_NAME} PRIVATE ${ARG_PCH})
|
target_precompile_headers(${NAME} PRIVATE ${ARG_PCH})
|
||||||
else()
|
else()
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE -include ${ARG_PCH})
|
target_compile_options(${NAME} PRIVATE -include ${ARG_PCH})
|
||||||
endif()
|
endif()
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PCH}")
|
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PCH}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
if(NOT IS_DIRECTORY "${PROJECT_BINARY_DIR}/include")
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>)
|
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/src")
|
if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>)
|
||||||
|
|
||||||
|
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/src")
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(__target_type STREQUAL "EXECUTABLE")
|
if(target_type STREQUAL "EXECUTABLE")
|
||||||
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include")
|
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include")
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||||
endif()
|
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(${TARGET_NAME} PROPERTIES
|
set_target_properties(${NAME} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
if(CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
||||||
target_compile_options(${TARGET_NAME} PUBLIC ${CMAKE_CXX_COMPILE_OPTIONS_PIE})
|
target_compile_options(${NAME} PUBLIC ${CMAKE_CXX_COMPILE_OPTIONS_PIE})
|
||||||
endif()
|
endif()
|
||||||
install(TARGETS ${TARGET_NAME} COMPONENT MAIN RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS ${NAME} COMPONENT main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_sources(${TARGET_NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
|
target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
|
||||||
target_sources(${TARGET_NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
|
target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
|
||||||
target_sources(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
|
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
|
||||||
target_compile_definitions(${TARGET_NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
|
target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES})
|
||||||
|
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
|
||||||
# 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"))
|
|
||||||
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})
|
|
||||||
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)
|
|
||||||
else()
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_shared)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Установка публичных заголовочных файлов
|
# Установка публичных заголовочных файлов
|
||||||
if(PROJECT_IS_TOP_LEVEL AND ARG_PUBLIC_HEADERS)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
myx_install_relative(${PROJECT_SOURCE_DIR}
|
install_relative(${PROJECT_SOURCE_DIR}
|
||||||
FILES ${ARG_PUBLIC_HEADERS}
|
FILES ${ARG_PUBLIC_HEADERS} ${ARG_INTERFACE_HEADERS}
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
COMPONENT DEV
|
COMPONENT dev
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
|
||||||
set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "unknown")
|
|
||||||
set(MYX_CMAKE_LSB_CODENAME "unknown")
|
|
||||||
set(MYX_CMAKE_LSB_RELEASE_VERSION "unknown")
|
|
||||||
|
|
||||||
if(CMAKE_CROSSCOMPILING)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(EXISTS /etc/mcst_version)
|
|
||||||
set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "ElbrusD")
|
|
||||||
set(MYX_CMAKE_LSB_CODENAME "Jessie")
|
|
||||||
execute_process(COMMAND cat /etc/mcst_version
|
|
||||||
OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE_VERSION
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
else()
|
|
||||||
find_program(LSB_RELEASE_EXECUTABLE lsb_release)
|
|
||||||
# cmake-format: off
|
|
||||||
if(LSB_RELEASE_EXECUTABLE)
|
|
||||||
execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -si
|
|
||||||
OUTPUT_VARIABLE MYX_CMAKE_LSB_DISTRIBUTOR_ID
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -sc
|
|
||||||
OUTPUT_VARIABLE MYX_CMAKE_LSB_CODENAME
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -sr
|
|
||||||
OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE_VERSION
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
endif()
|
|
||||||
# cmake-format: on
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
include("${MYX_CMAKE_TOOLCHAINS_DIR}/GCC.cmake")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
include("${MYX_CMAKE_TOOLCHAINS_DIR}/Clang.cmake")
|
|
||||||
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()
|
|
||||||
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()
|
|
||||||
endif()
|
|
108
cmake/myx/lib/Uncrustify.cmake
Normal file
108
cmake/myx/lib/Uncrustify.cmake
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||||
|
|
||||||
|
if(UNCRUSTIFY_EXE)
|
||||||
|
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-classheader.txt)
|
||||||
|
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-classheader.txt CONTENT
|
||||||
|
"/**
|
||||||
|
* @class $(fclass)
|
||||||
|
* @brief TODO
|
||||||
|
* @details TODO
|
||||||
|
*/")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-filefooter.txt)
|
||||||
|
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-filefooter.txt CONTENT
|
||||||
|
"// EOF $(filename)")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-fileheader.txt)
|
||||||
|
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-fileheader.txt CONTENT
|
||||||
|
"/**
|
||||||
|
* @file $(filename)
|
||||||
|
* @brief TODO
|
||||||
|
* @details TODO
|
||||||
|
*/")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS ${PROJECT_BINARY_DIR}/uncrustify-funcheader.txt)
|
||||||
|
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-funcheader.txt CONTENT
|
||||||
|
"/**
|
||||||
|
* @fn $(fclass)::$(function)
|
||||||
|
* $(javaparam)
|
||||||
|
* @details TODO
|
||||||
|
*/")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
function(myx_uncrustify target)
|
||||||
|
set(options)
|
||||||
|
set(oneValueArgs CONFIG)
|
||||||
|
set(multiValueArgs)
|
||||||
|
|
||||||
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT ARG_CONFIG)
|
||||||
|
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/.uncrustify.cfg")
|
||||||
|
if(NOT EXISTS ${ARG_CONFIG})
|
||||||
|
set(ARG_CONFIG "${CMAKE_SOURCE_DIR}/.uncrustify.cfg")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS ${ARG_CONFIG})
|
||||||
|
myx_message_notify("MyxCMake: uncrustify config is not found")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT UNCRUSTIFY_EXE)
|
||||||
|
myx_message_notify("MyxCMake: uncrustify executable is not found")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET myx-uncrustify)
|
||||||
|
add_custom_target(myx-uncrustify)
|
||||||
|
endif()
|
||||||
|
if(NOT TARGET myx-uncrustify-check)
|
||||||
|
add_custom_target(myx-uncrustify-check)
|
||||||
|
endif()
|
||||||
|
if(NOT TARGET myx-uncrustify-append-comments)
|
||||||
|
add_custom_target(myx-uncrustify-append-comments)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_target_property(__sources ${target} SOURCES)
|
||||||
|
list(FILTER __sources EXCLUDE REGEX "qrc_.*\\.cpp$")
|
||||||
|
list(FILTER __sources EXCLUDE REGEX "moc_.*\\.cpp$")
|
||||||
|
list(FILTER __sources EXCLUDE REGEX "ui_.*\\.h$")
|
||||||
|
list(FILTER __sources EXCLUDE REGEX ".*\\.qm$")
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${target}.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)
|
||||||
|
# cmake-format: off
|
||||||
|
add_custom_target(${target}-uncrustify-check
|
||||||
|
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||||
|
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${__sources})
|
||||||
|
|
||||||
|
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
|
||||||
|
add_custom_target(${target}-uncrustify
|
||||||
|
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||||
|
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${__sources})
|
||||||
|
|
||||||
|
add_custom_target(${target}-uncrustify-append-comments
|
||||||
|
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
||||||
|
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||||
|
--set cmt_insert_class_header=${PROJECT_BINARY_DIR}/uncrustify-classheader.txt
|
||||||
|
--set cmt_insert_file_footer=${PROJECT_BINARY_DIR}/uncrustify-filefooter.txt
|
||||||
|
--set cmt_insert_file_header=${PROJECT_BINARY_DIR}/uncrustify-fileheader.txt
|
||||||
|
--set cmt_insert_func_header=${PROJECT_BINARY_DIR}/uncrustify-funcheader.txt
|
||||||
|
--set cmt_insert_before_ctor_dtor=true --mtime ${__sources})
|
||||||
|
# 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)
|
||||||
|
endfunction()
|
@ -1,13 +0,0 @@
|
|||||||
#[=======================================================================[.rst:
|
|
||||||
Цель для удаления файлов, установленных выполнением цели `install`.
|
|
||||||
Если при установке использовалась переменная `DESTDIR`, то при удалении
|
|
||||||
файлов нужно указать то же значение.
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
if((NOT TARGET uninstall) AND (NOT DEFINED ENV{SAPR_PREFIX}))
|
|
||||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/uninstall.cmake.in
|
|
||||||
${CMAKE_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
|
|
||||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
|
|
||||||
endif()
|
|
@ -1,31 +0,0 @@
|
|||||||
PROJECT_NAME = @DOXYGEN_PROJECT_TITLE@
|
|
||||||
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@
|
|
||||||
OUTPUT_LANGUAGE = @ARG_LANGUAGE@
|
|
||||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
|
|
||||||
STRIP_FROM_INC_PATH = @PROJECT_SOURCE_DIR@
|
|
||||||
|
|
||||||
EXTRACT_ALL = YES
|
|
||||||
EXTRACT_PRIVATE = YES
|
|
||||||
EXTRACT_STATIC = YES
|
|
||||||
EXTRACT_LOCAL_METHODS = YES
|
|
||||||
|
|
||||||
INPUT = "@PROJECT_SOURCE_DIR@/doc/doxygen" "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@/src"
|
|
||||||
RECURSIVE = YES
|
|
||||||
|
|
||||||
CLANG_ASSISTED_PARSING = YES
|
|
||||||
CLANG_DATABASE_PATH = @CMAKE_BINARY_DIR@
|
|
||||||
|
|
||||||
GENERATE_HTML = @ARG_HTML@
|
|
||||||
GENERATE_TREEVIEW = YES
|
|
||||||
|
|
||||||
GENERATE_LATEX = @ARG_LATEX@
|
|
||||||
LATEX_CMD_NAME = xelatex
|
|
||||||
COMPACT_LATEX = YES
|
|
||||||
|
|
||||||
GENERATE_XML = @ARG_XML@
|
|
||||||
|
|
||||||
UML_LOOK = YES
|
|
||||||
TEMPLATE_RELATIONS = YES
|
|
||||||
CALL_GRAPH = YES
|
|
||||||
CALLER_GRAPH = YES
|
|
||||||
INTERACTIVE_SVG = YES
|
|
@ -1,75 +0,0 @@
|
|||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
||||||
set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(myx_doc_doxygen TARGET_NAME)
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
||||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
||||||
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")
|
|
||||||
else()
|
|
||||||
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(target myx-doc-doxygen-${TARGET_NAME})
|
|
||||||
if(TARGET ${target})
|
|
||||||
myx_message_warning("Target ${target} already defined")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT DOXYGEN_FOUND)
|
|
||||||
add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs HTML LATEX XML LANGUAGE DOXYFILE_TEMPLATE)
|
|
||||||
set(multiValueArgs)
|
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
if(NOT ARG_HTML)
|
|
||||||
set(ARG_HTML NO)
|
|
||||||
endif()
|
|
||||||
if(NOT ARG_LATEX)
|
|
||||||
set(ARG_LATEX NO)
|
|
||||||
endif()
|
|
||||||
if(NOT ARG_XML)
|
|
||||||
set(ARG_XML YES)
|
|
||||||
endif()
|
|
||||||
if(NOT ARG_LANGUAGE)
|
|
||||||
set(ARG_LANGUAGE "Russian")
|
|
||||||
endif()
|
|
||||||
if(NOT ARG_DOXYFILE_TEMPLATE OR NOT EXISTS "${ARG_DOXYFILE_TEMPLATE}")
|
|
||||||
set(ARG_DOXYFILE_TEMPLATE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Doxyfile.in")
|
|
||||||
endif()
|
|
||||||
if(NOT DOXYGEN_PROJECT_NAME)
|
|
||||||
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(work_dir ${PROJECT_BINARY_DIR}/doc/doxygen)
|
|
||||||
configure_file(${ARG_DOXYFILE_TEMPLATE} ${work_dir}/Doxyfile @ONLY)
|
|
||||||
|
|
||||||
add_custom_target(${target}
|
|
||||||
VERBATIM
|
|
||||||
WORKING_DIRECTORY ${work_dir}
|
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile
|
|
||||||
COMMENT "Generating API documentation with Doxygen")
|
|
||||||
if(ARG_HTML)
|
|
||||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/doxygen/html/
|
|
||||||
COMPONENT DOC OPTIONAL
|
|
||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/doxygen)
|
|
||||||
endif()
|
|
||||||
if(NOT TARGET myx-doc-doxygen)
|
|
||||||
add_custom_target(myx-doc-doxygen)
|
|
||||||
endif()
|
|
||||||
add_dependencies(myx-doc-doxygen ${target})
|
|
||||||
endfunction()
|
|
@ -1,32 +0,0 @@
|
|||||||
cmake_policy(PUSH)
|
|
||||||
cmake_policy(SET CMP0053 NEW) # IN_LIST operator
|
|
||||||
|
|
||||||
set(ARG_PREFIX "${PREFIX}")
|
|
||||||
set(GIT_REV "N/A")
|
|
||||||
set(GIT_DIFF "")
|
|
||||||
set(GIT_TAG "N/A")
|
|
||||||
set(GIT_BRANCH "N/A")
|
|
||||||
|
|
||||||
find_package(Git)
|
|
||||||
|
|
||||||
if(GIT_EXECUTABLE)
|
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE GIT_REV ERROR_QUIET)
|
|
||||||
|
|
||||||
# Check whether we got any revision (which isn't always the case,
|
|
||||||
# e.g. when someone downloaded a zip file from Github instead of a checkout)
|
|
||||||
if(NOT "${GIT_REV}" STREQUAL "")
|
|
||||||
execute_process(COMMAND bash -c "${GIT_EXECUTABLE} diff --quiet --exit-code || echo +" OUTPUT_VARIABLE GIT_DIFF)
|
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
|
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE GIT_BRANCH)
|
|
||||||
|
|
||||||
string(STRIP "${GIT_REV}" GIT_REV)
|
|
||||||
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
|
|
||||||
string(STRIP "${GIT_DIFF}" GIT_DIFF)
|
|
||||||
string(STRIP "${GIT_TAG}" GIT_TAG)
|
|
||||||
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
configure_file("GitInfo.hpp.in" "${GIT_INFO_FILE}")
|
|
||||||
|
|
||||||
cmake_policy(POP)
|
|
@ -1,26 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined (@PREFIX@GIT_REV)
|
|
||||||
#error "Duplicate definition of macros @PREFIX@GIT_REV"
|
|
||||||
#else
|
|
||||||
#define @PREFIX@GIT_REV "@GIT_REV@"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (@PREFIX@GIT_DIFF)
|
|
||||||
#error "Duplicate definition of macros @PREFIX@GIT_DIFF"
|
|
||||||
#else
|
|
||||||
#define @PREFIX@GIT_DIFF "@GIT_DIFF@"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (@PREFIX@GIT_BRANCH)
|
|
||||||
#error "Duplicate definition of macros @PREFIX@GIT_BRANCH"
|
|
||||||
#else
|
|
||||||
#define @PREFIX@GIT_BRANCH "@GIT_BRANCH@"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (@PREFIX@GIT_TAG)
|
|
||||||
#error "Duplicate definition of macros @PREFIX@GIT_TAG"
|
|
||||||
#else
|
|
||||||
#define @PREFIX@GIT_TAG "@GIT_TAG@"
|
|
||||||
#endif
|
|
@ -5,52 +5,102 @@ myx_generate_git_info_header
|
|||||||
Вспомогательная функция для автоматической генерации заголовочного
|
Вспомогательная функция для автоматической генерации заголовочного
|
||||||
файла, содержащего информацию о текущем состоянии репозитория git::
|
файла, содержащего информацию о текущем состоянии репозитория git::
|
||||||
|
|
||||||
myx_generate_git_info_header(TARGET_NAME BASE_FILENAME
|
myx_generate_git_info_header(TARGET BASE_FILENAME
|
||||||
[ PREFIX prefix ] )
|
[ PREFIX prefix ] )
|
||||||
|
|
||||||
Обязательные параметры: `TARGET_NAME` - имя цели, с которой связан
|
Обязательные параметры: `TARGET` - имя цели, с которой связан заголовочный файл,
|
||||||
заголовочный файл, и `BASE_FILENAME` - имя генерируемого заголовочного
|
и `BASE_FILENAME` - имя генерируемого заголовочного файла. Дополнительный аргумент
|
||||||
файла. Дополнительный аргумент `PREFIX` добавляет префикс к генерируемым
|
`PREFIX` добавляет префикс к генерируемым именам переменных.
|
||||||
именам переменных.
|
|
||||||
|
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
|
|
||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
function(myx_generate_git_info_header target base_filename)
|
||||||
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")
|
|
||||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs PREFIX)
|
set(oneValueArgs PREFIX)
|
||||||
set(multiValueArgs)
|
set(multiValueArgs)
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
|
|
||||||
file(APPEND ${__filename} "")
|
|
||||||
|
|
||||||
set(__prefix "")
|
|
||||||
if(ARG_PREFIX)
|
if(ARG_PREFIX)
|
||||||
string(APPEND ARG_PREFIX "_")
|
string(APPEND ARG_PREFIX "_")
|
||||||
string(REPLACE "-" "_" __prefix ${ARG_PREFIX})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}")
|
||||||
|
|
||||||
|
set(git_info_hpp_in
|
||||||
|
"#pragma once
|
||||||
|
|
||||||
|
#if defined (@ARG_PREFIX@GIT_REV)
|
||||||
|
#error \"Duplicate definition of macros @ARG_PREFIX@GIT_REV\"
|
||||||
|
#else
|
||||||
|
#define @ARG_PREFIX@GIT_REV \"@GIT_REV@\"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (@ARG_PREFIX@GIT_DIFF)
|
||||||
|
#error \"Duplicate definition of macros @ARG_PREFIX@GIT_DIFF\"
|
||||||
|
#else
|
||||||
|
#define @ARG_PREFIX@GIT_DIFF \"@GIT_DIFF@\"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (@ARG_PREFIX@GIT_BRANCH)
|
||||||
|
#error \"Duplicate definition of macros @ARG_PREFIX@GIT_BRANCH\"
|
||||||
|
#else
|
||||||
|
#define @ARG_PREFIX@GIT_BRANCH \"@GIT_BRANCH@\"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (@ARG_PREFIX@GIT_TAG)
|
||||||
|
#error \"Duplicate definition of macros @ARG_PREFIX@GIT_TAG\"
|
||||||
|
#else
|
||||||
|
#define @ARG_PREFIX@GIT_TAG \"@GIT_TAG@\"
|
||||||
|
#endif
|
||||||
|
")
|
||||||
|
|
||||||
|
set(git_info_hpp_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/myx_git_info_p.hpp.in)
|
||||||
|
file(WRITE ${git_info_hpp_in_path} ${git_info_hpp_in})
|
||||||
|
|
||||||
|
set(git_info_cmake_in
|
||||||
|
"set(ARG_PREFIX ${ARG_PREFIX})
|
||||||
|
set(GIT_REV \"N/A\")
|
||||||
|
set(GIT_DIFF \"\")
|
||||||
|
set(GIT_TAG \"N/A\")
|
||||||
|
set(GIT_BRANCH \"N/A\")
|
||||||
|
|
||||||
|
find_package(Git)
|
||||||
|
|
||||||
|
if(GIT_EXECUTABLE)
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE GIT_REV ERROR_QUIET)
|
||||||
|
|
||||||
|
# Check whether we got any revision (which isn't always the case,
|
||||||
|
# e.g. when someone downloaded a zip file from Github instead of a checkout)
|
||||||
|
if(NOT \"\${GIT_REV}\" STREQUAL \"\")
|
||||||
|
execute_process(COMMAND bash -c \"${GIT_EXECUTABLE} diff --quiet --exit-code || echo +\" OUTPUT_VARIABLE GIT_DIFF)
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE GIT_BRANCH)
|
||||||
|
|
||||||
|
string(STRIP \"\${GIT_REV}\" GIT_REV)
|
||||||
|
string(SUBSTRING \"\${GIT_REV}\" 1 7 GIT_REV)
|
||||||
|
string(STRIP \"\${GIT_DIFF}\" GIT_DIFF)
|
||||||
|
string(STRIP \"\${GIT_TAG}\" GIT_TAG)
|
||||||
|
string(STRIP \"\${GIT_BRANCH}\" GIT_BRANCH)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_file(${git_info_hpp_in_path} \"\${GIT_INFO_FILE}\")
|
||||||
|
")
|
||||||
|
set(git_info_cmake_in_path "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target}-git-info.cmake.in")
|
||||||
|
file(WRITE ${git_info_cmake_in_path} ${git_info_cmake_in})
|
||||||
|
|
||||||
# cmake-format: off
|
# cmake-format: off
|
||||||
if(NOT TARGET ${TARGET_NAME}-git-info-header)
|
if(NOT TARGET ${target}-git-info-header)
|
||||||
add_custom_target(${TARGET_NAME}-git-info-header ALL
|
add_custom_target(${target}-git-info-header ALL
|
||||||
${CMAKE_COMMAND} -DGIT_INFO_FILE=${__filename} -DPREFIX=${__prefix}
|
${CMAKE_COMMAND} -DGIT_INFO_FILE=${filename} -P ${git_info_cmake_in_path}
|
||||||
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/GitInfo.cmake
|
BYPRODUCTS ${filename}
|
||||||
BYPRODUCTS ${__filename}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR})
|
|
||||||
endif()
|
endif()
|
||||||
# cmake-format: on
|
# cmake-format: on
|
||||||
|
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
|
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
|
||||||
target_sources(${TARGET_NAME} PRIVATE ${__filename})
|
target_sources(${target} PRIVATE ${filename})
|
||||||
add_dependencies(${TARGET_NAME} ${TARGET_NAME}-git-info-header)
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define PROJECT_VERSION_STR "@PROJECT_VERSION@"
|
|
||||||
#define PROJECT_VERSION_INT @PROJECT_VERSION_INT@
|
|
||||||
|
|
||||||
#cmakedefine PROJECT_NAME "@PROJECT_NAME@"
|
|
||||||
#cmakedefine AUTHOR_NAME "@AUTHOR_NAME@"
|
|
||||||
#cmakedefine AUTHOR_EMAIL "@AUTHOR_EMAIL@"
|
|
||||||
#cmakedefine DESCRIPTION "@PROJECT_DESCRIPTION@"
|
|
||||||
#cmakedefine BUILD_TYPE "@CMAKE_BUILD_TYPE@"
|
|
||||||
#cmakedefine BUILD_DATE "@MYX_TODAY@"
|
|
@ -5,31 +5,41 @@ myx_generate_private_config_header
|
|||||||
Вспомогательная функция для автоматической генерации заголовочного
|
Вспомогательная функция для автоматической генерации заголовочного
|
||||||
файла, содержащего информацию о проекте::
|
файла, содержащего информацию о проекте::
|
||||||
|
|
||||||
myx_generate_private_config_header(TARGET_NAME BASE_FILENAME)
|
myx_generate_private_config_header(TARGET BASE_FILENAME)
|
||||||
|
|
||||||
Обязательные параметры: `TARGET_NAME` - имя цели, с которой связан
|
Обязательные параметры: `TARGET` - имя цели, с которой связан заголовочный файл,
|
||||||
заголовочный файл, и `BASE_FILENAME` - имя генерируемого заголовочного файла.
|
и `BASE_FILENAME` - имя генерируемого заголовочного файла.
|
||||||
|
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
|
|
||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
function(myx_generate_private_config_header target base_filename)
|
||||||
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")
|
|
||||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(BUILD_DATE ${MYX_TODAY})
|
set(BUILD_DATE ${MYX_TODAY})
|
||||||
myx_project_version_int()
|
myx_project_version_int()
|
||||||
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
|
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
|
||||||
|
|
||||||
set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
|
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}")
|
||||||
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${__filename})
|
|
||||||
|
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
|
set(private_config_hpp_in
|
||||||
target_sources(${TARGET_NAME} PRIVATE ${__filename})
|
"#pragma once
|
||||||
|
|
||||||
|
#define PROJECT_VERSION_STR \"@PROJECT_VERSION@\"
|
||||||
|
#define PROJECT_VERSION_INT @PROJECT_VERSION_INT@
|
||||||
|
|
||||||
|
#cmakedefine PROJECT_NAME \"@PROJECT_NAME@\"
|
||||||
|
#cmakedefine AUTHOR_NAME \"@AUTHOR_NAME@\"
|
||||||
|
#cmakedefine AUTHOR_EMAIL \"@AUTHOR_EMAIL@\"
|
||||||
|
#cmakedefine DESCRIPTION \"@PROJECT_DESCRIPTION@\"
|
||||||
|
#cmakedefine BUILD_TYPE \"@CMAKE_BUILD_TYPE@\"
|
||||||
|
#cmakedefine BUILD_DATE \"@MYX_TODAY@\"
|
||||||
|
")
|
||||||
|
|
||||||
|
set(private_config_hpp_in_path "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target}_config_p.hpp.in")
|
||||||
|
file(WRITE ${private_config_hpp_in_path} ${private_config_hpp_in})
|
||||||
|
|
||||||
|
configure_file(${private_config_hpp_in_path} ${filename})
|
||||||
|
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
|
||||||
|
target_sources(${target} PRIVATE ${filename})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
# Добавление флага к списку используемых после проверки
|
|
||||||
# возможности его использования текущим компилятором
|
|
||||||
# Основано на https://github.com/bluescarni/yacma
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
|
|
||||||
macro(check_enable_cxx_compiler_flag FLAG)
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs TARGET)
|
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_QUIET TRUE)
|
|
||||||
check_cxx_compiler_flag("${FLAG}" check_cxx_flag)
|
|
||||||
unset(CMAKE_REQUIRED_QUIET)
|
|
||||||
|
|
||||||
if(check_cxx_flag)
|
|
||||||
myx_message_notice("'${FLAG}': flag is supported.")
|
|
||||||
if(ARG_TARGET)
|
|
||||||
target_compile_options(${ARG_TARGET} PUBLIC ${FLAG})
|
|
||||||
else()
|
|
||||||
add_compile_options(${FLAG})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
myx_message_status("'${FLAG}': flag is NOT supported.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
unset(check_cxx_flag CACHE)
|
|
||||||
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
|
||||||
unset(ARG_${__iter})
|
|
||||||
endforeach()
|
|
||||||
unset(ARG_UNPARSED_ARGUMENTS)
|
|
||||||
unset(multiValueArgs)
|
|
||||||
unset(oneValueArgs)
|
|
||||||
unset(options)
|
|
||||||
endmacro()
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
# Создание символических ссылок
|
|
||||||
macro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)
|
|
||||||
if(UNIX AND (NOT EXISTS ${LINKNAME}))
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
||||||
${ORIGINAL_FILENAME} ${LINKNAME})
|
|
||||||
else()
|
|
||||||
file(CREATE_LINK ${ORIGINAL_FILENAME} ${LINKNAME} SYMBOLIC)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endmacro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)
|
|
@ -1,9 +1,10 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
macro(myx_find_required_packages)
|
macro(myx_find_packages)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs)
|
set(oneValueArgs)
|
||||||
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private)
|
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private)
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
foreach(iter ${ARG_PACKAGES})
|
foreach(iter ${ARG_PACKAGES})
|
||||||
@ -24,11 +25,11 @@ macro(myx_find_required_packages)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
foreach(iter IN LISTS oneValueArgs multiValueArgs)
|
||||||
unset(ARG_${__iter})
|
unset(ARG_${iter})
|
||||||
endforeach()
|
endforeach()
|
||||||
unset(ARG_UNPARSED_ARGUMENTS)
|
unset(ARG_UNPARSED_ARGUMENTS)
|
||||||
unset(multiValueArgs)
|
unset(multiValueArgs)
|
||||||
unset(oneValueArgs)
|
unset(oneValueArgs)
|
||||||
unset(options)
|
unset(options)
|
||||||
endmacro(myx_find_required_packages)
|
endmacro(myx_find_packages)
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
macro(myx_add_gtest TARGET_NAME)
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs)
|
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
add_executable(${TARGET_NAME} ${ARG_UNPARSED_ARGUMENTS})
|
|
||||||
|
|
||||||
find_package(GTest)
|
|
||||||
if(GTest_FOUND)
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE GTest::GTest GTest::Main)
|
|
||||||
else()
|
|
||||||
if((NOT TARGET gtest) AND (NOT TARGET gtest_main))
|
|
||||||
add_subdirectory(/usr/src/googletest/googletest ${CMAKE_BINARY_DIR}/gtest)
|
|
||||||
endif()
|
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE gtest gtest_main)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
|
|
||||||
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
|
||||||
unset(ARG_${__iter})
|
|
||||||
endforeach()
|
|
||||||
unset(ARG_UNPARSED_ARGUMENTS)
|
|
||||||
unset(multiValueArgs)
|
|
||||||
unset(oneValueArgs)
|
|
||||||
unset(options)
|
|
||||||
endmacro()
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
#[=======================================================================[.rst:
|
#[=======================================================================[.rst:
|
||||||
myx_install_relative
|
install_relative
|
||||||
--------------------
|
----------------
|
||||||
|
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
|
|
||||||
macro(myx_install_relative STRIP_DIRECTORY)
|
macro(install_relative STRIP_DIRECTORY)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs DESTINATION)
|
set(oneValueArgs DESTINATION)
|
||||||
set(multiValueArgs FILES)
|
set(multiValueArgs FILES)
|
||||||
@ -16,4 +16,4 @@ macro(myx_install_relative STRIP_DIRECTORY)
|
|||||||
string(REPLACE ${STRIP_DIRECTORY} "" RELATIVE_DIR ${DIR})
|
string(REPLACE ${STRIP_DIRECTORY} "" RELATIVE_DIR ${DIR})
|
||||||
INSTALL(FILES ${FILE} DESTINATION ${ARG_DESTINATION}/${RELATIVE_DIR} ${ARG_UNPARSED_ARGUMENTS})
|
INSTALL(FILES ${FILE} DESTINATION ${ARG_DESTINATION}/${RELATIVE_DIR} ${ARG_UNPARSED_ARGUMENTS})
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro(myx_install_relative STRIP_DIRECTORY)
|
endmacro(install_relative STRIP_DIRECTORY)
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
include_guard(GLOBAL)
|
|
||||||
|
|
||||||
macro(myx_add_qtest TARGET_NAME)
|
|
||||||
set(options)
|
|
||||||
set(oneValueArgs)
|
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Core Test REQUIRED)
|
|
||||||
if(NOT Qt5Test_FOUND)
|
|
||||||
myx_message_fatal_error("Qt testing framework is not found")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(filename ${ARG_UNPARSED_ARGUMENTS})
|
|
||||||
get_filename_component(basename ${filename} NAME_WE)
|
|
||||||
list(APPEND cpps "${basename}.cpp")
|
|
||||||
list(APPEND hpps "${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)
|
|
||||||
|
|
||||||
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
|
|
||||||
|
|
||||||
unset(cpps)
|
|
||||||
unset(hpps)
|
|
||||||
unset(moc)
|
|
||||||
unset(mocs)
|
|
||||||
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
|
||||||
unset(ARG_${__iter})
|
|
||||||
endforeach()
|
|
||||||
unset(ARG_UNPARSED_ARGUMENTS)
|
|
||||||
unset(multiValueArgs)
|
|
||||||
unset(oneValueArgs)
|
|
||||||
unset(options)
|
|
||||||
endmacro()
|
|
||||||
|
|
@ -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)
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
if(CMAKE_COLOR_MAKEFILE)
|
|
||||||
check_enable_cxx_compiler_flag(-fcolor-diagnostics)
|
|
||||||
endif()
|
|
@ -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")
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
if(CMAKE_COLOR_MAKEFILE)
|
|
||||||
check_enable_cxx_compiler_flag(-fdiagnostics-color=auto)
|
|
||||||
endif()
|
|
@ -1,96 +0,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")
|
|
||||||
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)
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
if(NOT ARG_CONFIG)
|
|
||||||
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/uncrustify.cfg")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT EXISTS ${ARG_CONFIG})
|
|
||||||
myx_message_notice("MyxCMake: uncrustify config is not found")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT UNCRUSTIFY_EXE)
|
|
||||||
myx_message_notice("MyxCMake: uncrustify executable is not found")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT TARGET myx-uncrustify)
|
|
||||||
add_custom_target(myx-uncrustify)
|
|
||||||
endif()
|
|
||||||
if(NOT TARGET myx-uncrustify-check)
|
|
||||||
add_custom_target(myx-uncrustify-check)
|
|
||||||
endif()
|
|
||||||
if(NOT TARGET myx-uncrustify-append-comments)
|
|
||||||
add_custom_target(myx-uncrustify-append-comments)
|
|
||||||
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})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
get_target_property(__s2 ${TARGET_NAME} SOURCES)
|
|
||||||
if(__s2)
|
|
||||||
list(APPEND __all_sources ${__s2})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(iter ${__all_sources})
|
|
||||||
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
|
|
||||||
if(pos EQUAL -1)
|
|
||||||
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}
|
|
||||||
DEPENDS ${ARG_CONFIG}
|
|
||||||
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
|
||||||
-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})
|
|
||||||
|
|
||||||
list(APPEND __options --replace --no-backup)
|
|
||||||
add_custom_target(${TARGET_NAME}-uncrustify
|
|
||||||
DEPENDS ${__fixed_config}
|
|
||||||
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${__sources})
|
|
||||||
|
|
||||||
add_custom_target(${TARGET_NAME}-uncrustify-append-comments
|
|
||||||
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})
|
|
||||||
# cmake-format: on
|
|
||||||
|
|
||||||
add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)
|
|
||||||
add_dependencies(myx-uncrustify-check ${TARGET_NAME}-uncrustify-check)
|
|
||||||
add_dependencies(myx-uncrustify-append-comments ${TARGET_NAME}-uncrustify-append-comments)
|
|
||||||
endfunction()
|
|
@ -1,5 +0,0 @@
|
|||||||
/**
|
|
||||||
* @class $(fclass)
|
|
||||||
* @brief TODO
|
|
||||||
* @details TODO
|
|
||||||
*/
|
|
@ -1 +0,0 @@
|
|||||||
// EOF $(filename)
|
|
@ -1,6 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/**
|
|
||||||
* @file $(filename)
|
|
||||||
* @brief TODO
|
|
||||||
* @details TODO
|
|
||||||
*/
|
|
@ -1,5 +0,0 @@
|
|||||||
/**
|
|
||||||
* @fn $(fclass)::$(function)
|
|
||||||
* $(javaparam)
|
|
||||||
* @details TODO
|
|
||||||
*/
|
|
@ -1,31 +0,0 @@
|
|||||||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
|
||||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
|
||||||
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
|
||||||
|
|
||||||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
|
|
||||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
|
||||||
foreach(file ${files})
|
|
||||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
|
||||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
exec_program(
|
|
||||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
|
||||||
OUTPUT_VARIABLE rm_out
|
|
||||||
RETURN_VALUE rm_retval
|
|
||||||
)
|
|
||||||
if(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
|
||||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
|
||||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
endforeach(file)
|
|
||||||
|
|
||||||
# Удаление пустых каталогов
|
|
||||||
foreach(_file ${files})
|
|
||||||
set(_res 0)
|
|
||||||
while(_res EQUAL 0)
|
|
||||||
get_filename_component(_file ${_file} DIRECTORY)
|
|
||||||
execute_process(COMMAND rmdir ${_file} RESULT_VARIABLE _res OUTPUT_QUIET ERROR_QUIET)
|
|
||||||
endwhile()
|
|
||||||
endforeach()
|
|
||||||
|
|
@ -10,21 +10,17 @@
|
|||||||
|
|
||||||
Если определена переменная `MYX_CMAKE_USE_SYSTEM`, то выполняется
|
Если определена переменная `MYX_CMAKE_USE_SYSTEM`, то выполняется
|
||||||
поиск версии в каталогах перечисленных в переменной `CMAKE_MODULES_DIR`.
|
поиск версии в каталогах перечисленных в переменной `CMAKE_MODULES_DIR`.
|
||||||
|
|
||||||
Кроме того выполняется попытка поиска (MyxxCMake)[../../../../myxx] --
|
|
||||||
расширения для библиотеки, позволяющиего в режиме разработки программного
|
|
||||||
проекта использовать дополнительные инструменты для его сопровождения.
|
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
|
|
||||||
if(ENV{MYX_CMAKE_DIR})
|
|
||||||
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
|
|
||||||
endif()
|
|
||||||
if(MYX_CMAKE_DIR)
|
if(MYX_CMAKE_DIR)
|
||||||
find_package(MyxCMake 2.3.1 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
|
set(ENV{MYX_CMAKE_DIR} ${MYX_CMAKE_DIR})
|
||||||
|
endif()
|
||||||
|
if(DEFINED ENV{MYX_CMAKE_DIR})
|
||||||
|
find_package(MyxCMake 1.99.77 CONFIG PATHS $ENV{MYX_CMAKE_DIR} NO_DEFAULT_PATH REQUIRED)
|
||||||
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
||||||
else()
|
else()
|
||||||
if(MYX_CMAKE_USE_SYSTEM)
|
if(MYX_CMAKE_USE_SYSTEM)
|
||||||
find_package(MyxCMake 2.3.1 REQUIRED)
|
find_package(MyxCMake 1.99.77 REQUIRED)
|
||||||
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
||||||
else()
|
else()
|
||||||
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
|
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
|
||||||
@ -32,12 +28,3 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENV{MYXX_CMAKE_DIR})
|
|
||||||
set(MYXX_CMAKE_DIR $ENV{MYXX_CMAKE_DIR})
|
|
||||||
endif()
|
|
||||||
if(MYXX_CMAKE_DIR)
|
|
||||||
find_package(MyxxCMake CONFIG PATHS ${MYXX_CMAKE_DIR} NO_DEFAULT_PATH)
|
|
||||||
else()
|
|
||||||
find_package(MyxxCMake CONFIG PATHS "$ENV{XDG_DATA_DIR}/cmake" QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user