浏览代码

Merge topic 'FindBoost-config-mode'

685fa8bec0 FindBoost: Avoid leaking internal Boost_ROOT setting

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5445
Brad King 5 年之前
父节点
当前提交
fa60d56c87
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      Modules/FindBoost.cmake

+ 8 - 2
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 ()