This commit is contained in:
2023-08-28 13:40:57 +03:00
parent f639f6eff5
commit 2bbb4a9b33
9 changed files with 21 additions and 9 deletions

View File

@ -28,13 +28,17 @@ find_package(Git QUIET)
option(ENABLE_DOWNLOAD_CONTENT "Enable download content" ON)
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
function(myx_download_content NAME)
set(options AUTOFETCH AUTOPULL)
set(oneValueArgs)
set(multiValueArgs DOWNLOAD_DIR GIT_REPOSITORY GIT_TAG)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT CMAKE_SCRIPT_MODE_FILE)
if(CMAKE_SCRIPT_MODE_FILE)
include(${CMAKE_CURRENT_LIST_DIR}/ProjectIsTopLevel.cmake)
else()
if(TARGET myx-download-${NAME})
return()
else()
@ -45,6 +49,10 @@ function(myx_download_content NAME)
endif()
endif()
if(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()
if(NOT ARG_DOWNLOAD_DIR)
set(ARG_DOWNLOAD_DIR "_downloads")
endif()

View File

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