Eric Fiselier | bf9653d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 1 | set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" PARENT_SCOPE) |
| 2 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 3 | # Get sources |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 4 | file(GLOB LIBCXX_SOURCES ../src/*.cpp) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 5 | if(WIN32) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 6 | file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp) |
| 7 | list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES}) |
Eric Fiselier | 6cb69ff | 2014-11-25 21:57:41 +0000 | [diff] [blame] | 8 | elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") |
| 9 | file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c) |
| 10 | list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES}) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 11 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 12 | |
| 13 | # Add all the headers to the project for IDEs. |
Eric Fiselier | 85df7a8 | 2015-12-16 23:41:05 +0000 | [diff] [blame] | 14 | if (LIBCXX_CONFIGURE_IDE) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 15 | file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 16 | if(WIN32) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 17 | file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h) |
| 18 | list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS}) |
Howard Hinnant | 92a0700 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 19 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 20 | # Force them all into the headers dir on MSVC, otherwise they end up at |
| 21 | # project scope because they don't have extensions. |
| 22 | if (MSVC_IDE) |
Howard Hinnant | 87c61a6 | 2012-03-19 15:40:23 +0000 | [diff] [blame] | 23 | source_group("Header Files" FILES ${LIBCXX_HEADERS}) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 24 | endif() |
| 25 | endif() |
| 26 | |
Chris Bieneman | a846b11 | 2015-12-03 18:52:54 +0000 | [diff] [blame] | 27 | if(NOT LIBCXX_INSTALL_LIBRARY) |
| 28 | set(exclude_from_all EXCLUDE_FROM_ALL) |
| 29 | endif() |
| 30 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 31 | #if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path. |
| 32 | add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") |
Eric Fiselier | c0b166e | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 33 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 34 | add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}") |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 35 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 36 | add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic") |
| 37 | add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}") |
| 38 | add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive") |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 39 | |
Eric Fiselier | 938c96e | 2015-07-22 00:33:36 +0000 | [diff] [blame] | 40 | if (APPLE AND LLVM_USE_SANITIZER) |
| 41 | if ("${LLVM_USE_SANITIZER}" STREQUAL "Address") |
| 42 | set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib") |
| 43 | elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined") |
| 44 | set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib") |
Kuba Brecka | 847eaf4 | 2016-09-14 14:12:50 +0000 | [diff] [blame^] | 45 | elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread") |
| 46 | set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib") |
Eric Fiselier | 938c96e | 2015-07-22 00:33:36 +0000 | [diff] [blame] | 47 | else() |
| 48 | message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X") |
| 49 | endif() |
| 50 | if (LIBFILE) |
| 51 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=lib OUTPUT_VARIABLE LIBDIR RESULT_VARIABLE Result) |
| 52 | if (NOT ${Result} EQUAL "0") |
| 53 | message(FATAL "Failed to find library resource directory") |
| 54 | endif() |
| 55 | string(STRIP "${LIBDIR}" LIBDIR) |
| 56 | set(LIBDIR "${LIBDIR}/darwin/") |
| 57 | if (NOT IS_DIRECTORY "${LIBDIR}") |
| 58 | message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER") |
| 59 | endif() |
| 60 | set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}") |
| 61 | set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE) |
| 62 | message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}") |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 63 | add_library_flags("${LIBCXX_SANITIZER_LIBRARY}") |
| 64 | add_link_flags("-Wl,-rpath,${LIBDIR}") |
Eric Fiselier | 938c96e | 2015-07-22 00:33:36 +0000 | [diff] [blame] | 65 | endif() |
| 66 | endif() |
| 67 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 68 | # Generate library list. |
| 69 | add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread) |
| 70 | add_library_flags_if(LIBCXX_HAS_C_LIB c) |
| 71 | add_library_flags_if(LIBCXX_HAS_M_LIB m) |
| 72 | add_library_flags_if(LIBCXX_HAS_RT_LIB rt) |
| 73 | add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s) |
Eric Fiselier | 5432e3b | 2016-07-18 06:01:50 +0000 | [diff] [blame] | 74 | add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic) |
Eric Fiselier | bf9653d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 75 | |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 76 | # Setup flags. |
Saleem Abdulrasool | 1dbcfe0 | 2016-09-01 20:49:54 +0000 | [diff] [blame] | 77 | if (NOT WIN32) |
| 78 | add_flags_if_supported(-fPIC) |
| 79 | endif() |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 80 | add_link_flags_if_supported(-nodefaultlibs) |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 81 | |
Eric Fiselier | 4f274d0 | 2015-03-27 09:00:45 +0000 | [diff] [blame] | 82 | if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR |
| 83 | LIBCXX_CXX_ABI_LIBNAME STREQUAL "none")) |
Eric Fiselier | 45969ec | 2015-02-21 02:26:24 +0000 | [diff] [blame] | 84 | if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION) |
Eric Fiselier | 5fb49ff | 2016-06-14 21:55:14 +0000 | [diff] [blame] | 85 | set(LIBCXX_LIBCPPABI_VERSION "2") # Default value |
| 86 | execute_process( |
| 87 | COMMAND xcrun --show-sdk-version |
| 88 | OUTPUT_VARIABLE sdk_ver |
| 89 | RESULT_VARIABLE res |
| 90 | OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 91 | if (res EQUAL 0) |
| 92 | message(STATUS "Found SDK version ${sdk_ver}") |
| 93 | string(REPLACE "10." "" sdk_ver "${sdk_ver}") |
| 94 | if (sdk_ver LESS 9) |
| 95 | set(LIBCXX_LIBCPPABI_VERSION "") |
| 96 | else() |
| 97 | set(LIBCXX_LIBCPPABI_VERSION "2") |
| 98 | endif() |
| 99 | endif() |
Eric Fiselier | 45969ec | 2015-02-21 02:26:24 +0000 | [diff] [blame] | 100 | endif() |
| 101 | |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 102 | if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 103 | add_definitions(-D__STRICT_ANSI__) |
| 104 | add_link_flags( |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 105 | "-compatibility_version 1" |
Hans Wennborg | f3b5f0e | 2014-08-12 17:32:07 +0000 | [diff] [blame] | 106 | "-current_version 1" |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 107 | "-install_name /usr/lib/libc++.1.dylib" |
| 108 | "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" |
| 109 | "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" |
| 110 | "/usr/lib/libSystem.B.dylib") |
| 111 | else() |
Eric Fiselier | 364cf87 | 2016-08-30 00:54:37 +0000 | [diff] [blame] | 112 | if (DEFINED CMAKE_OSX_SYSROOT) |
Eric Fiselier | b16966c | 2016-08-30 01:10:33 +0000 | [diff] [blame] | 113 | list(FIND CMAKE_OSX_ARCHITECTURES "armv7" OSX_HAS_ARMV7) |
Eric Fiselier | 364cf87 | 2016-08-30 00:54:37 +0000 | [diff] [blame] | 114 | if (NOT OSX_HAS_ARMV7 EQUAL -1) |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 115 | set(OSX_RE_EXPORT_LINE |
| 116 | "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" |
| 117 | "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") |
| 118 | else() |
| 119 | set(OSX_RE_EXPORT_LINE |
| 120 | "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") |
| 121 | endif() |
| 122 | else() |
Eric Fiselier | 25daee7 | 2015-10-05 19:28:48 +0000 | [diff] [blame] | 123 | set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 124 | endif() |
| 125 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 126 | add_link_flags( |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 127 | "-compatibility_version 1" |
| 128 | "-install_name /usr/lib/libc++.1.dylib" |
| 129 | "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" |
| 130 | "${OSX_RE_EXPORT_LINE}" |
| 131 | "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp" |
| 132 | "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp") |
| 133 | endif() |
| 134 | endif() |
| 135 | |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 136 | split_list(LIBCXX_COMPILE_FLAGS) |
| 137 | split_list(LIBCXX_LINK_FLAGS) |
Michael Gottesman | 8a1fc89 | 2013-09-02 07:28:03 +0000 | [diff] [blame] | 138 | |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 139 | # Add a object library that contains the compiled source files. |
| 140 | add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) |
| 141 | |
| 142 | set_target_properties(cxx_objects |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 143 | PROPERTIES |
Eric Fiselier | 8e2855c | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 144 | COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 145 | ) |
| 146 | |
| 147 | set(LIBCXX_TARGETS) |
| 148 | |
| 149 | # Build the shared library. |
| 150 | if (LIBCXX_ENABLE_SHARED) |
| 151 | add_library(cxx_shared SHARED $<TARGET_OBJECTS:cxx_objects>) |
| 152 | target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES}) |
| 153 | set_target_properties(cxx_shared |
| 154 | PROPERTIES |
| 155 | LINK_FLAGS "${LIBCXX_LINK_FLAGS}" |
| 156 | OUTPUT_NAME "c++" |
| 157 | VERSION "${LIBCXX_ABI_VERSION}.0" |
| 158 | SOVERSION "${LIBCXX_ABI_VERSION}" |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 159 | ) |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 160 | list(APPEND LIBCXX_TARGETS "cxx_shared") |
| 161 | endif() |
| 162 | |
| 163 | # Build the static library. |
| 164 | if (LIBCXX_ENABLE_STATIC) |
| 165 | add_library(cxx_static STATIC $<TARGET_OBJECTS:cxx_objects>) |
| 166 | target_link_libraries(cxx_static ${LIBCXX_LIBRARIES}) |
| 167 | set_target_properties(cxx_static |
| 168 | PROPERTIES |
| 169 | LINK_FLAGS "${LIBCXX_LINK_FLAGS}" |
| 170 | OUTPUT_NAME "c++" |
| 171 | ) |
| 172 | list(APPEND LIBCXX_TARGETS "cxx_static") |
| 173 | endif() |
| 174 | |
| 175 | # Add a meta-target for both libraries. |
| 176 | add_custom_target(cxx DEPENDS ${LIBCXX_TARGETS}) |
| 177 | |
| 178 | if (DEFINED LIBCXX_CXX_ABI_DEPS) |
| 179 | add_dependencies(cxx LIBCXX_CXX_ABI_DEPS) |
| 180 | endif() |
Michael J. Spencer | 626916f | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 181 | |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 182 | if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) |
| 183 | file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp) |
Eric Fiselier | 6e9a694 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 184 | if (LIBCXX_ENABLE_FILESYSTEM) |
| 185 | file(GLOB LIBCXX_FILESYSTEM_SOURCES ../src/experimental/filesystem/*.cpp) |
| 186 | endif() |
| 187 | add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES} ${LIBCXX_FILESYSTEM_SOURCES}) |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 188 | if (LIBCXX_ENABLE_SHARED) |
| 189 | target_link_libraries(cxx_experimental cxx_shared) |
| 190 | else() |
| 191 | target_link_libraries(cxx_experimental cxx_static) |
| 192 | endif() |
Eric Fiselier | 25bcc0f | 2016-05-10 16:17:43 +0000 | [diff] [blame] | 193 | |
| 194 | set(experimental_flags "${LIBCXX_COMPILE_FLAGS}") |
| 195 | check_flag_supported(-std=c++14) |
| 196 | if (NOT MSVC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG) |
| 197 | string(REPLACE "-std=c++11" "-std=c++14" experimental_flags "${LIBCXX_COMPILE_FLAGS}") |
| 198 | endif() |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 199 | set_target_properties(cxx_experimental |
| 200 | PROPERTIES |
Eric Fiselier | 25bcc0f | 2016-05-10 16:17:43 +0000 | [diff] [blame] | 201 | COMPILE_FLAGS "${experimental_flags}" |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 202 | OUTPUT_NAME "c++experimental" |
| 203 | ) |
| 204 | endif() |
| 205 | |
Asiri Rathnayake | 040945b | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 206 | if (LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 207 | file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES ../test/support/external_threads.cpp) |
| 208 | |
| 209 | if (LIBCXX_ENABLE_SHARED) |
| 210 | add_library(cxx_external_threads SHARED ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES}) |
| 211 | else() |
| 212 | add_library(cxx_external_threads STATIC ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES}) |
| 213 | endif() |
| 214 | |
| 215 | set_target_properties(cxx_external_threads |
| 216 | PROPERTIES |
| 217 | LINK_FLAGS "${LIBCXX_LINK_FLAGS}" |
| 218 | COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" |
| 219 | OUTPUT_NAME "c++external_threads" |
| 220 | ) |
| 221 | endif() |
| 222 | |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 223 | # Generate a linker script inplace of a libc++.so symlink. Rerun this command |
| 224 | # after cxx builds. |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 225 | if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 226 | # Get the name of the ABI library and handle the case where CXXABI_LIBNAME |
| 227 | # is a target name and not a library. Ex cxxabi_shared. |
Eric Fiselier | a317a1b | 2015-10-14 21:20:28 +0000 | [diff] [blame] | 228 | set(SCRIPT_ABI_LIBNAME "${LIBCXX_CXX_ABI_LIBRARY}") |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 229 | if (SCRIPT_ABI_LIBNAME STREQUAL "cxxabi_shared") |
Eric Fiselier | 1d3716a | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 230 | set(SCRIPT_ABI_LIBNAME "c++abi") |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 231 | endif() |
| 232 | # Generate a linker script inplace of a libc++.so symlink. Rerun this command |
| 233 | # after cxx builds. |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 234 | add_custom_command(TARGET cxx_shared POST_BUILD |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 235 | COMMAND |
| 236 | ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/gen_link_script/gen_link_script.py |
| 237 | ARGS |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 238 | "$<TARGET_LINKER_FILE:cxx_shared>" |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 239 | "${SCRIPT_ABI_LIBNAME}" |
| 240 | WORKING_DIRECTORY ${LIBCXX_BUILD_DIR} |
| 241 | ) |
| 242 | endif() |
| 243 | |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 244 | if (LIBCXX_INSTALL_LIBRARY) |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 245 | if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY) |
| 246 | set(experimental_lib cxx_experimental) |
| 247 | endif() |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 248 | install(TARGETS ${LIBCXX_TARGETS} ${experimental_lib} |
Chris Bieneman | e0620e2 | 2016-08-24 22:17:06 +0000 | [diff] [blame] | 249 | LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx |
| 250 | ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 251 | ) |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 252 | # NOTE: This install command must go after the cxx install command otherwise |
| 253 | # it will not be executed after the library symlinks are installed. |
Petr Hosek | b640da0 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 254 | if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
Eric Fiselier | 601d2c1 | 2015-10-22 21:24:01 +0000 | [diff] [blame] | 255 | # Replace the libc++ filename with $<TARGET_LINKER_FILE:cxx> |
| 256 | # after we required CMake 3.0. |
Eric Fiselier | e6d05b6 | 2015-10-23 07:04:24 +0000 | [diff] [blame] | 257 | install(FILES "${LIBCXX_LIBRARY_DIR}/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}" |
Eric Fiselier | 8cbf020 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 258 | DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} |
| 259 | COMPONENT libcxx) |
| 260 | endif() |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 261 | endif() |
Eric Fiselier | de56f74 | 2015-08-19 17:41:53 +0000 | [diff] [blame] | 262 | |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 263 | if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR |
| 264 | LIBCXX_INSTALL_HEADERS)) |
Chris Bieneman | a846b11 | 2015-12-03 18:52:54 +0000 | [diff] [blame] | 265 | if(LIBCXX_INSTALL_LIBRARY) |
Eric Fiselier | a956a10 | 2016-05-03 05:34:38 +0000 | [diff] [blame] | 266 | set(lib_install_target cxx) |
Chris Bieneman | a846b11 | 2015-12-03 18:52:54 +0000 | [diff] [blame] | 267 | endif() |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 268 | if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY) |
| 269 | set(experimental_lib_install_target cxx_experimental) |
| 270 | endif() |
Chris Bieneman | ffa3db2 | 2016-04-29 22:17:15 +0000 | [diff] [blame] | 271 | if(LIBCXX_INSTALL_HEADERS) |
Chris Bieneman | e0620e2 | 2016-08-24 22:17:06 +0000 | [diff] [blame] | 272 | set(header_install_target install-cxx-headers) |
Chris Bieneman | ffa3db2 | 2016-04-29 22:17:15 +0000 | [diff] [blame] | 273 | endif() |
Chris Bieneman | e0620e2 | 2016-08-24 22:17:06 +0000 | [diff] [blame] | 274 | add_custom_target(install-cxx |
Eric Fiselier | 5e4698c | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 275 | DEPENDS ${lib_install_target} |
| 276 | ${experimental_lib_install_target} |
| 277 | ${header_install_target} |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 278 | COMMAND "${CMAKE_COMMAND}" |
Chris Bieneman | e0620e2 | 2016-08-24 22:17:06 +0000 | [diff] [blame] | 279 | -DCMAKE_INSTALL_COMPONENT=cxx |
Eric Fiselier | 961269d | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 280 | -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake") |
Chris Bieneman | e0620e2 | 2016-08-24 22:17:06 +0000 | [diff] [blame] | 281 | add_custom_target(install-libcxx DEPENDS install-cxx) |
Eric Fiselier | de56f74 | 2015-08-19 17:41:53 +0000 | [diff] [blame] | 282 | endif() |