myx update

This commit is contained in:
Andrei Astafev 2023-02-17 14:36:30 +03:00
parent c6673c84b8
commit 96443f5218
5 changed files with 86 additions and 6 deletions

View File

@ -50,6 +50,7 @@ include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWarning.cmake)
include(${MYX_CMAKE_LIB_DIR}/DirectoriesGuards.cmake)
include(${MYX_CMAKE_LIB_DIR}/SemanticProjectVersion.cmake)
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWrapper.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddExternalTarget.cmake)
include(${MYX_CMAKE_LIB_DIR}/FetchContentAdd.cmake)
set(MYX_CMAKE_TOOLCHAINS_DIR "${MYX_CMAKE_LIB_DIR}/toolchains")

View File

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

View File

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

View File

@ -19,9 +19,6 @@ myx_add_object_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()
@ -31,6 +28,9 @@ function(myx_add_object_library TARGET_NAME)
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)

View File

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