This commit is contained in:
Andrei Astafev 2022-10-24 20:03:42 +03:00
parent b0dc31b1d5
commit 96cdd184fa
10 changed files with 39 additions and 25 deletions

View File

@ -1,7 +1,15 @@
cmake_policy(PUSH) cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # IN_LIST operator cmake_policy(SET CMP0057 NEW) # IN_LIST operator
# Каталог для модулей, выполняющих поиск библиотек # CMake выполняет проверку системного окружения с помощью модулей,
# расположенных в следующих каталогах:
# /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") set(MYX_CMAKE_FIND_DIR "${PROJECT_SOURCE_DIR}/cmake/find")
if(IS_DIRECTORY "${MYX_CMAKE_FIND_DIR}") if(IS_DIRECTORY "${MYX_CMAKE_FIND_DIR}")
if(NOT ${MYX_CMAKE_FIND_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${MYX_CMAKE_FIND_DIR} IN_LIST CMAKE_MODULE_PATH)
@ -14,6 +22,7 @@ get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTO
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_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")
@ -22,9 +31,11 @@ else()
include(FetchContent) include(FetchContent)
endif() endif()
# Загрузка стандартных модулей
include(GNUInstallDirs) include(GNUInstallDirs)
include(CMakeDependentOption) include(CMakeDependentOption)
# Полезные макросы
include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake) include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake) include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake) include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)

View File

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

View File

@ -1,33 +1,34 @@
include_guard(GLOBAL) include_guard(GLOBAL)
# based on https://github.com/bluescarni/yacma # Добавление флага к списку используемых после проверки
# возможности его использования текущим компилятором
# Основано на https://github.com/bluescarni/yacma
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
macro(check_enable_cxx_compiler_flag flag) macro(check_enable_cxx_compiler_flag FLAG)
set(options) set(options)
set(oneValueArgs TARGET) set(oneValueArgs TARGET)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(CMAKE_REQUIRED_QUIET TRUE) set(CMAKE_REQUIRED_QUIET TRUE)
check_cxx_compiler_flag("${flag}" check_cxx_flag) check_cxx_compiler_flag("${FLAG}" check_cxx_flag)
unset(CMAKE_REQUIRED_QUIET) unset(CMAKE_REQUIRED_QUIET)
if(check_cxx_flag) if(check_cxx_flag)
myx_message_notice("'${flag}': flag is supported.") myx_message_notice("'${FLAG}': flag is supported.")
if(ARG_TARGET) if(ARG_TARGET)
target_compile_options(${ARG_TARGET} PUBLIC ${flag}) target_compile_options(${ARG_TARGET} PUBLIC ${FLAG})
else() else()
add_compile_options(${flag}) add_compile_options(${FLAG})
endif() endif()
else() else()
myx_message_status("'${flag}': flag is NOT supported.") myx_message_status("'${FLAG}': flag is NOT supported.")
endif() endif()
unset(check_cxx_flag CACHE) unset(check_cxx_flag CACHE)
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)

View File

@ -1,11 +1,13 @@
include_guard(GLOBAL) include_guard(GLOBAL)
macro(myx_create_symlink original linkname) # Создание символических ссылок
if(UNIX AND (NOT EXISTS ${linkname})) macro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)
if(UNIX AND (NOT EXISTS ${LINKNAME}))
if(${CMAKE_VERSION} VERSION_LESS "3.14.0") if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${original} ${linkname}) execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${ORIGINAL_FILENAME} ${LINKNAME})
else() else()
file(CREATE_LINK ${original} ${linkname} SYMBOLIC) file(CREATE_LINK ${ORIGINAL_FILENAME} ${LINKNAME} SYMBOLIC)
endif() endif()
endif() endif()
endmacro(myx_create_symlink original linkname) endmacro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)

View File

@ -24,8 +24,8 @@ 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)

View File

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

View File

@ -1 +1 @@
2.1.92 2.1.93

View File

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

2
debian/changelog vendored
View File

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

View File

@ -20,11 +20,11 @@ if(ENV{MYX_CMAKE_DIR})
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR}) set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
endif() endif()
if(MYX_CMAKE_DIR) if(MYX_CMAKE_DIR)
find_package(MyxCMake 2.1.92 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH) find_package(MyxCMake 2.1.93 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===") myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
else() else()
if(MYX_CMAKE_USE_SYSTEM) if(MYX_CMAKE_USE_SYSTEM)
find_package(MyxCMake 2.1.92 REQUIRED) find_package(MyxCMake 2.1.93 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)