Skip to content

Commit 1e4bd22

Browse files
authored
fix(cmake): support release and debug at the same time (#3948)
1 parent a8b3ff3 commit 1e4bd22

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

tools/pybind11Tools.cmake

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,32 @@ if(PYTHON_IS_DEBUG)
115115
PROPERTY INTERFACE_COMPILE_DEFINITIONS Py_DEBUG)
116116
endif()
117117

118-
set_property(
119-
TARGET pybind11::module
120-
APPEND
121-
PROPERTY
122-
INTERFACE_LINK_LIBRARIES pybind11::python_link_helper
123-
"$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>")
118+
if(CMAKE_VERSION VERSION_LESS 3.11)
119+
set_property(
120+
TARGET pybind11::module
121+
APPEND
122+
PROPERTY
123+
INTERFACE_LINK_LIBRARIES
124+
pybind11::python_link_helper
125+
"$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>"
126+
)
124127

125-
set_property(
126-
TARGET pybind11::embed
127-
APPEND
128-
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11 $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
128+
set_property(
129+
TARGET pybind11::embed
130+
APPEND
131+
PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11 $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
132+
else()
133+
target_link_libraries(
134+
pybind11::module
135+
INTERFACE
136+
pybind11::python_link_helper
137+
"$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>"
138+
)
139+
140+
target_link_libraries(pybind11::embed INTERFACE pybind11::pybind11
141+
$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
142+
143+
endif()
129144

130145
function(pybind11_extension name)
131146
# The prefix and extension are provided by FindPythonLibsNew.cmake

0 commit comments

Comments
 (0)