@@ -132,17 +132,50 @@ if(MSVC)
132132 PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT :$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
133133 endif ()
134134endif ()
135+
136+ # ----------------------- Legacy option --------------------------
137+
138+ # Warn or error if old variable name used
139+ if (PYBIND11_CPP_STANDARD)
140+ string (REGEX MATCH [[..$]] VAL "${PYBIND11_CPP_STANDARD} " )
141+ if (CMAKE_CXX_STANDARD)
142+ if (NOT CMAKE_CXX_STANDARD STREQUAL VAL)
143+ message (WARNING "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} does not match "
144+ "PYBIND11_CPP_STANDARD=${PYBIND11_CPP_STANDARD} , "
145+ "please remove PYBIND11_CPP_STANDARD from your cache" )
146+ endif ()
147+ else ()
148+ set (supported_standards 11 14 17 20)
149+ if ("${VAL} " IN_LIST supported_standards)
150+ message (WARNING "USE -DCMAKE_CXX_STANDARD=${VAL} instead of PYBIND11_PYTHON_VERSION" )
151+ set (CMAKE_CXX_STANDARD
152+ ${VAL}
153+ CACHE STRING "From PYBIND11_CPP_STANDARD" )
154+ else ()
155+ message (FATAL_ERROR "PYBIND11_CPP_STANDARD should be replaced with CMAKE_CXX_STANDARD "
156+ "(last two chars: ${VAL} not understood as a valid CXX std)" )
157+ endif ()
158+ endif ()
159+ endif ()
160+
135161# --------------------- Python specifics -------------------------
136162
137- # Check to see which Python mode we are in, new or old python
138- if (PYBIND11_FINDPYTHON
139- OR Python_FOUND
140- OR Python3_FOUND
141- OR Python2_FOUND)
163+ # Check to see which Python mode we are in, new, old, or no python
164+ if (PYBIND11_NOPYTHON)
165+ set (_pybind11_nopython ON )
166+ if (NOT pybind11_QUIETLY)
167+ message (STATUS "pybind11 in NOPYHTON mode" )
168+ endif ()
169+ elseif (PYBIND11_FINDPYTHON OR Python_FOUND)
142170
143171 # New mode
144172 include ("${CMAKE_CURRENT_LIST_DIR} /pybind11NewTools.cmake" )
145173
174+ elseif (Python3_FOUND OR Python2_FOUND)
175+ set (_pybind11_nopython ON )
176+ if (NOT pybind11_QUIETLY)
177+ message (STATUS "pybind11 in NOPYHTON mode due to Python2/Python3 only being present" )
178+ endif ()
146179else ()
147180
148181 # Classic mode
@@ -221,11 +254,11 @@ function(_pybind11_generate_lto target prefer_thin_lto)
221254 TARGET ${target}
222255 APPEND
223256 PROPERTY INTERFACE_COMPILE_OPTIONS "$<${genex} :${PYBIND11_LTO_CXX_FLAGS} >" )
224- if (NOT is_config)
257+ if (NOT is_config AND NOT pybind11_QUIETLY )
225258 message (STATUS "${target} enabled" )
226259 endif ()
227260 else ()
228- if (NOT is_config)
261+ if (NOT is_config AND NOT pybind11_QUIETLY )
229262 message (STATUS "${target} disabled (not supported by the compiler and/or linker)" )
230263 endif ()
231264 endif ()
0 commit comments