xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

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

Closed PolarLinda6 closed 2 months ago

PolarLinda6 commented 3 months ago

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 commented 3 months ago

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


Title: cmakelists generation does not support compiler flags

waruqi commented 2 months ago

试下这个 patch https://github.com/xmake-io/xmake/pull/5487

xmake update -s github:xmake-io/xmake#cmake
PolarLinda6 commented 2 months ago

试下这个 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 commented 2 months ago

再试试

Issues-translate-bot commented 2 months ago

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


try again

waruqi commented 2 months ago

可以了么

Issues-translate-bot commented 2 months ago

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


Is it ok?

PolarLinda6 commented 2 months ago

可以了么

我遇到了新的问题: 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 commented 2 months ago

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

其他的问题 单独开 issues

PolarLinda6 commented 2 months ago

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

其他的问题 单独开 issues

好的, 谢谢作者了

Issues-translate-bot commented 2 months ago

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 commented 2 months ago

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