Disable strip when build type is unset (#4454) (#4780)

This commit is contained in:
Pieter P 2023-08-08 05:58:30 +02:00 committed by GitHub
parent 690a115d84
commit 4bf60c609a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -233,12 +233,14 @@ function(pybind11_add_module target_name)
endif()
endif()
if(DEFINED CMAKE_BUILD_TYPE) # see https://github.com/pybind/pybind11/issues/4454
# Use case-insensitive comparison to match the result of $<CONFIG:cfgs>
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
if(NOT MSVC AND NOT "${uppercase_CMAKE_BUILD_TYPE}" MATCHES DEBUG|RELWITHDEBINFO)
# Strip unnecessary sections of the binary on Linux/macOS
pybind11_strip(${target_name})
endif()
endif()
if(MSVC)
target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)

View File

@ -212,11 +212,13 @@ function(pybind11_add_module target_name)
endif()
endif()
if(DEFINED CMAKE_BUILD_TYPE) # see https://github.com/pybind/pybind11/issues/4454
# Use case-insensitive comparison to match the result of $<CONFIG:cfgs>
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
if(NOT MSVC AND NOT "${uppercase_CMAKE_BUILD_TYPE}" MATCHES DEBUG|RELWITHDEBINFO)
pybind11_strip(${target_name})
endif()
endif()
if(MSVC)
target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)