From: Radoslaw Zarzynski Date: Tue, 4 Dec 2018 09:21:26 +0000 (+0100) Subject: build, tests: introduce compiletest_cxx11_client for C++11 conformity. X-Git-Tag: v15.1.0~2436^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8b275022d8923d14c0b609d69aec94b2cd6f512;p=ceph.git build, tests: introduce compiletest_cxx11_client for C++11 conformity. This patch extends the usual pull request workflow with extra stage: validation of the C++11 compliance of the public headers (currently `buffers.h` only; I would love to have this broader) on `make check`. The idea is to let the bots to detect breaking the language part of our public API early, and thus off-load reviewers and Teuthology. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d90dc294b890..7ad3af5be477 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -111,6 +111,14 @@ if(CMAKE_VERSION VERSION_LESS "3.8") "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support.") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + + # for compiletest_cxx11_client + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + if(NOT COMPILER_SUPPORTS_CXX11) + message(FATAL_ERROR + "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") + endif() + include(CheckCCompilerFlag) CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_SUPPORTS_GNU99) if(NOT COMPILER_SUPPORTS_GNU99) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 1e47535e9840..55b60a6ee72f 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -678,6 +678,28 @@ add_executable(unittest_bufferlist add_ceph_unittest(unittest_bufferlist) target_link_libraries(unittest_bufferlist global) +# compiletest_cxx11_client +add_executable(compiletest_cxx11_client + cxx11_client.cc + ) +if(CMAKE_VERSION VERSION_LESS "3.8") + # this is ugly as we'll end with -std=c++11 overriding the previous -std=c++17 + # I would love to have a better way for old Cmakes + set_target_properties(compiletest_cxx11_client + PROPERTIES COMPILE_FLAGS "-std=c++11 -Werror -pedantic" + ) +else() + set_target_properties(compiletest_cxx11_client + PROPERTIES COMPILE_FLAGS "-Werror -pedantic" + CMAKE_CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + ) +endif() +add_ceph_test(compiletest_cxx11_client + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/compiletest_cxx11_client" + ) +target_link_libraries(compiletest_cxx11_client global) + # unittest_xlist add_executable(unittest_xlist test_xlist.cc diff --git a/src/test/cxx11_client.cc b/src/test/cxx11_client.cc new file mode 100644 index 000000000000..c30ab5cfaa95 --- /dev/null +++ b/src/test/cxx11_client.cc @@ -0,0 +1,6 @@ +#include "include/buffer.h" + +// We might want to include here all our public headers. +// Not any file residing in src/include has this status. + +int main() {}