From 67480c05e3f6819d867680775ca0cbc6f03f28da Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 23 Sep 2016 21:49:12 +0200 Subject: Add a feature check to test availability of auto_ptr --- Source/Checks/cm_cxx_auto_ptr.cxx | 18 ++++++++++++++++++ Source/Checks/cm_cxx_features.cmake | 1 + Source/cmConfigure.cmake.h.in | 1 + 3 files changed, 20 insertions(+) create mode 100644 Source/Checks/cm_cxx_auto_ptr.cxx diff --git a/Source/Checks/cm_cxx_auto_ptr.cxx b/Source/Checks/cm_cxx_auto_ptr.cxx new file mode 100644 index 0000000..d3100fd --- /dev/null +++ b/Source/Checks/cm_cxx_auto_ptr.cxx @@ -0,0 +1,18 @@ +#include + +std::auto_ptr get_auto_ptr() +{ + std::auto_ptr ptr; + ptr = std::auto_ptr(new int(0)); + return ptr; +} + +int use_auto_ptr(std::auto_ptr ptr) +{ + return *ptr; +} + +int main() +{ + return use_auto_ptr(get_auto_ptr()); +} diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index c6a532f..80c9f3b 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -32,6 +32,7 @@ function(cm_check_cxx_feature name) endfunction() if(CMAKE_CXX_STANDARD) + cm_check_cxx_feature(auto_ptr) 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 8365367..8a1e81f 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -30,6 +30,7 @@ #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_USE_LIBUV #cmakedefine CMAKE_ENCODING_UTF8 +#cmakedefine CMake_HAVE_CXX_AUTO_PTR #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE #cmakedefine CMake_HAVE_CXX_NULLPTR #cmakedefine CMake_HAVE_CXX_OVERRIDE -- cgit v0.12