cloudflare/ClickHouse
Publicmirrored fromhttps://github.com/cloudflare/ClickHouse
cmake/find/cxx.cmake
36lines · modecode
| 1 | if (COMPILER_CLANG) |
| 2 | option (USE_LIBCXX "Use libc++ and libc++abi instead of libstdc++" ON) |
| 3 | option (USE_INTERNAL_LIBCXX_LIBRARY "Set to FALSE to use system libcxx and libcxxabi libraries instead of bundled" ${NOT_UNBUNDLED}) |
| 4 | endif() |
| 5 | |
| 6 | if (USE_LIBCXX) |
| 7 | set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_LIBCPP_DEBUG=0") # More checks in debug build. |
| 8 | |
| 9 | if (NOT USE_INTERNAL_LIBCXX_LIBRARY) |
| 10 | find_library (LIBCXX_LIBRARY c++) |
| 11 | find_library (LIBCXXFS_LIBRARY c++fs) |
| 12 | find_library (LIBCXXABI_LIBRARY c++abi) |
| 13 | |
| 14 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") |
| 15 | |
| 16 | target_link_libraries(global-libs INTERFACE ${EXCEPTION_HANDLING_LIBRARY}) |
| 17 | else () |
| 18 | set (LIBCXX_LIBRARY cxx) |
| 19 | set (LIBCXXABI_LIBRARY cxxabi) |
| 20 | add_subdirectory(contrib/libcxxabi-cmake) |
| 21 | add_subdirectory(contrib/libcxx-cmake) |
| 22 | |
| 23 | # Exception handling library is embedded into libcxxabi. |
| 24 | endif () |
| 25 | |
| 26 | target_link_libraries(global-libs INTERFACE ${LIBCXX_LIBRARY} ${LIBCXXABI_LIBRARY} ${LIBCXXFS_LIBRARY}) |
| 27 | |
| 28 | set (HAVE_LIBCXX 1) |
| 29 | |
| 30 | message (STATUS "Using libcxx: ${LIBCXX_LIBRARY}") |
| 31 | message (STATUS "Using libcxxfs: ${LIBCXXFS_LIBRARY}") |
| 32 | message (STATUS "Using libcxxabi: ${LIBCXXABI_LIBRARY}") |
| 33 | else () |
| 34 | target_link_libraries(global-libs INTERFACE -l:libstdc++.a -l:libstdc++fs.a) # Always link these libraries as static |
| 35 | target_link_libraries(global-libs INTERFACE ${EXCEPTION_HANDLING_LIBRARY}) |
| 36 | endif () |