From 5d1671324bbcf0826b32c4c1691ae0f1041430ed Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sat, 22 Apr 2017 10:09:41 +0200 Subject: cmConfigure: provide macros CM_EQ_DELETE and CM_DISABLE_COPY --- Source/Checks/cm_cxx_eq_delete.cxx | 14 ++++++++++++++ Source/Checks/cm_cxx_features.cmake | 1 + Source/cmConfigure.cmake.h.in | 11 +++++++++++ bootstrap | 2 ++ 4 files changed, 28 insertions(+) create mode 100644 Source/Checks/cm_cxx_eq_delete.cxx diff --git a/Source/Checks/cm_cxx_eq_delete.cxx b/Source/Checks/cm_cxx_eq_delete.cxx new file mode 100644 index 0000000..809e4cf --- /dev/null +++ b/Source/Checks/cm_cxx_eq_delete.cxx @@ -0,0 +1,14 @@ +struct Foo +{ + Foo() {} + ~Foo() {} + Foo(Foo const&) = delete; + Foo& operator=(Foo const&) = delete; + int test() const { return 0; } +}; + +int main() +{ + Foo const foo; + return foo.test(); +} diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index 80c9f3b..cd58539 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -33,6 +33,7 @@ endfunction() if(CMAKE_CXX_STANDARD) cm_check_cxx_feature(auto_ptr) + cm_check_cxx_feature(eq_delete) cm_check_cxx_feature(make_unique) if(CMake_HAVE_CXX_MAKE_UNIQUE) set(CMake_HAVE_CXX_UNIQUE_PTR 1) diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index e30b43f..970fde5 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -21,6 +21,7 @@ #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_USE_LIBUV #cmakedefine CMake_HAVE_CXX_AUTO_PTR +#cmakedefine CMake_HAVE_CXX_EQ_DELETE #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE #cmakedefine CMake_HAVE_CXX_NULLPTR #cmakedefine CMake_HAVE_CXX_OVERRIDE @@ -30,6 +31,12 @@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" +#ifdef CMake_HAVE_CXX_EQ_DELETE +#define CM_EQ_DELETE = delete +#else +#define CM_EQ_DELETE +#endif + #ifdef CMake_HAVE_CXX_NULLPTR #define CM_NULLPTR nullptr #else @@ -42,4 +49,8 @@ #define CM_OVERRIDE #endif +#define CM_DISABLE_COPY(Class) \ + Class(Class const&) CM_EQ_DELETE; \ + Class& operator=(Class const&) CM_EQ_DELETE; + #endif diff --git a/bootstrap b/bootstrap index 4f58365..e957e82 100755 --- a/bootstrap +++ b/bootstrap @@ -1369,8 +1369,10 @@ cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_ cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" +cmake_report cmConfigure.h${_tmp} "#define CM_EQ_DELETE" cmake_report cmConfigure.h${_tmp} "#define CM_NULLPTR 0" cmake_report cmConfigure.h${_tmp} "#define CM_OVERRIDE" +cmake_report cmConfigure.h${_tmp} "#define CM_DISABLE_COPY(Class)" # Regenerate configured headers for h in Configure VersionConfig; do -- cgit v0.12