-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cmake] Use generator expressions to change conditionalize target_compile_definition that are for c/c++ only be used for c/c++ #37510
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
Conversation
cmake/modules/AddSwift.cmake
Outdated
else() | ||
target_compile_definitions(${target} PRIVATE -DNDEBUG) | ||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-DNDEBUG>) |
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.
I by mistake changed this to definitions. I am going to change this back before it goes in. (I think I did it in a few more places as well).
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.
I looked through the commit and these were the only two that I found.
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.
This technically changes the behaviour - it changes ordering to be precise. I think that using target_compile_definitions
is better, but Im not opposed to this change.
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.
Was just an error
cmake/modules/AddSwift.cmake
Outdated
else() | ||
target_compile_definitions(${target} PRIVATE -DNDEBUG) | ||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-DNDEBUG>) |
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.
This technically changes the behaviour - it changes ordering to be precise. I think that using target_compile_definitions
is better, but Im not opposed to this change.
…pile_definition that are for c/c++ only be used for c/c++ I am in the process now of preparing the tree for the addition of Swift code in the optimizer as a normal source of source file. The goal is to make it so that one can just include a random swift library anywhere in the swift project host build and the cmake will use the swift compiler from the host toolchain/compile-link the code just as if it was a normal host side thing (1). In order to do this though, we need to deal with the legacy of our cmake creating compile flags without constraining the flags to only being used if cmake is compiling c/c++ code. To fix this, I just inserted generator expressions into the host side swift build's cmake that uses generator expressions to perform such conditionalization. The result is that the parts of a target that are c/c++ will get these flags, but these flags will not propagate to any Swift files that we add. (1) With time this implies that we will need to be able to bootstrap the swift compiler. We are not crossing that bridge now since the only places that we are going to use this today is in the SILOptimizer optimier passes. These can always be disabled while cross compiling, meaning that we can make progress here without having the bootstrapping completely ironed out.
dd30a17
to
558c9d4
Compare
@swift-ci smoke test |
should be NFC |
I am in the process now of preparing the tree for the addition of Swift code in
the optimizer as a normal source of source file. The goal is to make it so that
one can just include a random swift library anywhere in the swift project host
build and the cmake will use the swift compiler from the host
toolchain/compile-link the code just as if it was a normal host side thing (1).
In order to do this though, we need to deal with the legacy of our cmake
creating compile flags without constraining the flags to only being used if
cmake is compiling c/c++ code. To fix this, I just inserted generator
expressions into the host side swift build's cmake that uses generator
expressions to perform such conditionalization. The result is that the parts of
a target that are c/c++ will get these flags, but these flags will not propagate
to any Swift files that we add.
(1) With time this implies that we will need to be able to bootstrap the swift
compiler. We are not crossing that bridge now since the only places that we are
going to use this today is in the SILOptimizer optimier passes. These can always
be disabled while cross compiling, meaning that we can make progress here
without having the bootstrapping completely ironed out.