Project: Guess default standard dialect if compiler was forced (#15852)
Prior to commit v3.4.0-rc1~71^2 (Project: Determine default language dialect for the compiler, 2015-09-15) we always guessed the default language standard dialect based on the compiler version. This was not reliable so that commit switched to computing the default language standard dialect while detecting the compiler id. When a toolchain file uses CMakeForceCompiler to set the compiler id then the detection does not occur. Therefore commit v3.4.0-rc1~54^2 (Project: Don't require computed default dialect if compiler was forced, 2015-09-22) made the lack of detection an error only if the compiler was not forced. However, this means that projects using CMakeForceCompiler no longer even get the guess that we had before so <LANG>_COMPILER does not work. Due to the sophistication of CMake's compiler detection logic projects should be ported away from using CMakeForceCompiler. In the meantime, restore a guess of the default language standard dialect when the compiler is forced.
This commit is contained in:
parent
d13758514c
commit
441dba8032
|
@ -18,6 +18,9 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
|
|||
message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_C_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
set(CMAKE_C_STANDARD_DEFAULT 99)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
|
|||
message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_CXX_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT 98)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -23,6 +23,13 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
|
|||
message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_C_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6)
|
||||
set(CMAKE_C_STANDARD_DEFAULT 11)
|
||||
else()
|
||||
set(CMAKE_C_STANDARD_DEFAULT 99)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
|
|||
message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_CXX_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT 98)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -28,6 +28,13 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
|
|||
message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_C_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
|
||||
set(CMAKE_C_STANDARD_DEFAULT 11)
|
||||
else()
|
||||
set(CMAKE_C_STANDARD_DEFAULT 90)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
|
|||
message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_CXX_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT 98)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
|
|||
message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
|
||||
elseif(NOT DEFINED CMAKE_CXX_STANDARD_DEFAULT)
|
||||
# Compiler id was forced so just guess the default standard level.
|
||||
set(CMAKE_CXX_STANDARD_DEFAULT 98)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue