From 16808f1afe3b8f6b48c329d7a65f9153449ebcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Fri, 10 Jan 2020 13:44:51 +0100 Subject: [PATCH] CMake: require C++14; enable C++11 tests --- CMakeLists.txt | 36 +++++--------------- Crypto/testsuite/src/EVPTest.cpp | 7 ---- Crypto/testsuite/src/PKCS12ContainerTest.cpp | 4 --- 3 files changed, 8 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c095e351e..626320fd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,30 +36,17 @@ endif() ################################################################################# # Setup C/C++ compiler options ################################################################################# -option(DISABLE_CPP11 "Disable C++11 if not available" OFF) -option(DISABLE_CPP14 "Disable C++14 if not available" OFF) -if(NOT DISABLE_CPP11 OR NOT DISABLE_CPP14) - # C++11/14 compiler flags - include(CXX1x) - check_for_cxx11_compiler(CXX11_COMPILER) +# C++11/14 compiler flags +include(CXX1x) +check_for_cxx14_compiler(CXX14_COMPILER) - # If a C++11 compiler is available, then set the appropriate flags - if(CXX11_COMPILER) - set (CMAKE_CXX_STANDARD 11) +# If a C++14 compiler is available, then set the appropriate flags +if(CXX14_COMPILER) + set (CMAKE_CXX_STANDARD 14) set (CMAKE_CXX_STANDARD_REQUIRED ON) - - check_for_cxx14_compiler(CXX14_COMPILER) - # If a C++14 compiler is available, then set the appropriate flags - if(CXX14_COMPILER) - set(CMAKE_CXX_STANDARD 14) - else() - set(DISABLE_CPP14 ON CACHE BOOL "Disable C++14 if not available" FORCE) - endif() - else() - set(DISABLE_CPP11 ON CACHE BOOL "Disable C++11 if not available" FORCE) - set(DISABLE_CPP14 ON CACHE BOOL "Disable C++14 if not available" FORCE) - endif() +else() + message(FATAL_ERROR "Compiler does not support C++14." ) endif() if(NOT CMAKE_BUILD_TYPE) @@ -84,13 +71,11 @@ if(MSVC) option(ENABLE_MSVC_MP "Set to OFF|ON (default is OFF) to control parallel build of POCO with MSVC" OFF) - # allow disabling of internally built OpenSSL# (see below for details) # if POCO pre-built OpenSSL directory is found, and POCO_DISABLE_INTERNAL_OPENSSL=OFF, # the internal OpenSSL build will be used option(POCO_DISABLE_INTERNAL_OPENSSL "Disable internal OpensSSL binaries use" OFF) - if((NOT POCO_DISABLE_INTERNAL_OPENSSL) AND (ENABLE_NETSSL OR ENABLE_CRYPTO OR (ENABLE_DATA_MYSQL AND MINGW))) include(UseEmbeddedOpenSSL) endif() @@ -493,11 +478,6 @@ message(STATUS "[cmake] Build type: ${CMAKE_BUILD_TYPE}") string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE) message(STATUS "[cmake] Build with cxx flags: ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}") message(STATUS "[cmake] Build with c flags: ${CMAKE_C_FLAGS_${BUILD_TYPE}} ${CMAKE_C_FLAGS}") -if(NOT DISABLE_CPP14) - message(STATUS "Build with C++14 support") -elseif(NOT DISABLE_CPP11) - message(STATUS "Build with C++11 support") -endif() foreach(component ${Poco_COMPONENTS}) message(STATUS "Building: ${component}") diff --git a/Crypto/testsuite/src/EVPTest.cpp b/Crypto/testsuite/src/EVPTest.cpp index 4375c329b..f53ec81b1 100644 --- a/Crypto/testsuite/src/EVPTest.cpp +++ b/Crypto/testsuite/src/EVPTest.cpp @@ -108,8 +108,6 @@ void EVPTest::testRSAEVPPKey() assertTrue (sizePub1 && (sizePub1 == sizePub2)); assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1)); -#ifdef POCO_ENABLE_CPP11 - BIO_free(bioPub2); BIO_free(bioPriv2); @@ -128,8 +126,6 @@ void EVPTest::testRSAEVPPKey() assertTrue (sizePub1 && (sizePub1 == sizePub2)); assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1)); -#endif // POCO_ENABLE_CPP11 - BIO_free(bioPub2); BIO_free(bioPriv2); BIO_free(bioPub1); @@ -274,8 +270,6 @@ void EVPTest::testECEVPPKey() assertTrue (sizePub1 && (sizePub1 == sizePub2)); assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1)); - #ifdef POCO_ENABLE_CPP11 - BIO_free(bioPub2); BIO_free(bioPriv2); @@ -293,7 +287,6 @@ void EVPTest::testECEVPPKey() assertTrue (0 == memcmp(pPrivData1, pPrivData2, sizePriv1)); assertTrue (sizePub1 && (sizePub1 == sizePub2)); assertTrue (0 == memcmp(pPubData1, pPubData2, sizePub1)); - #endif // POCO_ENABLE_CPP11 BIO_free(bioPub2); BIO_free(bioPriv2); diff --git a/Crypto/testsuite/src/PKCS12ContainerTest.cpp b/Crypto/testsuite/src/PKCS12ContainerTest.cpp index fab454fd9..cdeb868f5 100644 --- a/Crypto/testsuite/src/PKCS12ContainerTest.cpp +++ b/Crypto/testsuite/src/PKCS12ContainerTest.cpp @@ -59,16 +59,12 @@ void PKCS12ContainerTest::testFullPKCS12() pkcs3 = pkcs2; full(pkcs3); -#ifdef POCO_ENABLE_CPP11 - pkcs3 = std::move(pkcs); full(pkcs3); PKCS12Container pkcs4(std::move(pkcs2)); full(pkcs4); -#endif // POCO_ENABLE_CPP11 - } catch (Poco::Exception& ex) {