From: Enblend <enb...@li...> - 2019-11-23 14:04:13
|
branch: details: http://enblend.hg.sourceforge.net/hgweb/enblend/enblend/hg/p/enblend/code/rev/b7ed254a9d70 changeset: 1537:b7ed254a9d70 user: tmodes <tm...@us...> date: Sat Nov 23 15:02:34 2019 +0100 description: CMake: Use now C++17 standard in all builds diffstat: CMakeLists.txt | 61 ++++------------------- CMakeModules/FindCXX11Compiler.cmake | 89 ------------------------------------ CMakeModules/FindOptional.cmake | 19 ------- VERSION | 2 +- config.h.cmake | 15 ------ src/CMakeLists.txt | 1 - 6 files changed, 13 insertions(+), 174 deletions(-) diffs (253 lines): diff -r 1f882f1c83ef -r b7ed254a9d70 CMakeLists.txt --- a/CMakeLists.txt Sat Nov 23 13:45:52 2019 +0100 +++ b/CMakeLists.txt Sat Nov 23 15:02:34 2019 +0100 @@ -122,22 +122,13 @@ SET(ENABLE_DMALLOC_FUNC_CHECK OFF CACHE INTERNAL "") ENDIF(NOT WIN32) -IF(MSVC) - # Check CXX17 compiler - # MSVC needs c++17 switch for some constructs - SET(CMAKE_CXX_STANDARD 17) - SET(CMAKE_CXX_STANDARD_REQUIRED ON) - # MSVC 2017 has removed some deprecated functions with C++17 - # but there are still used by vigra, so bring they back for now - IF(MSVC_VERSION GREATER 1900) - ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC=1) - ENDIF() -ELSE() - # other compiler e.g. gcc complain about some constructs - # in depended libs when compiled with C++17 - # so for now keep at C++11 - SET(CMAKE_CXX_STANDARD 11) - SET(CMAKE_CXX_STANDARD_REQUIRED ON) +# we need a C++17 compliant compiler +SET(CMAKE_CXX_STANDARD 17) +SET(CMAKE_CXX_STANDARD_REQUIRED ON) +# MSVC 2017 has removed some deprecated functions with C++17 +# but there are still used by vigra, so bring they back for now +IF(MSVC_VERSION GREATER 1900) + ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC=1) ENDIF() IF(CMAKE_COMPILER_IS_GNUCXX) @@ -200,6 +191,7 @@ # Required Libraries first FIND_PACKAGE(LCMS2 REQUIRED) ADD_DEFINITIONS(-DHAVE_LIBLCMS2) +ADD_DEFINITIONS(-DCMS_NO_REGISTER_KEYWORD) FIND_PACKAGE(TIFF REQUIRED) FIND_PACKAGE(Perl REQUIRED) # this one is needed in doc. (Especially the program "convert") @@ -208,6 +200,10 @@ ADD_DEFINITIONS(-DHAVE_LIBGSL) ADD_DEFINITIONS(-DHAVE_LIBGSLCBLAS) LIST(APPEND common_libs ${LCMS2_LIBRARIES} ${TIFF_LIBRARIES} ${GSL_LIBRARIES}) +IF(CMAKE_COMPILER_IS_GNUCXX) +# gnu c++ requires -lstdc++fs for C++17 <filesystem> support +LIST(APPEND common_libs stdc++fs) +ENDIF() include_directories(${TIFF_INCLUDE_DIR} ${LCMS2_INCLUDE_DIR}) # Platform specifics required libraries @@ -216,42 +212,9 @@ INCLUDE_DIRECTORIES(${TOP_SRC_DIR}/src/win32helpers) ENDIF(WIN32) -# search for optional header -INCLUDE(CheckIncludeFileCXX) -CHECK_INCLUDE_FILE_CXX(optional HAVE_OPTIONAL) -IF(HAVE_OPTIONAL) - MESSAGE(STATUS "Using <optional> from compiler suite") -ELSE() - FIND_PACKAGE(Optional) - IF(OPTIONAL_FOUND) - MESSAGE(STATUS "Optional header found") - SET(HAVE_OPTIONAL_HPP 1) - INCLUDE_DIRECTORIES(${OPTIONAL_INCLUDE_DIR}) - ELSE() - MESSAGE(STATUS "No optional headers found, fall back to boost") - # search for boost - if(WIN32) - SET(Boost_USE_STATIC_LIBS ON) - IF( NOT Boost_root_suffix ) - SET( Boost_root_suffix _1_51_0 CACHE STRING "suffix of boost root dir." FORCE ) - ENDIF( NOT Boost_root_suffix ) - SET(Boost_USE_STATIC_LIBS ON) - if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") - set(BOOST_ROOT $ENV{BOOST_ROOT}) - else(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") - set(BOOST_ROOT ${SOURCE_BASE_DIR}/boost${Boost_root_suffix}) - endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") - endif() - FIND_PACKAGE(Boost 1.55 REQUIRED) - SET(HAVE_BOOST_OPTIONAL_HPP 1) - ENDIF() -ENDIF() - #check some header and functions include(ConfigureChecks.cmake) -include_directories(${Boost_INCLUDE_DIR}) - # Optional Libraries FIND_PACKAGE(ZLIB) FIND_PACKAGE(JPEG) diff -r 1f882f1c83ef -r b7ed254a9d70 CMakeModules/FindCXX11Compiler.cmake --- a/CMakeModules/FindCXX11Compiler.cmake Sat Nov 23 13:45:52 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -# Check if compiler supports C++11 features -# and which compiler switches are necessary -# CXX11_FLAG : contains the necessary compiler flag - -# -# Copyright (c) 2013 Thomas Modes <tmodes@@users.sourceforge.net> -# -# This file is part of Enblend. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# This file is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Enblend; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -INCLUDE(CheckCXXSourceCompiles) -INCLUDE(FindPackageHandleStandardArgs) - -SET(CXX11_FLAG_CANDIDATES - "--std=gnu++11" - "--std=c++11" - "--std=gnu++0x" -) - -# sample openmp source code to test -SET(CXX11_TEST_SOURCE -" -template <typename T> -struct check -{ - static_assert(sizeof(int) <= sizeof(T), \"not big enough\"); -}; - -typedef check<check<bool>> right_angle_brackets; - -class TestDeleted -{ -public: - TestDeleted() = delete; -}; - - -int a; -decltype(a) b; - -typedef check<int> check_type; -check_type c; -check_type&& cr = static_cast<check_type&&>(c); - -auto d = a; - -int main() { - return 0; -}; -") - -# check c compiler -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_FLAG "${FLAG}") - BREAK() - ENDIF() -ENDFOREACH() - -# handle the standard arguments for find_package -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CXX11Compiler DEFAULT_MSG CXX11_FLAG) - -MARK_AS_ADVANCED(CXX11_FLAG) diff -r 1f882f1c83ef -r b7ed254a9d70 CMakeModules/FindOptional.cmake --- a/CMakeModules/FindOptional.cmake Sat Nov 23 13:45:52 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -IF (OPTIONAL_INCLUDE_DIR) - # Already in cache, be silent - SET(OPTIONAL_FIND_QUIETLY TRUE) -ENDIF() - -FIND_PATH(OPTIONAL_INCLUDE_DIR optional.hpp - /usr/local/include - /usr/include - ${SOURCE_BASE_DIR}/Optional-master -) - - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Optional DEFAULT_MSG - OPTIONAL_INCLUDE_DIR) - -MARK_AS_ADVANCED( - OPTIONAL_INCLUDE_DIR -) diff -r 1f882f1c83ef -r b7ed254a9d70 VERSION --- a/VERSION Sat Nov 23 13:45:52 2019 +0100 +++ b/VERSION Sat Nov 23 15:02:34 2019 +0100 @@ -1,1 +1,1 @@ -4.3-2a3eed753859 +4.3-1f882f1c83ef diff -r 1f882f1c83ef -r b7ed254a9d70 config.h.cmake --- a/config.h.cmake Sat Nov 23 13:45:52 2019 +0100 +++ b/config.h.cmake Sat Nov 23 15:02:34 2019 +0100 @@ -77,21 +77,6 @@ /* Define to 1 if strerror_r returns char *. */ #cmakedefine STRERROR_R_CHAR_P 1 -/* Define to 1 if std::as_const (C++ 17) is available */ -#cmakedefine HAVE_AS_CONST 1 - -/* Define to 1 if <filesystem> is available */ -#cmakedefine HAVE_STD_FILESYSTEM 1 - -/* Define to 1 if <optional> is available */ -#cmakedefine HAVE_OPTIONAL 1 - -/* Define to 1 if <optional.hpp> is available */ -#cmakedefine HAVE_OPTIONAL_HPP 1 - -/* Define to 1 if <boost/optional.hpp> should be used */ -#cmakedefine HAVE_BOOST_OPTIONAL_HPP 1 - /* Version number of package */ #define VERSION "${ENBLEND_VERSION_ONLY}" diff -r 1f882f1c83ef -r b7ed254a9d70 src/CMakeLists.txt --- a/src/CMakeLists.txt Sat Nov 23 13:45:52 2019 +0100 +++ b/src/CMakeLists.txt Sat Nov 23 15:02:34 2019 +0100 @@ -120,7 +120,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) -message(STATUS "Boost_FOUND = ${Boost_FOUND}") message(STATUS "OpenMP_CXX_FLAGS = ${OpenMP_CXX_FLAGS}") add_executable(enblend ${ENBLEND_SOURCES}) |