From: Adam C. Emerson Date: Fri, 9 Feb 2018 21:16:43 +0000 (-0500) Subject: build: Use the right experimental library X-Git-Tag: v13.0.2~288^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F20392%2Fhead;p=ceph.git build: Use the right experimental library Test whether we're building with libstdc++ or libc++. Use stdc++filesystem if the former and c++experimental if the later. Signed-off-by: Adam C. Emerson --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f748bc6c215..c8f5d20d041 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ CHECK_FUNCTION_EXISTS(getgrouplist HAVE_GETGROUPLIST) if(NOT APPLE) CHECK_FUNCTION_EXISTS(fdatasync HAVE_FDATASYNC) endif() -CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) +CHECK_FUNCTION_EXISTS(strerror_r HAVE_Strerror_R) CHECK_FUNCTION_EXISTS(name_to_handle_at HAVE_NAME_TO_HANDLE_AT) CHECK_FUNCTION_EXISTS(pipe2 HAVE_PIPE2) set(CMAKE_REQUIRED_LIBRARIES pthread) @@ -594,6 +594,19 @@ include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include) find_package(Threads REQUIRED) +execute_process( + COMMAND ./librarytest.sh ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE CXX_STDLIB + ) + +if(CXX_STDLIB STREQUAL "libstdc++" OR CXX_STDLIB STREQUAL "libc++") + message(STATUS "We are using ${CXX_STDLIB}.") +else() + message(FATAL_ERROR + "Unable to determine C++ standard library, got ${CXX_STDLIB}.") +endif() + option(WITH_SELINUX "build SELinux policy" OFF) if(WITH_SELINUX) find_file(SELINUX_MAKEFILE selinux/devel/Makefile diff --git a/librarytest.sh b/librarytest.sh new file mode 100755 index 00000000000..12bc8c3cca9 --- /dev/null +++ b/librarytest.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +CXX=$1 + +shift + +echo "#include +#if defined(_LIBCPP_VERSION) +#define MYRESULT libc++ +#elif defined(__GLIBCXX__) +#define MYRESULT libstdc++ +#else +#define MYRESULT unknown +#endif + +HelloFriendsTheAnsWerIs MYRESULT" | ${CXX} -E -xc++ $* - | \ + grep "HelloFriendsTheAnsWerIs" | cut -f 2 -d ' ' | tr -d '\n' diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 3d97be7c81c..f2f12956dfa 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -508,10 +508,10 @@ add_executable(ceph_test_admin_socket_output ) target_link_libraries(ceph_test_admin_socket_output ceph-common) -if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) +if(CXX_STDLIB STREQUAL "libstdc++") target_link_libraries(ceph_test_admin_socket_output -lstdc++fs) -elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) +elseif(CXX_STDLIB STREQUAL "libc++") target_link_libraries(ceph_test_admin_socket_output -lc++experimental) endif()