include(CheckCXXCompilerFlag) if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") CHECK_CXX_COMPILER_FLAG("-std=c++2a" COMPILER_SUPPORTS_CXX2A) CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX2A) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") elseif(COMPILER_SUPPORTS_CXX17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") elseif(COMPILER_SUPPORTS_CXX14) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") elseif(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wfloat-equal -Wno-long-long -Wpedantic -funsigned-char") set(CMAKE_CXX_FLAGS_DEBUG "-g3 -fexceptions -O0 -D_DEBUG -DDEBUG") add_definitions("-D_WINDOWS -D_UNICODE -DUNICODE") endif() if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwin32 -mthreads -municode") endif(CMAKE_COMPILER_IS_GNUCXX) if(MSVC) CHECK_CXX_COMPILER_FLAG("-std:c++latest" COMPILER_SUPPORTS_CXXLATEST) CHECK_CXX_COMPILER_FLAG("-std:c++17" COMPILER_SUPPORTS_CXX17) if(COMPILER_SUPPORTS_CXXLATEST) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++latest") elseif(COMPILER_SUPPORTS_CXX17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++17") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.") endif() add_definitions("-wd4503 -D_UNICODE -DUNICODE") endif(MSVC)