beanz created this revision.
beanz added reviewers: mclow.lists, EricWF.
beanz added a subscriber: cfe-commits.

The current implementation doesn't work as intended because of CMake's caching 
behavior. The CMake set command doesn't globally override cached options.

This change removes LIBCXX_OVERRIDE_DARWIN_INSTALL, and instead defaults the 
options OFF on Darwin. The end result is the same, if you want to install the 
libraries or headers on Darwin you need to explicitly set the options.

http://reviews.llvm.org/D15161

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -55,8 +55,16 @@
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." 
${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
     "Define suffix of library directory name (32/64)")
-option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
-option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+
+set(INSTALL_HEADERS_DEFAULT ON)
+set(INSTALL_LIBRARY_DEFAULT ON)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  set(INSTALL_HEADERS_DEFAULT OFF)
+  set(INSTALL_LIBRARY_DEFAULT OFF)
+endif()
+option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." 
${INSTALL_HEADERS_DEFAULT})
+option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." 
${INSTALL_LIBRARY_DEFAULT})
+
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
@@ -133,23 +141,6 @@
 set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
     "The Profile-rt library used to build with code coverage")
 
-# Don't allow a user to accidentally overwrite the system libc++ installation 
on Darwin.
-# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for 
libc++
-# will not be generated and a warning will be issued.
-option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ 
installation." OFF)
-mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by 
default.
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT 
LIBCXX_OVERRIDE_DARWIN_INSTALL)
-  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
-    message(WARNING "Disabling libc++ install rules because installation would 
"
-                    "overwrite the systems installation. Configure with "
-                    "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this 
behaviour.")
-    mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override 
option.
-    set(LIBCXX_INSTALL_HEADERS OFF)
-    set(LIBCXX_INSTALL_LIBRARY OFF)
-  endif()
-endif()
-
 
#===============================================================================
 # Check option configurations
 
#===============================================================================


Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -55,8 +55,16 @@
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
     "Define suffix of library directory name (32/64)")
-option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
-option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+
+set(INSTALL_HEADERS_DEFAULT ON)
+set(INSTALL_LIBRARY_DEFAULT ON)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  set(INSTALL_HEADERS_DEFAULT OFF)
+  set(INSTALL_LIBRARY_DEFAULT OFF)
+endif()
+option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ${INSTALL_HEADERS_DEFAULT})
+option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ${INSTALL_LIBRARY_DEFAULT})
+
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
@@ -133,23 +141,6 @@
 set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
     "The Profile-rt library used to build with code coverage")
 
-# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
-# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
-# will not be generated and a warning will be issued.
-option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
-mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
-  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
-    message(WARNING "Disabling libc++ install rules because installation would "
-                    "overwrite the systems installation. Configure with "
-                    "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
-    mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
-    set(LIBCXX_INSTALL_HEADERS OFF)
-    set(LIBCXX_INSTALL_LIBRARY OFF)
-  endif()
-endif()
-
 #===============================================================================
 # Check option configurations
 #===============================================================================
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to