Home | History | Annotate | Download | only in lib
      1 # Get sources
      2 file(GLOB LIBCXX_SOURCES ../src/*.cpp)
      3 if(WIN32)
      4   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
      5   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
      6 endif()
      7 
      8 # Add all the headers to the project for IDEs.
      9 if (MSVC_IDE OR XCODE)
     10   file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
     11   if(WIN32)
     12     file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h)
     13     list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS})
     14   endif()
     15   # Force them all into the headers dir on MSVC, otherwise they end up at
     16   # project scope because they don't have extensions.
     17   if (MSVC_IDE)
     18     source_group("Header Files" FILES ${LIBCXX_HEADERS})
     19   endif()
     20 endif()
     21 
     22 if (LIBCXX_ENABLE_SHARED)
     23   add_library(cxx SHARED
     24     ${LIBCXX_SOURCES}
     25     ${LIBCXX_HEADERS}
     26     )
     27 else()
     28   add_library(cxx STATIC
     29     ${LIBCXX_SOURCES}
     30     ${LIBCXX_HEADERS}
     31     )
     32 endif()
     33 
     34 if (DEFINED LIBCXX_CXX_ABI_DEPS)
     35   add_dependencies(cxx ${LIBCXX_CXX_ABI_DEPS})
     36 endif()
     37 
     38 # Generate library list.
     39 set(libraries ${LIBCXX_CXX_ABI_LIBRARIES})
     40 append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
     41 append_if(libraries LIBCXX_HAS_C_LIB c)
     42 append_if(libraries LIBCXX_HAS_M_LIB m)
     43 append_if(libraries LIBCXX_HAS_RT_LIB rt)
     44 append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
     45 
     46 target_link_libraries(cxx ${libraries})
     47 
     48 # Setup flags.
     49 append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
     50 append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
     51 
     52 if ( APPLE )
     53   if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
     54     list(APPEND compile_flags "-U__STRICT_ANSI__")
     55     list(APPEND link_flags
     56       "-compatibility_version 1"
     57       "-current_version ${LIBCXX_VERSION}"
     58       "-install_name /usr/lib/libc++.1.dylib"
     59       "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
     60       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
     61       "/usr/lib/libSystem.B.dylib")
     62   else()
     63     if ( ${CMAKE_OSX_SYSROOT} )
     64       list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
     65       if (OSX_HAS_ARMV7)
     66         set(OSX_RE_EXPORT_LINE
     67           "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
     68           "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
     69       else()
     70         set(OSX_RE_EXPORT_LINE
     71           "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
     72       endif()
     73     else()
     74       set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
     75     endif()
     76 
     77     list(APPEND link_flags
     78       "-compatibility_version 1"
     79       "-install_name /usr/lib/libc++.1.dylib"
     80       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
     81       "${OSX_RE_EXPORT_LINE}"
     82       "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp"
     83       "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp")
     84   endif()
     85 endif()
     86 
     87 string(REPLACE ";" " " link_flags "${link_flags}")
     88 
     89 set_target_properties(cxx
     90   PROPERTIES
     91     COMPILE_FLAGS "${compile_flags}"
     92     LINK_FLAGS    "${link_flags}"
     93     OUTPUT_NAME   "c++"
     94     VERSION       "1.0"
     95     SOVERSION     "1"
     96   )
     97 
     98 install(TARGETS cxx
     99   LIBRARY DESTINATION lib
    100   ARCHIVE DESTINATION lib
    101   )
    102