Skip to content
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

cmakelists 生成不支持编译器 flags #5471

Closed
PolarLinda6 opened this issue Aug 16, 2024 · 12 comments
Closed

cmakelists 生成不支持编译器 flags #5471

PolarLinda6 opened this issue Aug 16, 2024 · 12 comments
Labels
Milestone

Comments

@PolarLinda6
Copy link

Xmake 版本

2.9.4

操作系统版本和架构

Windows 11 version 23H2

描述问题

xmake project -k cmakelists 生成 cmakelists

  1. 不支持编译器flags
  2. 特定编译参数丢失

期待的结果

if(Clang)
    target_compile_options(Main PRIVATE -Wno-gnu-line-marker)
    target_compile_options(Main PRIVATE -fexperimental-library)  # 生成的 cmakelists 中我并没有找到这个参数
    target_link_options(Main PRIVATE -lc++)
elseif(Gcc)
    target_compile_options(Main PRIVATE -Wno-non-template-friend)
    target_compile_options(Main PRIVATE -fanalyzer)
    target_link_options(Main PRIVATE -lstdc++)
    target_link_options(Main PRIVATE -lbenchmark)
)
endif()

工程配置

add_cxxflags("clang::-Wno-gnu-line-marker", "gcc::-Wno-non-template-friend")
add_cxxflags("clang::-stdlib=libc++", "clang::-fexperimental-library", "gcc::-fanalyzer")
add_ldflags("clangxx::-lc++", "gxx::-lstdc++", "gxx::-lbenchmark")

附加信息和错误日志

IMG_20240816_225343

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: cmakelists generation does not support compiler flags

@waruqi
Copy link
Member

waruqi commented Aug 20, 2024

试下这个 patch #5487

xmake update -s github:xmake-io/xmake#cmake

@PolarLinda6
Copy link
Author

PolarLinda6 commented Aug 20, 2024

试下这个 patch #5487

xmake update -s github:xmake-io/xmake#cmake

我已经更新到了新的分支, 但我遇到了一个问题:

set(CMAKE_C_COMPILER "/usr/sbin/gcc") set(CMAKE_CXX_COMPILER "/usr/sbin/g++") 会重复生成( 与 target 数目相同 )

image

@waruqi
Copy link
Member

waruqi commented Aug 20, 2024

再试试

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


try again

@waruqi
Copy link
Member

waruqi commented Aug 21, 2024

可以了么

@waruqi waruqi added this to the v2.9.5 milestone Aug 21, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Is it ok?

@PolarLinda6
Copy link
Author

PolarLinda6 commented Aug 21, 2024

可以了么

我遇到了新的问题:
set_runtimes 出现了错误, gcc clang 配置消失, msvc 配置错误

PS: 作者是否可以支持 set runtimes的编译器 flag 呢?( 使用 if 配置很痛苦 )

if "clang" == get_config("toolchain") then
  set_runtimes("c++_shared")
elseif "gcc" == get_config("toolchain") then
  set_runtimes("stdc++_static")
end

image

CMakeLists.txt
xmake.lua.txt

@waruqi
Copy link
Member

waruqi commented Aug 21, 2024

不同的问题不要混一起,这个跟当前的 issues 无关。如果当前的 issues 确认已经修复,我就 close 了。。

其他的问题 单独开 issues

@PolarLinda6
Copy link
Author

不同的问题不要混一起,这个跟当前的 issues 无关。如果当前的 issues 确认已经修复,我就 close 了。。

其他的问题 单独开 issues

好的, 谢谢作者了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Don't mix different issues together. This has nothing to do with the current issues. If the current issues are confirmed to have been fixed, I will close them. .

Open other issues separately

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Do not mix different issues together. This has nothing to do with the current issues. If the current issues are confirmed to have been fixed, I will close them. .

Other issues, open separate issues

Okay, thank you author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants