diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index 3d1503df8..5535e872f 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -115,17 +115,32 @@ if(PYTHON_IS_DEBUG) PROPERTY INTERFACE_COMPILE_DEFINITIONS Py_DEBUG) endif() -set_property( - TARGET pybind11::module - APPEND - PROPERTY - INTERFACE_LINK_LIBRARIES pybind11::python_link_helper - "$<$,$>:$>") +if(CMAKE_VERSION VERSION_LESS 3.11) + set_property( + TARGET pybind11::module + APPEND + PROPERTY + INTERFACE_LINK_LIBRARIES + pybind11::python_link_helper + "$<$,$>:$>" + ) -set_property( - TARGET pybind11::embed - APPEND - PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11 $) + set_property( + TARGET pybind11::embed + APPEND + PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11 $) +else() + target_link_libraries( + pybind11::module + INTERFACE + pybind11::python_link_helper + "$<$,$>:$>" + ) + + target_link_libraries(pybind11::embed INTERFACE pybind11::pybind11 + $) + +endif() function(pybind11_extension name) # The prefix and extension are provided by FindPythonLibsNew.cmake