]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
build: Use the right experimental library 20392/head
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 9 Feb 2018 21:16:43 +0000 (16:16 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Sat, 10 Feb 2018 00:54:02 +0000 (19:54 -0500)
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 <aemerson@redhat.com>
CMakeLists.txt
librarytest.sh [new file with mode: 0755]
src/test/CMakeLists.txt

index f748bc6c21520d9f395e4ac9b91fbbeea4301913..c8f5d20d041e5336a62f81f6ddba576daffd8efc 100644 (file)
@@ -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 (executable)
index 0000000..12bc8c3
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+CXX=$1
+
+shift
+
+echo "#include <utility>
+#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'
index 3d97be7c81ccee4c21ec6f6c1148b280153fd83f..f2f12956dfa9d03c84e718a93904a83ad6a296c9 100644 (file)
@@ -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()