Skip to content

Commit 4bf60c6

Browse files
authored
Disable strip when build type is unset (pybind#4454) (pybind#4780)
1 parent 690a115 commit 4bf60c6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

tools/pybind11NewTools.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ function(pybind11_add_module target_name)
233233
endif()
234234
endif()
235235

236-
# Use case-insensitive comparison to match the result of $<CONFIG:cfgs>
237-
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
238-
if(NOT MSVC AND NOT "${uppercase_CMAKE_BUILD_TYPE}" MATCHES DEBUG|RELWITHDEBINFO)
239-
# Strip unnecessary sections of the binary on Linux/macOS
240-
pybind11_strip(${target_name})
236+
if(DEFINED CMAKE_BUILD_TYPE) # see https://github.com/pybind/pybind11/issues/4454
237+
# Use case-insensitive comparison to match the result of $<CONFIG:cfgs>
238+
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
239+
if(NOT MSVC AND NOT "${uppercase_CMAKE_BUILD_TYPE}" MATCHES DEBUG|RELWITHDEBINFO)
240+
# Strip unnecessary sections of the binary on Linux/macOS
241+
pybind11_strip(${target_name})
242+
endif()
241243
endif()
242244

243245
if(MSVC)

tools/pybind11Tools.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ function(pybind11_add_module target_name)
212212
endif()
213213
endif()
214214

215-
# Use case-insensitive comparison to match the result of $<CONFIG:cfgs>
216-
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
217-
if(NOT MSVC AND NOT "${uppercase_CMAKE_BUILD_TYPE}" MATCHES DEBUG|RELWITHDEBINFO)
218-
pybind11_strip(${target_name})
215+
if(DEFINED CMAKE_BUILD_TYPE) # see https://github.com/pybind/pybind11/issues/4454
216+
# Use case-insensitive comparison to match the result of $<CONFIG:cfgs>
217+
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
218+
if(NOT MSVC AND NOT "${uppercase_CMAKE_BUILD_TYPE}" MATCHES DEBUG|RELWITHDEBINFO)
219+
pybind11_strip(${target_name})
220+
endif()
219221
endif()
220222

221223
if(MSVC)

0 commit comments

Comments
 (0)