diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a86e947..b8eb0f39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,16 +33,6 @@ include (ACGOutput) # Definitions # ======================================================================== -set(INHIBIT_CXX11_SUPPORT OFF CACHE BOOL "Do not use C++11 even if it is available. (This is mainly useful for unit testing.)") - -if (NOT INHIBIT_CXX11_SUPPORT) -find_package (CXX11) - -if (CXX11_FOUND) - add_definitions(${CXX11_FLAGS} -DCPP11_ENABLED) -endif (CXX11_FOUND) -endif (NOT INHIBIT_CXX11_SUPPORT) - if (WIN32) add_definitions( -D_USE_MATH_DEFINES -DNOMINMAX @@ -107,12 +97,6 @@ else() set (OPENMESH_FOUND true PARENT_SCOPE) set (OPENMESH_LIBRARIES OpenMeshCore OpenMeshTools PARENT_SCOPE) set (OPENMESH_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src" PARENT_SCOPE) - set (OPENMESH_FLAGS "" PARENT_SCOPE) - if (NOT INHIBIT_CXX11_SUPPORT) - if (CXX11_FOUND) - set(OPENMESH_FLAGS "${CXX11_FLAGS};-DCPP11_ENABLED" PARENT_SCOPE) - endif (CXX11_FOUND) - endif (NOT INHIBIT_CXX11_SUPPORT) # Also define variables provided by the old legacy finder. set (OPENMESH_CORE_LIBRARY OpenMeshCore PARENT_SCOPE) diff --git a/cmake/FindCXX11.cmake b/cmake/FindCXX11.cmake deleted file mode 100644 index a1fe935c..00000000 --- a/cmake/FindCXX11.cmake +++ /dev/null @@ -1,71 +0,0 @@ -IF (NOT CXX11_FLAGS OR NOT CXX11_FOUND) -include(CheckCXXSourceCompiles) -include(FindPackageHandleStandardArgs) - -set(CXX11_FLAG_CANDIDATES - #Gnu and Intel Linux - "-std=c++11" - #Microsoft Visual Studio, and everything that automatically accepts C++11 - " " - #Intel windows - "/Qstd=c++0x" - ) - -set(CXX11_TEST_SOURCE -" -#include -#include -#include - -class Matrix { -public: - // Initializer lists - Matrix(int a, int b, int c, int d) - : data {a, b, c, d} - { - // Lambda functions - std::transform(data, data+4, data, - [](int x) { return x+1; }); - } - - // rvalue references - Matrix(Matrix &&rhs) { - } - -private: - int data[4]; -}; - -int main() -{ - int n[] {4,7,6,1,2}; - // auto - for (auto i : n) { - Matrix mat (3,5,1,2); - - // std::move, unique_ptr - std::unique_ptr m2( - new Matrix(std::move(mat))); - } - return 0; -} -") - -foreach(FLAG ${CXX11_FLAG_CANDIDATES}) - set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${FLAG}") - unset(CXX11_FLAG_DETECTED CACHE) - - check_cxx_source_compiles("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED) - set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") - if(CXX11_FLAG_DETECTED) - set(CXX11_FLAGS_INTERNAL "${FLAG}") - break() - endif(CXX11_FLAG_DETECTED) -endforeach(FLAG ${CXX11_FLAG_CANDIDATES}) - -set(CXX11_FLAGS "${CXX11_FLAGS_INTERNAL}") - -find_package_handle_standard_args(CXX11 DEFAULT_MSG CXX11_FLAGS) -mark_as_advanced(CXX11_FLAGS) -ENDIF() \ No newline at end of file diff --git a/src/OpenMesh/Core/Geometry/VectorT.hh b/src/OpenMesh/Core/Geometry/VectorT.hh index 7be16f0e..0eeb74ba 100644 --- a/src/OpenMesh/Core/Geometry/VectorT.hh +++ b/src/OpenMesh/Core/Geometry/VectorT.hh @@ -77,7 +77,7 @@ #include #endif -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) #include #include #include @@ -92,7 +92,7 @@ namespace OpenMesh { //== CLASS DEFINITION ========================================================= -#if CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) /* * Helpers for VectorT */ @@ -121,7 +121,7 @@ struct are_convertible_to : public std::is_convertible {}; */ template class VectorDataT { public: -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) VectorDataT() {} template @@ -141,7 +141,7 @@ template class VectorDataT { /// This specialization enables us to use aligned SSE instructions. template<> class VectorDataT { public: -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) VectorDataT() {} template @@ -152,7 +152,7 @@ template<> class VectorDataT { #endif union { __m128 m128; -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) std::array values_; #else float values_[4]; @@ -432,7 +432,7 @@ typedef VectorT Vec6d; //============================================================================= -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) /** * Literal operator for inline specification of colors in HTML syntax. * diff --git a/src/OpenMesh/Core/Geometry/VectorT_inc.hh b/src/OpenMesh/Core/Geometry/VectorT_inc.hh index 3f045a19..bc7e1570 100644 --- a/src/OpenMesh/Core/Geometry/VectorT_inc.hh +++ b/src/OpenMesh/Core/Geometry/VectorT_inc.hh @@ -97,7 +97,7 @@ public: /// default constructor creates uninitialized values. inline VectorT() {} -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) explicit inline VectorT(const Scalar &v) { vectorize(v); } @@ -199,7 +199,7 @@ public: // /// cast to const Scalar array // inline operator const Scalar*() const { return Base::values_; } -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) /// access to Scalar array inline Scalar* data() { return Base::values_.data(); } diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index a629979d..270f4242 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -22,16 +22,6 @@ if ( OPENMESH_BUILD_UNIT_TESTS ) # set additional link directories link_directories(${GTEST_LIBRARY_DIR} ) - set(INHIBIT_CXX11_SUPPORT OFF CACHE BOOL "Do not use C++11 even if it is available. (This is mainly useful for unit testing.)") - - if (NOT INHIBIT_CXX11_SUPPORT) - find_package (CXX11) - - if (CXX11_FOUND) - add_definitions(${CXX11_FLAGS} -DCPP11_ENABLED) - endif (CXX11_FOUND) - endif (NOT INHIBIT_CXX11_SUPPORT) - if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" ) add_definitions( /D _VARIADIC_MAX=10 ) endif() diff --git a/src/Unittests/unittests_vector_type.cc b/src/Unittests/unittests_vector_type.cc index 58172537..82e7793b 100644 --- a/src/Unittests/unittests_vector_type.cc +++ b/src/Unittests/unittests_vector_type.cc @@ -83,7 +83,7 @@ TEST_F(OpenMeshVectorTest, VectorCasting) { } -#ifdef CPP11_ENABLED +#if __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__) TEST_F(OpenMeshVectorTest, cpp11_constructors) { OpenMesh::Vec3d vec1 { 1.2, 2.0, 3.0 }; @@ -113,6 +113,8 @@ TEST_F(OpenMeshVectorTest, cpp11_constructors) { } TEST_F(OpenMeshVectorTest, cpp11_htmlColorLiteral) { + static constexpr OpenMesh::Vec4f rose = 0xFFC7F1FF_htmlColor; + const OpenMesh::Vec4f light_blue = 0x1FCFFFFF_htmlColor; EXPECT_LE((OpenMesh::Vec4f(0.1215686274f, 0.8117647058f, 1.0f, 1.0f) - light_blue).sqrnorm(), 1e-10);