Skip to content

Commit

Permalink
CMake: avoid imbalanced cmake_policy push/pop if TIFF or CURL depende…
Browse files Browse the repository at this point in the history
…ncy cannot be found (fixes #3696)
  • Loading branch information
rouault authored and github-actions[bot] committed Apr 6, 2023
1 parent f628b2d commit 2304078
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmake/project-config.cmake.in
Expand Up @@ -13,12 +13,25 @@ endif()

include(CMakeFindDependencyMacro)

# We cannot have a find_dependency() call between cmake_policy(PUSH)/cmake_policy(POP)
# because find_dependency() issues a return() on failure, which results in
# imbalanced push/pop
# Cf https://gitlab.kitware.com/cmake/cmake/-/issues/17612
cmake_policy(PUSH)
cmake_policy(SET CMP0012 NEW)
if("@ENABLE_TIFF@")
find_dependency(TIFF)
set(PROJ_CONFIG_FIND_TIFF_DEP ON)
endif()
if("@CURL_ENABLED@")
set(PROJ_CONFIG_FIND_CURL_DEP ON)
endif()
cmake_policy(POP)

if(DEFINED PROJ_CONFIG_FIND_TIFF_DEP)
find_dependency(TIFF)
endif()

if(DEFINED PROJ_CONFIG_FIND_CURL_DEP)
# Chainload CURL usage requirements
find_dependency(CURL)
# Target CURL::libcurl only defined since CMake 3.12
Expand All @@ -30,7 +43,6 @@ if("@CURL_ENABLED@")
)
endif()
endif()
cmake_policy(POP)

function(set_variable_from_rel_or_absolute_path var root rel_or_abs_path)
if(IS_ABSOLUTE "${rel_or_abs_path}")
Expand Down

0 comments on commit 2304078

Please sign in to comment.