-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: module being stripped if no build type selected (2.10.2 regression) #4454
Comments
FYI @henryiii , is this a regression or something we forgot to mention in the changelog? |
How would you propose using a generator expression? You can't run a configure-time function based on a generator expression. I need to check to see if generator expressions can be used inside pybind11_strip. To fix the bug back to 2.10.0 behavior, I expect you could check to see if it's defined? I'm guessing the quotes cause it to "not match" (empty string) rather then being skipped. |
Indeed, what I meant is changing the diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake
index cc87ced5..fa7170cb 100644
--- a/tools/pybind11Common.cmake
+++ b/tools/pybind11Common.cmake
@@ -397,9 +397,21 @@ function(pybind11_strip target_name)
set(x_opt -x)
endif()
- add_custom_command(
- TARGET ${target_name}
- POST_BUILD
- COMMAND ${CMAKE_STRIP} ${x_opt} $<TARGET_FILE:${target_name}>)
+ if(CMAKE_VERSION VERSION_LESS 3.8)
+ message(WARNING "CMake 3.8+ required for correct strip behavior when using multi-config "
+ "generators")
+ add_custom_command(
+ TARGET ${target_name}
+ POST_BUILD
+ COMMAND ${CMAKE_STRIP} ${x_opt} $<TARGET_FILE:${target_name}>)
+ else()
+ set(no_debug_info $<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>>)
+ set(strip_cmd ${CMAKE_STRIP} ${x_opt} $<TARGET_FILE:${target_name}>)
+ add_custom_command(
+ TARGET ${target_name}
+ POST_BUILD
+ COMMAND "$<${no_debug_info}:${strip_cmd}>"
+ COMMAND_EXPAND_LISTS)
+ endif()
endif()
endfunction() This would need some refactoring, though, because now I would definitely be in favor of adding the |
Recently got bitten by this. The modification @tttapa did to the Looking forward to seeing @tttapa's fix making into the master branch in the near future. |
Hello, I just found that issue. I trigger the |
We should match on RELEASE-like builds only, not the other way around. |
I have custom release-like targets too :). |
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.10.3
Problem description
If no
CMAKE_BUILD_TYPE
is specified, the seemingly innocuous quotes that were added in 88b019a cause thepybind11_add_module
function to strip the module, even for debug builds.By relying on
CMAKE_BUILD_TYPE
at configure time rather than on$<CONFIG>
at generation time, multi-configuration generators like Ninja Multi-Config cannot work correctly. It might be better to use a generator expression (e.g. https://stackoverflow.com/questions/45455350/cmake-how-to-add-a-custom-command-that-is-only-executed-for-one-configuration).Reproducible example code
CMakeLists.txt
Run CMake without build type
Is this a regression? Put the last known working version here if it is.
1f04cc7
The text was updated successfully, but these errors were encountered: