[libcxx-commits] [PATCH] D61403: [libcxx] cmake - guard list remove

Brian Cain via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 1 14:29:20 PDT 2019


bcain created this revision.
bcain added reviewers: EricWF, mclow.lists.
bcain added a project: libc++.
Herald added subscribers: jfb, ldionne, christof, mgorny.

REMOVE_ITEM fails if CMAKE_REQUIRED_LIBRARIES is empty.


Repository:
  rCXX libc++

https://reviews.llvm.org/D61403

Files:
  libcxx/cmake/Modules/CheckLibcxxAtomic.cmake


Index: libcxx/cmake/Modules/CheckLibcxxAtomic.cmake
===================================================================
--- libcxx/cmake/Modules/CheckLibcxxAtomic.cmake
+++ libcxx/cmake/Modules/CheckLibcxxAtomic.cmake
@@ -34,10 +34,12 @@
 # Perform the check for 64bit atomics without libatomic. It may have been
 # added to the required libraries during in the configuration of LLVM, which
 # would cause the check for CXX atomics without libatomic to incorrectly pass.
-set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
-list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic")
-check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
-set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
+if (CMAKE_REQUIRED_LIBRARIES)
+  set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+  list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic")
+  check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
+  set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
+endif()
 
 check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
 # If not, check if the library exists, and atomics work with it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61403.197641.patch
Type: text/x-patch
Size: 1133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190501/42d5240e/attachment-0001.bin>


More information about the libcxx-commits mailing list