我的 CMakeLists.txt
中有以下说明:
target_compile_options(sometarget PRIVATE
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-mllvm --inline-threshold=8192>
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-mllvm -polly>
)
cmake
主动将这些命令行选项转换为
-mllvm --inline-threshold=8192 -polly
在将其传递给编译器之前(通过 make 文件)。当然,编译器会提示它不知道 -polly
。
如何限制 CMake 的聪明才智并强制它按照我的意思传递给编译器:
-mllvm --inline-threshold=8192 -mllvm -polly
?
最佳答案
The final set of compile or link options used for a target is constructed by accumulating options from the current target and the usage requirements of its dependencies. The set of options is de-duplicated to avoid repetition. While beneficial for individual options, the de-duplication step can break up option groups. For example, -D A -D B becomes -D A B. One may specify a group of options using shell-like quoting along with a SHELL: prefix. The SHELL: prefix is dropped, and the rest of the option string is parsed using the separate_arguments() UNIX_COMMAND mode. For example, "SHELL:-D A" "SHELL:-D B" becomes -D A -D B.
尝试:
"SHELL:$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-mllvm --inline-threshold=8192>"
"SHELL:$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-mllvm -polly>"
关于c++ - 如何指示 CMake 不要合并编译器参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63889460/