[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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246070 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e94b4840ef
commit
961269db1b
@ -56,6 +56,7 @@ option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS
|
|||||||
set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
||||||
"Define suffix of library directory name (32/64)")
|
"Define suffix of library directory name (32/64)")
|
||||||
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
|
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)
|
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
|
||||||
|
|
||||||
# ABI Library options ---------------------------------------------------------
|
# ABI Library options ---------------------------------------------------------
|
||||||
@ -95,6 +96,23 @@ option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
|
|||||||
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
|
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
|
||||||
"The Profile-rt library used to build with code coverage")
|
"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
|
# Check option configurations
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
@ -41,11 +41,13 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
|
|||||||
file(COPY "${incpath}/${fpath}"
|
file(COPY "${incpath}/${fpath}"
|
||||||
DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}"
|
DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}"
|
||||||
)
|
)
|
||||||
install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}"
|
if (LIBCXX_INSTALL_HEADERS)
|
||||||
DESTINATION include/c++/v1/${dstdir}
|
install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}"
|
||||||
COMPONENT libcxx
|
DESTINATION include/c++/v1/${dstdir}
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
COMPONENT libcxx
|
||||||
)
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||||
|
)
|
||||||
|
endif()
|
||||||
list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}")
|
list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -133,15 +133,18 @@ set_target_properties(cxx
|
|||||||
SOVERSION "1"
|
SOVERSION "1"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS cxx
|
if (LIBCXX_INSTALL_LIBRARY)
|
||||||
LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
|
install(TARGETS cxx
|
||||||
ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
|
LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
|
||||||
)
|
ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
|
||||||
|
)
|
||||||
if (NOT CMAKE_CONFIGURATION_TYPES)
|
endif()
|
||||||
add_custom_target(install-libcxx
|
|
||||||
DEPENDS cxx
|
if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR
|
||||||
COMMAND "${CMAKE_COMMAND}"
|
LIBCXX_INSTALL_HEADERS))
|
||||||
-DCMAKE_INSTALL_COMPONENT=libcxx
|
add_custom_target(install-libcxx
|
||||||
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
DEPENDS cxx
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
-DCMAKE_INSTALL_COMPONENT=libcxx
|
||||||
|
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user