summaryrefslogtreecommitdiff
path: root/Modules/FindBoost.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-10-30 09:29:31 -0400
committerBrad King <brad.king@kitware.com>2020-10-30 09:42:43 -0400
commit685fa8bec064e5776319c8a42c02578bd85b6a7d (patch)
tree68699313efdc575a40453da5e6c224c7ccf1a4c3 /Modules/FindBoost.cmake
parentf506cc6bb2d16b8876bd6e38741e80fc88482d1f (diff)
downloadcmake-685fa8bec064e5776319c8a42c02578bd85b6a7d.tar.gz
FindBoost: Avoid leaking internal Boost_ROOT setting
Since commit 4b2a61946f (FindBoost: Honor BOOST_ROOT when finding upstream BoostConfig, 2020-10-22, v3.19.0-rc2~14^2) we accidentally leak our internal setting of `Boost_ROOT`. Revise the logic to unset our temporary value. Fixes: #21379
Diffstat (limited to 'Modules/FindBoost.cmake')
-rw-r--r--Modules/FindBoost.cmake10
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 77868f4bb9..00e4ff1d21 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -450,13 +450,19 @@ if (NOT Boost_NO_BOOST_CMAKE)
# Do the same find_package call but look specifically for the CMake version.
# Note that args are passed in the Boost_FIND_xxxxx variables, so there is no
# need to delegate them to this find_package call.
- cmake_policy(PUSH)
if(BOOST_ROOT AND NOT Boost_ROOT)
+ # Honor BOOST_ROOT by setting Boost_ROOT with CMP0074 NEW behavior.
+ cmake_policy(PUSH)
cmake_policy(SET CMP0074 NEW)
set(Boost_ROOT "${BOOST_ROOT}")
+ set(_Boost_ROOT_FOR_CONFIG 1)
endif()
find_package(Boost QUIET NO_MODULE ${_boost_FIND_PACKAGE_ARGS})
- cmake_policy(POP)
+ if(_Boost_ROOT_FOR_CONFIG)
+ unset(_Boost_ROOT_FOR_CONFIG)
+ unset(Boost_ROOT)
+ cmake_policy(POP)
+ endif()
if (DEFINED Boost_DIR)
mark_as_advanced(Boost_DIR)
endif ()