Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1 | # Get sources |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame^] | 2 | file(GLOB sources ../src/*.cpp) |
| 3 | if(WIN32) |
| 4 | file(GLOB win32_sources ../src/support/win32/*.cpp) |
| 5 | list(APPEND sources ${win32_sources}) |
| 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) |
| 10 | file(GLOB_RECURSE headers ../include/*) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame^] | 11 | if(WIN32) |
| 12 | file( GLOB win32_headers ../include/support/win32/*.h) |
| 13 | list(APPEND headers ${win32_headers}) |
| 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) |
| 18 | source_group("Header Files" FILES ${headers}) |
| 19 | endif() |
| 20 | endif() |
| 21 | |
| 22 | if (LIBCXX_ENABLE_SHARED) |
| 23 | add_library(cxx SHARED |
| 24 | ${sources} |
| 25 | ${headers} |
| 26 | ) |
| 27 | else() |
| 28 | add_library(cxx STATIC |
| 29 | ${sources} |
| 30 | ${headers} |
| 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 | ) |