From 24436a3122926b090cd294d5f772a66991a11a52 Mon Sep 17 00:00:00 2001 From: Andrei Astafev Date: Thu, 17 Aug 2023 12:18:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20MyxCMake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/myx/MyxCMakeConfigVersion.cmake | 2 +- cmake/myx/lib/DownloadContent.cmake | 32 ++++++++++++++++++--------- cmake/myx/lib/TargetSetupQt.cmake | 4 ++-- cmake/myx_setup.cmake | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/cmake/myx/MyxCMakeConfigVersion.cmake b/cmake/myx/MyxCMakeConfigVersion.cmake index e2f97a5..4243a9a 100644 --- a/cmake/myx/MyxCMakeConfigVersion.cmake +++ b/cmake/myx/MyxCMakeConfigVersion.cmake @@ -1,4 +1,4 @@ -set(MYX_CMAKE_PACKAGE_VERSION "2.4.10") +set(MYX_CMAKE_PACKAGE_VERSION "2.4.12") if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) set(PACKAGE_VERSION_COMPATIBLE FALSE) else() diff --git a/cmake/myx/lib/DownloadContent.cmake b/cmake/myx/lib/DownloadContent.cmake index aecca67..530a856 100644 --- a/cmake/myx/lib/DownloadContent.cmake +++ b/cmake/myx/lib/DownloadContent.cmake @@ -7,15 +7,20 @@ myx_download_content myx_download_content(NAME [ DOWNLOAD_DIR dir ] | [ GIT_REPOSITORY url ] | - [ GIT_TAG tag ] ) + [ GIT_TAG tag ] | + [ AUTOFETCH ] | [ AUTOPULL ] ) Обязательный параметр: `NAME` - имя целевого каталога. Параметр `DOWNLOAD_DIR` содержит имя каталога, в который будет загружаться -содержимое (по умолчанию `downloads`). +содержимое (по умолчанию `_downloads`). Параметр `GIT_REPOSITORY` содержит адрес внешнего проекта, который нужно загрузить с помощью git. Параметр `GIT_TAG` содержит используемые метку, идентификатор коммита или ветку в загружаемом репозитории. +Если указана опция `AUTOFETCH`, то на этапе конфигурирования для загруженного +репозитория будут скачиваться изменения. +Если указана опция `AUTOPULL`, то на этапе конфигурирования из загруженного +репозитория будет изменяться рабочий каталог. #]=======================================================================] @@ -24,7 +29,7 @@ find_package(Git QUIET) option(ENABLE_DOWNLOAD_CONTENT "Enable download content" ON) function(myx_download_content NAME) - set(options) + set(options AUTOFETCH AUTOPULL) set(oneValueArgs) set(multiValueArgs DOWNLOAD_DIR GIT_REPOSITORY GIT_TAG) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -53,25 +58,30 @@ function(myx_download_content NAME) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DOWNLOAD_DIR}) endif() + set(WORK_DIR "${ARG_DOWNLOAD_DIR}/${NAME}") if(ENABLE_DOWNLOAD_CONTENT AND GIT_EXECUTABLE AND ARG_GIT_REPOSITORY) - if(NOT IS_DIRECTORY ${ARG_DOWNLOAD_DIR}/${NAME}) + if(NOT IS_DIRECTORY ${WORK_DIR}) execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ARG_GIT_REPOSITORY} ${NAME} WORKING_DIRECTORY ${ARG_DOWNLOAD_DIR}) else() - execute_process(COMMAND ${GIT_EXECUTABLE} fetch - WORKING_DIRECTORY ${ARG_DOWNLOAD_DIR}/${NAME}) + if(ARG_AUTOFETCH) + execute_process(COMMAND ${GIT_EXECUTABLE} fetch + WORKING_DIRECTORY ${WORK_DIR}) + endif() endif() if(ARG_GIT_TAG) execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${ARG_GIT_TAG} - WORKING_DIRECTORY ${ARG_DOWNLOAD_DIR}/${NAME}) + WORKING_DIRECTORY ${WORK_DIR}) else() - execute_process(COMMAND ${GIT_EXECUTABLE} pull - WORKING_DIRECTORY ${ARG_DOWNLOAD_DIR}/${NAME}) + if(ARG_AUTOPULL) + execute_process(COMMAND ${GIT_EXECUTABLE} pull + WORKING_DIRECTORY ${WORK_DIR}) + endif() endif() endif() - if(NOT CMAKE_SCRIPT_MODE_FILE) - add_subdirectory(${ARG_DOWNLOAD_DIR}/${NAME} EXCLUDE_FROM_ALL) + if(NOT CMAKE_SCRIPT_MODE_FILE AND EXISTS "${WORK_DIR}/CMakeLists.txt") + add_subdirectory(${WORK_DIR} EXCLUDE_FROM_ALL) endif() endfunction() diff --git a/cmake/myx/lib/TargetSetupQt.cmake b/cmake/myx/lib/TargetSetupQt.cmake index d149fe2..893075c 100644 --- a/cmake/myx/lib/TargetSetupQt.cmake +++ b/cmake/myx/lib/TargetSetupQt.cmake @@ -76,7 +76,7 @@ function(myx_target_setup_qt TARGET_NAME) endif() if(ARG_UI) - if(NOT COMMAND qt${myx_ver_qt}_wrap_ui) + if(NOT COMMAND qt${myx_qt_ver}_wrap_ui) message(WARNING "MyxCMake: Widgets is required to process UI") else() if(myx_qt_ver EQUAL 5) @@ -100,7 +100,7 @@ function(myx_target_setup_qt TARGET_NAME) # Формирование файла ресурсов с переводами if(tr AND ARG_LANGS) - if(NOT COMMAND qt${myx_ver_qt}_create_translation) + if(NOT COMMAND qt${myx_qt_ver}_create_translation) message(WARNING "MyxCMake: LinguistTools is required to process LANGS") else() # Заглавие файла ресурсов diff --git a/cmake/myx_setup.cmake b/cmake/myx_setup.cmake index d4733e6..a2155fd 100644 --- a/cmake/myx_setup.cmake +++ b/cmake/myx_setup.cmake @@ -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.4.10 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH) + find_package(MyxCMake 2.4.12 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.4.10 REQUIRED) + find_package(MyxCMake 2.4.12 REQUIRED) myx_message_notice("== MyxCMake directory: ${MyxCMake_CONFIG} ==") else() include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)