From 688d7b4942cde5be854893635297bae15a8470a3 Mon Sep 17 00:00:00 2001 From: Anton Zhilin Date: Wed, 13 Sep 2023 20:54:46 +0300 Subject: [PATCH] Initial fix --- cmake/CPM.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 19728920..f7a2d400 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -46,6 +46,13 @@ set(CURRENT_CPM_VERSION 1.0.0-development-version) get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH) if(CPM_DIRECTORY) + if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + get_directory_property(hasParent PARENT_DIRECTORY) + if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY OR ${hasParent}) + include(FetchContent) + endif() + endif() + if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY) if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION) message( @@ -56,9 +63,6 @@ It is recommended to upgrade CPM to the most recent version. \ See https://github.com/cpm-cmake/CPM.cmake for more information." ) endif() - if(${CMAKE_VERSION} VERSION_LESS "3.17.0") - include(FetchContent) - endif() return() endif()