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 | |
| 34 | # Generate library list. |
| 35 | append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread) |
| 36 | append_if(libraries LIBCXX_HAS_C_LIB c) |
| 37 | append_if(libraries LIBCXX_HAS_M_LIB m) |
Howard Hinnant | 20542c0 | 2011-05-24 12:54:00 +0000 | [diff] [blame] | 38 | append_if(libraries LIBCXX_HAS_RT_LIB rt) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 39 | append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s) |
| 40 | |
| 41 | target_link_libraries(cxx ${libraries}) |
| 42 | |
| 43 | # Setup flags. |
| 44 | append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC) |
| 45 | append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) |
| 46 | |
| 47 | set_target_properties(cxx |
| 48 | PROPERTIES |
| 49 | COMPILE_FLAGS "${compile_flags}" |
| 50 | LINK_FLAGS "${link_flags}" |
| 51 | OUTPUT_NAME "c++" |
| 52 | VERSION "1.0" |
| 53 | SOVERSION "1" |
| 54 | ) |
| 55 | |
| 56 | install(TARGETS cxx |
| 57 | LIBRARY DESTINATION lib |
| 58 | ARCHIVE DESTINATION lib |
| 59 | ) |
| 60 | |
| 61 | install(DIRECTORY ../include/ |
| 62 | DESTINATION include/c++/v1 |
| 63 | FILES_MATCHING |
Howard Hinnant | 8dcad97 | 2011-03-03 01:59:23 +0000 | [diff] [blame] | 64 | PATTERN "*" |
Howard Hinnant | 542b0f0 | 2011-03-02 17:29:46 +0000 | [diff] [blame] | 65 | PATTERN ".svn" EXCLUDE |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 66 | ) |