From: Pasukhin Dmitry Date: Sat, 25 Oct 2025 14:49:04 +0000 (+0100) Subject: Configuration - Validate the configuration on CMake 3.10 and later (#762) X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=190c90c856fe6f9ec5f3c4ca3f7deae6189a1571;p=occt.git Configuration - Validate the configuration on CMake 3.10 and later (#762) - adm/cmake/gtest.cmake: check CMake version before using FetchContent; emit a warning and skip FetchContent-based GoogleTest setup when CMake < 3.11. - adm/cmake/occt_macros.cmake: wrap list(REMOVE_DUPLICATES ...) calls in if() checks to avoid operating on empty/unset variables. --- diff --git a/adm/cmake/gtest.cmake b/adm/cmake/gtest.cmake index 436713f35c..280188546c 100644 --- a/adm/cmake/gtest.cmake +++ b/adm/cmake/gtest.cmake @@ -26,6 +26,13 @@ if(GTest_FOUND) else() message(STATUS "Googletest not found in system paths") if(GTEST_USE_FETCHCONTENT) + # FetchContent requires CMake 3.11 or higher + if(CMAKE_VERSION VERSION_LESS "3.11") + message(WARNING "FetchContent requires CMake 3.11 or higher (current version: ${CMAKE_VERSION}). " + "Please either upgrade CMake, install Google Test manually, or disable BUILD_GTEST.") + set(GOOGLETEST_FOUND FALSE) + return() + endif() include(FetchContent) # Set option to disable GMock before declaring the content diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake index 228a7599e4..360a5306cf 100644 --- a/adm/cmake/occt_macros.cmake +++ b/adm/cmake/occt_macros.cmake @@ -332,8 +332,13 @@ function(EXCTRACT_TOOLKIT_FULL_DEPS SOLUTION_TYPE OCCT_TOOLKIT RESULT_TKS_AS_DEP list(APPEND OCCT_TOOLKIT_INCLUDE_FOLDERS ${DEP_INCLUDE_DIRS}) endforeach() - list(REMOVE_DUPLICATES OCCT_TOOLKIT_FULL_DEPS) - list(REMOVE_DUPLICATES OCCT_TOOLKIT_INCLUDE_FOLDERS) + if (OCCT_TOOLKIT_FULL_DEPS) + list(REMOVE_DUPLICATES OCCT_TOOLKIT_FULL_DEPS) + endif() + + if (OCCT_TOOLKIT_INCLUDE_FOLDERS) + list(REMOVE_DUPLICATES OCCT_TOOLKIT_INCLUDE_FOLDERS) + endif() set (${RESULT_TKS_AS_DEPS} ${OCCT_TOOLKIT_FULL_DEPS} PARENT_SCOPE) set (${RESULT_INCLUDE_FOLDERS} ${OCCT_TOOLKIT_INCLUDE_FOLDERS} PARENT_SCOPE)