summaryrefslogtreecommitdiffstats
path: root/libcxx/lib
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-07-29 00:03:51 +0000
committerEric Fiselier <eric@efcs.ca>2015-07-29 00:03:51 +0000
commit7eb30deff17e6e137cad170b340fcc7cf5f70761 (patch)
treeb4aca259e13d05e1b865bcb89c1f5f684dc47a6e /libcxx/lib
parentcfe41f050c0c00a0840bd10907d9d22605e1c115 (diff)
downloadbcm5719-llvm-7eb30deff17e6e137cad170b340fcc7cf5f70761.tar.gz
bcm5719-llvm-7eb30deff17e6e137cad170b340fcc7cf5f70761.zip
[libcxx] Cleanup CMake configuration and integrate with LLVM
Summary: This patch contains the following changes: 1. Require that libc++ can find a LLVM source directory. This is done the same way as `libc++abi` currently does. 2. Cleanup ugly configuration code in CMakeLists.txt by using `add_flags`, `add_flags_if`, and `add_flags_if_supported` macros. The goals for this patch are: 1. Help libc++ be more consistent with how LLVM handles CMake options (see PR23670 PR23671). 2. Make it easier to use sanitizers using the `LLVM_USE_SANITIZER` option. 3. Make libc++'s CMakeLists.txt file easier to understand and change. 4. Move towards allowing libc++ to create Sphinx documentation (see http://efcs.ca/libcxx-docs). 5. Move towards allowing libc++ to use other LLVM utilities such as `not` and `FileCheck`. Reviewers: mclow.lists, jroelofs, danalbert Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11308 llvm-svn: 243503
Diffstat (limited to 'libcxx/lib')
-rw-r--r--libcxx/lib/CMakeLists.txt68
1 files changed, 25 insertions, 43 deletions
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index a32f2931447..26dee6765c7 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -25,48 +25,23 @@ if (MSVC_IDE OR XCODE)
endif()
if (LIBCXX_ENABLE_SHARED)
- add_library(cxx SHARED
- ${LIBCXX_SOURCES}
- ${LIBCXX_HEADERS}
- )
+ add_library(cxx SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
else()
- add_library(cxx STATIC
- ${LIBCXX_SOURCES}
- ${LIBCXX_HEADERS}
- )
-endif()
-
-#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
-if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
- target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
+ add_library(cxx STATIC ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
endif()
if (DEFINED LIBCXX_CXX_ABI_DEPS)
add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
endif()
-set(libraries "")
-if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
- # TODO(ericwf): Remove these GNU specific linker flags and let CMake do the
- # configuration. This will be more portable.
- list(APPEND libraries "-Wl,--whole-archive" "-Wl,-Bstatic")
- list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}")
- list(APPEND libraries "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
-else()
- list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}")
-endif()
+#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
+add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
-# Generate library list.
-append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
-append_if(libraries LIBCXX_HAS_C_LIB c)
-append_if(libraries LIBCXX_HAS_M_LIB m)
-append_if(libraries LIBCXX_HAS_RT_LIB rt)
-append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
-
-if (LIBCXX_COVERAGE_LIBRARY)
- target_link_libraries(cxx ${LIBCXX_COVERAGE_LIBRARY})
-endif()
-target_link_libraries(cxx ${libraries})
+add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
+
+add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
+add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
if (APPLE AND LLVM_USE_SANITIZER)
if ("${LLVM_USE_SANITIZER}" STREQUAL "Address")
@@ -89,15 +64,21 @@ if (APPLE AND LLVM_USE_SANITIZER)
set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}")
set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE)
message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}")
- target_link_libraries(cxx "${LIBCXX_SANITIZER_LIBRARY}")
- target_link_libraries(cxx "-Wl,-rpath,${LIBDIR}")
+ add_library_flags("${LIBCXX_SANITIZER_LIBRARY}")
+ add_link_flags("-Wl,-rpath,${LIBDIR}")
endif()
endif()
+# Generate library list.
+add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
+add_library_flags_if(LIBCXX_HAS_C_LIB c)
+add_library_flags_if(LIBCXX_HAS_M_LIB m)
+add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
+add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
# Setup flags.
-append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC)
-append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
+add_flags_if_supported(-fPIC)
+add_link_flags_if_supported(-nodefaultlibs)
if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
@@ -106,8 +87,8 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
endif()
if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
- list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__")
- list(APPEND LIBCXX_LINK_FLAGS
+ add_definitions(-D__STRICT_ANSI__)
+ add_link_flags(
"-compatibility_version 1"
"-current_version 1"
"-install_name /usr/lib/libc++.1.dylib"
@@ -129,7 +110,7 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
endif()
- list(APPEND LIBCXX_LINK_FLAGS
+ add_link_flags(
"-compatibility_version 1"
"-install_name /usr/lib/libc++.1.dylib"
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
@@ -139,8 +120,9 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
endif()
endif()
-string(REPLACE ";" " " LIBCXX_COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}")
-string(REPLACE ";" " " LIBCXX_LINK_FLAGS "${LIBCXX_LINK_FLAGS}")
+target_link_libraries(cxx ${LIBCXX_LIBRARIES})
+split_list(LIBCXX_COMPILE_FLAGS)
+split_list(LIBCXX_LINK_FLAGS)
set_target_properties(cxx
PROPERTIES
OpenPOWER on IntegriCloud