mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 07:02:11 +00:00
fix: better handling of PYBIND11_CPP_STANDARD
This commit is contained in:
parent
c664d55757
commit
227170dc2f
@ -25,14 +25,23 @@ include(CheckCXXCompilerFlag)
|
|||||||
|
|
||||||
# Warn or error if old variable name used
|
# Warn or error if old variable name used
|
||||||
if(PYBIND11_CPP_STANDARD)
|
if(PYBIND11_CPP_STANDARD)
|
||||||
if(NOT CMAKE_CXX_STANDARD)
|
string(REGEX MATCH [[..$]] VAL "${PYBIND11_CPP_STANDARD}")
|
||||||
string(REGEX MATCH [=[..^]=] VAL "${PYBIND11_CPP_STANDARD}")
|
if(CMAKE_CXX_STANDARD)
|
||||||
|
if(NOT CMAKE_CXX_STANDARD STREQUAL VAL)
|
||||||
|
message(WARNING "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} does not match "
|
||||||
|
"PYBIND11_CPP_STANDARD=${PYBIND11_CPP_STANDARD}, "
|
||||||
|
"please remove PYBIND11_CPP_STANDARD from your cache")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
set(supported_standards 11 14 17 20)
|
set(supported_standards 11 14 17 20)
|
||||||
if("${VAL}" IN_LIST supported_standards)
|
if("${VAL}" IN_LIST supported_standards)
|
||||||
message(WARNING "USE -DCMAKE_CXX_STANDARD=${VAL} instead of PYBIND11_PYTHON_VERSION")
|
message(WARNING "USE -DCMAKE_CXX_STANDARD=${VAL} instead of PYBIND11_PYTHON_VERSION")
|
||||||
set(CMAKE_CXX_STANDARD ${VAL})
|
set(CMAKE_CXX_STANDARD
|
||||||
|
${VAL}
|
||||||
|
CACHE STRING "From PYBIND11_CPP_STANDARD")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "PYBIND11_CPP_STANDARD should be replaced with CMAKE_CXX_STANDARD")
|
message(FATAL_ERROR "PYBIND11_CPP_STANDARD should be replaced with CMAKE_CXX_STANDARD "
|
||||||
|
"(last two chars: ${VAL} not understood as a valid CXX std)")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user