Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -38,47 +38,71 @@ add_dependencies(cxx LIBCXX_CXX_ABI_DEPS) endif() +# We need to use a bunch of special link flags for apple in these cases. +if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" OR + LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi")) + set(APPLE_SPECIAL_LINK_CONFIG TRUE) +endif() + + +if (NOT APPLE_SPECIAL_LINK_CONFIG) + #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() + # Link libc++ to the ABI library. + target_link_libraries(cxx ${LIBCXX_CXX_ABI_LIBRARY}) +endif() + # Generate library list. -set(libraries ${LIBCXX_CXX_ABI_LIBRARY}) +set(libraries "") 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_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() target_link_libraries(cxx ${libraries}) # Setup flags. append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC) append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) -if ( APPLE ) + +if ( APPLE_SPECIAL_LINK_CONFIG ) + # Attempt to guess the location of libc++abi.dylib. Start by setting it to the + # Default location. + set(LIBCXX_CXX_ABI_LIBRARY_LOCATION "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") + # If libc++abi is an intree CMake target get its name from the target + # properties. + if(LIBCXX_CXX_ABI_LIBRARY STREQUAL "cxxabi") + get_target_property(LIBCXX_CXX_ABI_LIBRARY_LOCATION TARGET cxxabi PROPERTY LOCATION) + # Otherwise if the user has told us where to look then construct the name + # from the patch. + elseif (LIBCXX_CXX_ABI_LIBRARY STREQUAL "c++abi" AND DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH) + set(LIBCXX_CXX_ABI_LIBRARY_LOCATION "${LIBCXX_CXX_ABI_LIBRARY_PATH}/libc++abi.dylib") + endif() if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__") list(APPEND LIBCXX_LINK_FLAGS "-compatibility_version 1" "-current_version 1" "-install_name /usr/lib/libc++.1.dylib" - "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" + "-Wl,-reexport_library,${LIBCXX_CXX_ABI_LIBRARY_LOCATION}" "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "${LIBCXX_CXX_ABI_LIBRARY_LOCATION}" "/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") + "-Wl,-reexport_library,${LIBCXX_CXX_ABI_LIBRARY_LOCATION}") 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") + set (OSX_RE_EXPORT_LINE "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") endif() list(APPEND LIBCXX_LINK_FLAGS @@ -87,7 +111,8 @@ "-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") + "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp" + "${LIBCXX_CXX_ABI_LIBRARY_LOCATION}") endif() endif()