Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1 | # Get sources |
Howard Hinnant | b2f52bb | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 2 | file(GLOB LIBCXX_SOURCES ../src/*.cpp) |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 3 | if(WIN32) |
Howard Hinnant | b2f52bb | 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 | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 6 | endif() |
Michael J. Spencer | f5799be | 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 | b2f52bb | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 10 | file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*) |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 11 | if(WIN32) |
Howard Hinnant | b2f52bb | 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 | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 14 | endif() |
Michael J. Spencer | f5799be | 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 | b2f52bb | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 18 | source_group("Header Files" FILES ${LIBCXX_HEADERS}) |
Michael J. Spencer | f5799be | 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 | b2f52bb | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 24 | ${LIBCXX_SOURCES} |
| 25 | ${LIBCXX_HEADERS} |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 26 | ) |
| 27 | else() |
| 28 | add_library(cxx STATIC |
Howard Hinnant | b2f52bb | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 29 | ${LIBCXX_SOURCES} |
| 30 | ${LIBCXX_HEADERS} |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 31 | ) |
| 32 | endif() |
| 33 | |
Michael J. Spencer | 299fc29 | 2012-11-30 21:02:29 +0000 | [diff] [blame^] | 34 | add_dependencies(cxx ${LIBCXX_CXX_ABI_DEPS}) |
| 35 | |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 36 | # Generate library list. |
Michael J. Spencer | 299fc29 | 2012-11-30 21:02:29 +0000 | [diff] [blame^] | 37 | set(libraries ${LIBCXX_CXX_ABI_LIBRARIES}) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 38 | append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread) |
| 39 | append_if(libraries LIBCXX_HAS_C_LIB c) |
| 40 | append_if(libraries LIBCXX_HAS_M_LIB m) |
Howard Hinnant | cf76200 | 2011-05-24 12:54:00 +0000 | [diff] [blame] | 41 | append_if(libraries LIBCXX_HAS_RT_LIB rt) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 42 | append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s) |
| 43 | |
| 44 | target_link_libraries(cxx ${libraries}) |
| 45 | |
| 46 | # Setup flags. |
| 47 | append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC) |
| 48 | append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) |
| 49 | |
| 50 | set_target_properties(cxx |
| 51 | PROPERTIES |
| 52 | COMPILE_FLAGS "${compile_flags}" |
| 53 | LINK_FLAGS "${link_flags}" |
| 54 | OUTPUT_NAME "c++" |
| 55 | VERSION "1.0" |
| 56 | SOVERSION "1" |
| 57 | ) |
| 58 | |
| 59 | install(TARGETS cxx |
| 60 | LIBRARY DESTINATION lib |
| 61 | ARCHIVE DESTINATION lib |
| 62 | ) |
| 63 | |
| 64 | install(DIRECTORY ../include/ |
| 65 | DESTINATION include/c++/v1 |
| 66 | FILES_MATCHING |
Howard Hinnant | 3145a94 | 2011-03-03 01:59:23 +0000 | [diff] [blame] | 67 | PATTERN "*" |
Howard Hinnant | 01533ed | 2011-03-02 17:29:46 +0000 | [diff] [blame] | 68 | PATTERN ".svn" EXCLUDE |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 69 | ) |