CMake: Use user-provided CMAKE_CXX_STANDARD
wxBUILD_CXX_STANDARD is initialized with CMAKE_CXX_STANDARD. But if the user changes the value of CMAKE_CXX_STANDARD, it would keep using the old wxBUILD_CXX_STANDARD value.
This commit is contained in:
parent
57ed33978d
commit
395a61fc9a
1 changed files with 7 additions and 4 deletions
|
|
@ -34,15 +34,18 @@ function(checkCompilerDefaults)
|
||||||
wxHAVE_CXX17)
|
wxHAVE_CXX17)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if(DEFINED wxBUILD_CXX_STANDARD AND NOT wxBUILD_CXX_STANDARD STREQUAL COMPILER_DEFAULT)
|
if(DEFINED CMAKE_CXX_STANDARD)
|
||||||
|
# User has explicitly set a CMAKE_CXX_STANDARD.
|
||||||
|
elseif(DEFINED wxBUILD_CXX_STANDARD AND NOT wxBUILD_CXX_STANDARD STREQUAL COMPILER_DEFAULT)
|
||||||
|
# Standard is set using wxBUILD_CXX_STANDARD.
|
||||||
set(CMAKE_CXX_STANDARD ${wxBUILD_CXX_STANDARD})
|
set(CMAKE_CXX_STANDARD ${wxBUILD_CXX_STANDARD})
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
else()
|
else()
|
||||||
# If the standard is not set explicitly, check whether we can use C++11
|
# CMAKE_CXX_STANDARD not defined.
|
||||||
# without any special options.
|
|
||||||
checkCompilerDefaults()
|
checkCompilerDefaults()
|
||||||
if(NOT wxHAVE_CXX11)
|
if(NOT wxHAVE_CXX11)
|
||||||
# If not, request it explicitly and let CMake check if it's supported.
|
# If the standard is not set explicitly, and the default compiler settings
|
||||||
|
# do not support c++11, request it explicitly.
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue