Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame^] | 1 | # Get sources |
| 2 | file(GLOB_RECURSE sources ../src/*.cpp) |
| 3 | |
| 4 | # Add all the headers to the project for IDEs. |
| 5 | if (MSVC_IDE OR XCODE) |
| 6 | file(GLOB_RECURSE headers ../include/*) |
| 7 | # Force them all into the headers dir on MSVC, otherwise they end up at |
| 8 | # project scope because they don't have extensions. |
| 9 | if (MSVC_IDE) |
| 10 | source_group("Header Files" FILES ${headers}) |
| 11 | endif() |
| 12 | endif() |
| 13 | |
| 14 | if (LIBCXX_ENABLE_SHARED) |
| 15 | add_library(cxx SHARED |
| 16 | ${sources} |
| 17 | ${headers} |
| 18 | ) |
| 19 | else() |
| 20 | add_library(cxx STATIC |
| 21 | ${sources} |
| 22 | ${headers} |
| 23 | ) |
| 24 | endif() |
| 25 | |
| 26 | # Generate library list. |
| 27 | append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread) |
| 28 | append_if(libraries LIBCXX_HAS_C_LIB c) |
| 29 | append_if(libraries LIBCXX_HAS_M_LIB m) |
| 30 | append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s) |
| 31 | |
| 32 | target_link_libraries(cxx ${libraries}) |
| 33 | |
| 34 | # Setup flags. |
| 35 | append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC) |
| 36 | append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) |
| 37 | |
| 38 | set_target_properties(cxx |
| 39 | PROPERTIES |
| 40 | COMPILE_FLAGS "${compile_flags}" |
| 41 | LINK_FLAGS "${link_flags}" |
| 42 | OUTPUT_NAME "c++" |
| 43 | VERSION "1.0" |
| 44 | SOVERSION "1" |
| 45 | ) |
| 46 | |
| 47 | install(TARGETS cxx |
| 48 | LIBRARY DESTINATION lib |
| 49 | ARCHIVE DESTINATION lib |
| 50 | ) |
| 51 | |
| 52 | install(DIRECTORY ../include/ |
| 53 | DESTINATION include/c++/v1 |
| 54 | FILES_MATCHING |
| 55 | PATTERN "*" |
| 56 | ) |