[CMake] Don't use CMakePushCheckState
authorPetr Hosek <phosek@google.com>
Fri, 2 Oct 2020 21:16:27 +0000 (14:16 -0700)
committerPetr Hosek <phosek@google.com>
Sat, 3 Oct 2020 00:13:34 +0000 (17:13 -0700)
When we call cmake_pop_check_state, we undo any changes to REQUIRED
variables performed by HandleLLVMOptions which is undesirable. Rather
use replacement which is what we've used prior to 8d26760a.

Differential Revision: https://reviews.llvm.org/D88756

llvm/runtimes/CMakeLists.txt

index ecf8ac4..598daa4 100644 (file)
@@ -98,9 +98,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
 
   include(CheckLibraryExists)
   include(CheckCCompilerFlag)
-  include(CMakePushCheckState)
-
-  cmake_push_check_state()
 
   # We don't have libc++ (yet)...
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++")
@@ -118,7 +115,8 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
   include(HandleLLVMOptions)
   include(FindPythonInterp)
 
-  cmake_pop_check_state()
+  # Remove the -nostdlib++ option we've added earlier.
+  string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
 
   # Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
   if(CMAKE_HOST_APPLE AND APPLE)