-
Notifications
You must be signed in to change notification settings - Fork 37
cmake: Show error instead of invoking cross-compiled mpgen binary #171
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
base: master
Are you sure you want to change the base?
Conversation
Suggested by Cory Fields <cory-nospam-@coryfields.com> in bitcoin/bitcoin#31741 (comment)
| # should trigger a more readable attempting to run a cross compiled executable. | ||
| if(CMAKE_CROSSCOMPILING AND NOT MPGEN_EXECUTABLE) | ||
| include(CheckCXXSourceRuns) | ||
| check_cxx_source_runs("int main() { return 0; }" EXECUTABLES_CAN_RUN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. While looking for something like this, I stumbled upon try_run which takes CMAKE_CROSSCOMPILING into account, which is why I suggested just testing against the var itself. But it seems check_cxx_source_runs is more sane.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
|
⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
Idea here is to avoid potentially confusing errors if cross compiling and forgetting to set the MPGEN_EXECUTABLE.
Idea came from theuni in bitcoin/bitcoin#31741 (comment) with suggestion to show a warning whenever CMAKE_CROSSCOMPILING was set and MPGEN_EXECUTABLE wasn't set, but this would show a warning in the default build which excludes tests and examples and does not need to run the code generator. Also it could warn spuriously if cross-compiled binaries were actually executable.
Avoid these problems by using check_cxx_source_runs instead of CMAKE_CROSSCOMPILING to see if binaries can run and triggering an error at build time instead of configure time to avoid showing warnings when code generator is not actually needed.
This is currently a draft PR, because I haven't tested it on a cross-compiled system so not actually sure it is a significant improvement. Also not sure if this is the best approach.