diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-08-26 20:18:21 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-08-26 20:18:21 +0000 |
commit | d77135f8285d66d0f76974511c86fa0f9a8c0713 (patch) | |
tree | a936eff1c1ba8438899f9a394e9b3e1f0ac2af01 /libcxx/CMakeLists.txt | |
parent | 4b30e569be72f6dfcdf811c12eb34e2d4e4d4ce5 (diff) | |
download | bcm5719-llvm-d77135f8285d66d0f76974511c86fa0f9a8c0713.tar.gz bcm5719-llvm-d77135f8285d66d0f76974511c86fa0f9a8c0713.zip |
[libcxx] Remove installation rules on Darwin when it would overwrite the system installation.
Summary:
On Mac OS X overwriting `/usr/lib/libc++.dylib` can cause your computer to fail to boot. This patch tries to make it harder to do that accidentally.
If `CMAKE_SYSTEM_NAME` is `Darwin` and `CMAKE_INSTALL_PREFIX` is `/usr` don't generate installation rules unless the user explicitly provides `LIBCXX_OVERRIDE_DARWIN_INSTALL=ON`. Note that `CMAKE_INSTALL_PREFIX` is always absolute so we don't need to worry about things like `/usr/../usr`.
Reviewers: mclow.lists, beanz, jroelofs
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D12209
llvm-svn: 246070
Diffstat (limited to 'libcxx/CMakeLists.txt')
-rw-r--r-- | libcxx/CMakeLists.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 872adddb928..fb9e2bf2d54 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -56,6 +56,7 @@ 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) option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) # ABI Library options --------------------------------------------------------- @@ -95,6 +96,23 @@ option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) 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 #=============================================================================== |