2010-12-11 03:47:54 +08:00
|
|
|
# Get sources
|
2012-03-19 23:40:23 +08:00
|
|
|
file(GLOB LIBCXX_SOURCES ../src/*.cpp)
|
2011-09-23 03:10:18 +08:00
|
|
|
if(WIN32)
|
2012-03-19 23:40:23 +08:00
|
|
|
file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
|
|
|
|
list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
|
2014-11-26 05:57:41 +08:00
|
|
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
|
|
|
|
file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c)
|
|
|
|
list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
|
2011-09-23 03:10:18 +08:00
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
|
|
|
|
# Add all the headers to the project for IDEs.
|
|
|
|
if (MSVC_IDE OR XCODE)
|
2012-03-19 23:40:23 +08:00
|
|
|
file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
|
2011-09-23 03:10:18 +08:00
|
|
|
if(WIN32)
|
2012-03-19 23:40:23 +08:00
|
|
|
file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h)
|
|
|
|
list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS})
|
2011-09-23 03:10:18 +08:00
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
# Force them all into the headers dir on MSVC, otherwise they end up at
|
|
|
|
# project scope because they don't have extensions.
|
|
|
|
if (MSVC_IDE)
|
2012-03-19 23:40:23 +08:00
|
|
|
source_group("Header Files" FILES ${LIBCXX_HEADERS})
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXX_ENABLE_SHARED)
|
|
|
|
add_library(cxx SHARED
|
2012-03-19 23:40:23 +08:00
|
|
|
${LIBCXX_SOURCES}
|
|
|
|
${LIBCXX_HEADERS}
|
2010-12-11 03:47:54 +08:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
add_library(cxx STATIC
|
2012-03-19 23:40:23 +08:00
|
|
|
${LIBCXX_SOURCES}
|
|
|
|
${LIBCXX_HEADERS}
|
2010-12-11 03:47:54 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-03-03 23:59:51 +08:00
|
|
|
#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}")
|
|
|
|
endif()
|
|
|
|
|
2013-01-01 03:34:21 +08:00
|
|
|
if (DEFINED LIBCXX_CXX_ABI_DEPS)
|
2014-06-25 04:32:11 +08:00
|
|
|
add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
|
2013-01-01 03:34:21 +08:00
|
|
|
endif()
|
2012-12-01 05:02:29 +08:00
|
|
|
|
2015-03-03 23:59:51 +08:00
|
|
|
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()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
# 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)
|
2011-05-24 20:54:00 +08:00
|
|
|
append_if(libraries LIBCXX_HAS_RT_LIB rt)
|
2010-12-11 03:47:54 +08:00
|
|
|
append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
|
|
|
|
|
|
|
|
target_link_libraries(cxx ${libraries})
|
|
|
|
|
|
|
|
# Setup flags.
|
2014-11-15 14:26:30 +08:00
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC)
|
|
|
|
append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2015-03-27 17:00:45 +08:00
|
|
|
if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
|
|
|
|
LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
|
2015-02-21 10:26:24 +08:00
|
|
|
if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION)
|
|
|
|
set(LIBCXX_LIBCPPABI_VERSION "2")
|
|
|
|
endif()
|
|
|
|
|
2013-09-02 15:28:03 +08:00
|
|
|
if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
|
2014-11-15 14:26:30 +08:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__")
|
|
|
|
list(APPEND LIBCXX_LINK_FLAGS
|
2013-09-02 15:28:03 +08:00
|
|
|
"-compatibility_version 1"
|
2014-08-13 01:32:07 +08:00
|
|
|
"-current_version 1"
|
2013-09-02 15:28:03 +08:00
|
|
|
"-install_name /usr/lib/libc++.1.dylib"
|
|
|
|
"-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
|
|
|
|
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
|
|
|
|
"/usr/lib/libSystem.B.dylib")
|
|
|
|
else()
|
|
|
|
if ( ${CMAKE_OSX_SYSROOT} )
|
|
|
|
list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
|
|
|
|
if (OSX_HAS_ARMV7)
|
|
|
|
set(OSX_RE_EXPORT_LINE
|
|
|
|
"${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
|
|
|
|
"-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
|
|
|
|
else()
|
|
|
|
set(OSX_RE_EXPORT_LINE
|
|
|
|
"-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
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()
|
|
|
|
|
2014-11-15 14:26:30 +08:00
|
|
|
list(APPEND LIBCXX_LINK_FLAGS
|
2013-09-02 15:28:03 +08:00
|
|
|
"-compatibility_version 1"
|
|
|
|
"-install_name /usr/lib/libc++.1.dylib"
|
|
|
|
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
|
|
|
|
"${OSX_RE_EXPORT_LINE}"
|
|
|
|
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp"
|
|
|
|
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-11-15 14:26:30 +08:00
|
|
|
string(REPLACE ";" " " LIBCXX_COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}")
|
|
|
|
string(REPLACE ";" " " LIBCXX_LINK_FLAGS "${LIBCXX_LINK_FLAGS}")
|
2013-09-02 15:28:03 +08:00
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
set_target_properties(cxx
|
|
|
|
PROPERTIES
|
2014-11-15 14:26:30 +08:00
|
|
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
|
|
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
2010-12-11 03:47:54 +08:00
|
|
|
OUTPUT_NAME "c++"
|
|
|
|
VERSION "1.0"
|
|
|
|
SOVERSION "1"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(TARGETS cxx
|
2014-12-29 20:15:47 +08:00
|
|
|
LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
|
|
|
|
ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX}
|
2010-12-11 03:47:54 +08:00
|
|
|
)
|