-
Notifications
You must be signed in to change notification settings - Fork 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
cmake: Improve handling of SECP256K1_APPEND_*FLAGS
options
#1648
base: master
Are you sure you want to change the base?
Conversation
Can you indicate why this is a draft? |
I haven't tested this branch with Xcode on macOS yet. |
debc50d
to
ce23e6e
Compare
Reworked to support only command-line build tool generators. Undrafted and ready for review :) |
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.
On the master branch @ f79f46c, setting
SECP256K1_APPEND_*FLAGS
when using IDE build tool generators, such as "Visual Studio" and "Xcode", has no effect because these generators do not utilise low-level rule variables when creating project files.This PR disables
SECP256K1_APPEND_*FLAGS
options in such scenarios. CMake will issue a warning if any of them are set.
Concept ACK
Special casing generators is not elegant, but yeah, it's probably a good idea. Otherwise, anyone who wants to use SECP256K1_APPEND_CFLAGS
on an unsupported build system will waste hours trying to understand why this is the case.
CMakeLists.txt
Outdated
if(CMAKE_GENERATOR MATCHES "Make|Ninja") | ||
# Only command-line build tool generators support low-level rule | ||
# variables. |
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.
nit:
While this seems to be true, I think it's a coincidence that these happen to be the command-line tools.
if(CMAKE_GENERATOR MATCHES "Make|Ninja") | |
# Only command-line build tool generators support low-level rule | |
# variables. | |
# Only some generators use low-level rule variables. | |
if(CMAKE_GENERATOR MATCHES "Make|Ninja") |
And I think the command should be above the if
line because it comments on the if
.
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.
Thanks! Reworked.
@@ -287,7 +287,7 @@ if(CMAKE_GENERATOR MATCHES "Make|Ninja") | |||
# guarantee that the flags appear at the end of the command line. | |||
set(SECP256K1_APPEND_CFLAGS "" CACHE STRING "Compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") | |||
if(SECP256K1_APPEND_CFLAGS) | |||
string(APPEND CMAKE_C_COMPILE_OBJECT " ${SECP256K1_APPEND_CFLAGS}") | |||
string(REPLACE "<FLAGS>" "<FLAGS> ${SECP256K1_APPEND_CFLAGS}" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") |
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.
Do you think this same should be done for CMAKE_C_CREATE_SHARED_LIBRARY
and/or CMAKE_C_LINK_EXECUTABLE
?
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.
Thanks! Done.
Command-line build tool generators are the only ones that support low-level rule variables. IDE build tool generators, such as "Visual Studio" and "Xcode", do not utilize these variables when creating project files. This change ensures that CMake warns users if any of the `SECP256K1_APPEND_*FLAGS` options are set while using an unsupported generator.
This change also makes the compile invocation string more natural by ensuring flags do not follow source files. Linker flags are also amended for consistency.
ce23e6e
to
c12bc01
Compare
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.
utACK c12bc01
On the master branch @ f79f46c, setting
SECP256K1_APPEND_*FLAGS
when using IDE build tool generators, such as "Visual Studio" and "Xcode", has no effect because these generators do not utilise low-level rule variables when creating project files.This PR disables
SECP256K1_APPEND_*FLAGS
options in such scenarios. CMake will issue a warning if any of them are set.Additionally, this PR fixes a bug with the clang-cl compiler (see #1647):
The last change is beneficial in its own right, as it makes the compile invocation string more natural by ensuring that flags do not follow source files.