Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1 | # Get sources |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 2 | file(GLOB LIBCXX_SOURCES ../src/*.cpp) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 3 | if(WIN32) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 4 | file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp) |
| 5 | list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES}) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 6 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 7 | |
| 8 | # Add all the headers to the project for IDEs. |
| 9 | if (MSVC_IDE OR XCODE) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 10 | file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 11 | if(WIN32) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 12 | file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h) |
| 13 | list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS}) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 14 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 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) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 18 | source_group("Header Files" FILES ${LIBCXX_HEADERS}) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 19 | endif() |
| 20 | endif() |
| 21 | |
| 22 | if (LIBCXX_ENABLE_SHARED) |
| 23 | add_library(cxx SHARED |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 24 | ${LIBCXX_SOURCES} |
| 25 | ${LIBCXX_HEADERS} |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 26 | ) |
| 27 | else() |
| 28 | add_library(cxx STATIC |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 29 | ${LIBCXX_SOURCES} |
| 30 | ${LIBCXX_HEADERS} |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 31 | ) |
| 32 | endif() |
| 33 | |
Michael J. Spencer | db8a030 | 2012-12-31 19:34:21 +0000 | [diff] [blame] | 34 | if (DEFINED LIBCXX_CXX_ABI_DEPS) |
| 35 | add_dependencies(cxx ${LIBCXX_CXX_ABI_DEPS}) |
| 36 | endif() |
Michael J. Spencer | a358fbe | 2012-11-30 21:02:29 +0000 | [diff] [blame] | 37 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 38 | # Generate library list. |
Michael J. Spencer | a358fbe | 2012-11-30 21:02:29 +0000 | [diff] [blame] | 39 | set(libraries ${LIBCXX_CXX_ABI_LIBRARIES}) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 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) |
Howard Hinnant | 20542c0 | 2011-05-24 12:54:00 +0000 | [diff] [blame] | 43 | append_if(libraries LIBCXX_HAS_RT_LIB rt) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 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 | |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 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 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 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 | ) |