use C++17 when building with Visual Studio in CMake - fixes GUI CI builds (#4924)

* use C++17 when building with Visual Studio in CMake

* printInfo.cmake: print more variables

* CMakeLists.txt: set C++ standard earlier
This commit is contained in:
Oliver Stöneberg 2023-03-31 10:37:53 +02:00 committed by GitHub
parent 89ec148199
commit cb915085ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 2.8.12)
project(Cppcheck)
include(cmake/cxx11.cmake)
use_cxx11()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(GNUInstallDirs)
@ -13,13 +16,11 @@ include(cmake/findDependencies.cmake)
include(cmake/compileroptions.cmake)
include(cmake/compilerDefinitions.cmake)
include(cmake/buildFiles.cmake)
include(cmake/cxx11.cmake)
include(cmake/printInfo.cmake)
if(BUILD_GUI)
include(cmake/qtCompat.cmake)
endif()
use_cxx11()
file(GLOB addons "addons/*.py")
file(GLOB cfgs "cfg/*.cfg")

View File

@ -154,7 +154,7 @@ if (MSVC)
# C/C++ - Language
add_compile_options(/Zc:rvalueCast) # Enforce type conversion rules
add_compile_options(/std:c++14) # C++ Language Standard - ISO C++14 Standard
#add_compile_options(/std:c++14) # C++ Language Standard - ISO C++14 Standard
# C/C++ - Browse Information
# Enable Browse Information - No

View File

@ -6,7 +6,12 @@ macro(use_cxx11)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif ()
else ()
set (CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
# some GitHub Action windows runners randomly fail with a complaint that Qt6 requires a C++17 compiler
if (MSVC)
set (CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use")
else ()
set (CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
endif()
set (CMAKE_CXX_STANDARD_REQUIRED ON)
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)

View File

@ -1,9 +1,11 @@
message( STATUS "------------------ General configuration for ${PROJECT_NAME} ${VERSION} -----------------")
message( STATUS )
message( STATUS "CMake Version = ${CMAKE_VERSION}")
message( STATUS "CMake Generator = ${CMAKE_GENERATOR}")
message( STATUS "Compiler = ${CMAKE_CXX_COMPILER_ID}")
message( STATUS "Compiler Version = ${CMAKE_CXX_COMPILER_VERSION}")
message( STATUS "Build type = ${CMAKE_BUILD_TYPE}")
message( STATUS "CMake C++ Standard = ${CMAKE_CXX_STANDARD}")
message( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" )
message( STATUS "CMAKE_DISABLE_PRECOMPILE_HEADERS = ${CMAKE_DISABLE_PRECOMPILE_HEADERS}" )
message( STATUS "C++ flags (General) = ${CMAKE_CXX_FLAGS}")
@ -12,10 +14,10 @@ message( STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
message( STATUS "C++ flags (Debug) = ${CMAKE_CXX_FLAGS_DEBUG}")
message( STATUS "CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")
message( STATUS "CPPCHK_GLIBCXX_DEBUG = ${CPPCHK_GLIBCXX_DEBUG}" )
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach( d ${DirDefs} )
message( STATUS "Found Define: " ${d} )
endforeach()
get_directory_property( DirCompileDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
message( STATUS "COMPILE_DEFINITIONS (global) = ${DirCompileDefs}" )
get_directory_property( DirCompileOptions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS )
message( STATUS "COMPILE_OPTIONS (global) = ${DirCompileOptions}" )
message( STATUS )
message( STATUS "---------------------------------------------------------" )
message( STATUS "ANALYZE_MEMORY = ${ANALYZE_MEMORY}" )