-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Respect CMAKE_<LANG>_COMPILE_OPTIONS_TARGET
#542
base: master
Are you sure you want to change the base?
Conversation
Required on QCC, which uses "-V" instead of "--target=".
@@ -738,8 +738,11 @@ function(_add_cargo_build out_cargo_build_out_dir) | |||
set(cargo_target_linker $<$<BOOL:${linker}>:${cargo_target_linker_var}=${linker}>) | |||
|
|||
if(Rust_CROSSCOMPILING AND (CMAKE_C_COMPILER_TARGET OR CMAKE_CXX_COMPILER_TARGET)) | |||
string(REPLACE "," "\$<COMMA>" c_opts_target "${CMAKE_C_COMPILE_OPTIONS_TARGET}") |
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.
are there any cases where CMAKE_<LANG>_COMPILE_OPTIONS_TARGET
contains a comma?
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.
No, but if there ever was one, the CMake error would be pretty cryptic. 😅
Learned this the hard way in another change I got lined up, which gives the same treatment to --sysroot
. There, the QCC parameter is -Wc,-isysroot,
.
It's probably fine to skip the escaping here though, if you prefer.
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.
another change I got lined up, which gives the same treatment to --sysroot
In that case, could you perhaps follow-up in the upstream CMake issue https://gitlab.kitware.com/cmake/cmake/-/issues/21382#note_852685 and clarify if CMake can officially document these two variables? Brad king seems to have indicated this is fine in the linked comment, but it would be good to have some confirmation, and even better if we could merge a PR to CMake first which documents these variables (to make them part of the official API)
It's probably fine to skip the escaping here though, if you prefer.
I would prefer skipping it unless necessary.
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 find, I'll approach upstream to get these documented.
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.
@mvf Did you receive any feedback from the CMake Maintainers?
In cross builds with
CMAKE_<C|CXX>_COMPILER_TARGET
, a hard-coded--target=
was passed to the compiler during linking. Some compilers, such as QNX's QCC wrapper, use a different parameter and the build would fail.To fix this, take the parameter name from CMake's
CMAKE_<LANG>_COMPILE_OPTIONS_TARGET
, with a fallback to--target=
.The variable was added to CMake back in 2013 with the very change that added
CMAKE_<LANG>_COMPILER_TARGET
: Kitware/CMake@76552d5. Nowadays, many cross compilers declare this variable: