diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index 7afb0d0b1..69ac4b0f6 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -20,6 +20,7 @@ Adds the following functions:: #]======================================================] # CMake 3.10 has an include_guard command, but we can't use that yet +# include_guard(global) (pre-CMake 3.10) if(TARGET pybind11::lto) return() endif() diff --git a/tools/pybind11NewTools.cmake b/tools/pybind11NewTools.cmake index 0a7b84706..9e2fd2b40 100644 --- a/tools/pybind11NewTools.cmake +++ b/tools/pybind11NewTools.cmake @@ -5,6 +5,12 @@ # All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. +if(CMAKE_VERSION VERSION_LESS 3.12) + message(FATAL_ERROR "You cannot use the new FindPython module with CMake < 3.12") +endif() + +include_guard(GLOBAL) + get_property( is_config TARGET pybind11::headers @@ -16,10 +22,6 @@ else() set(_pybind11_quiet "") endif() -if(CMAKE_VERSION VERSION_LESS 3.12) - message(FATAL_ERROR "You cannot use the new FindPython module with CMake < 3.12") -endif() - if(NOT Python_FOUND AND NOT Python3_FOUND AND NOT Python2_FOUND) diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index 026069c73..c255e5cfd 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -5,6 +5,11 @@ # All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. +# include_guard(global) (pre-CMake 3.10) +if(TARGET pybind11::python_headers) + return() +endif() + # Built-in in CMake 3.5+ include(CMakeParseArguments)