Closed ZCB1208 closed 3 months ago
Bot detected the issue body's language is not English, translate it automatically.
Title: windows environment, the CMakeLists.txt file is generated, and an error is reported when using cmake + Ninja + tcc to compile.
xmake 可以直接编译干嘛不用? xmake 可以直接生成 build ninja 干嘛不用?要这么饶两层?
另外,为啥移动至 CMakeLists.txt 最上面就可以,这不应该是 cmake 的 issues 么,为啥要改 xmake。。
Bot detected the issue body's language is not English, translate it automatically.
Why not use xmake if you can compile it directly? xmake can directly generate build ninja, why not use it? Do you want to spare two layers like this?
In addition, why can it be moved to the top of CMakeLists.txt? Shouldn't this be an issue of cmake? Why should xmake be changed? .
是的,确实是绕了两层,非常无奈公司要求就是必须要用使用 cmake + ninja ,原因在于国外的团队开发组用了这个组合,所以要求我们也要切换至这样。
虽然极力推荐 使用 xmake ,并阐述了个人的几个看法,无奈人微言轻,只能被迫这样的兼容设计,自己在开发与测试的时候,都是直接使用 xmake 进行的,方便很多。 目前在本地开发以及 cicd 测试的时候,我尽量都是使用 xmake 二 cmake 只是作为一个补充,只是为了符合公司要求而已。
虽然这确实是 cmake 的问题,但是目前我只能这样选择去做兼容,最终选择做出这样的提交,希望能为与我一样处境的开发者提供一些便利,确实找这个问题也是花费了一些时间,并不许想后续如我类似的开发者在遇到这样的问题就放弃l 这么好的工具,希望未来 xmake 能成为开发者的首选。看看我们国人做的多么优秀的工具,对洋人,洋工具能祛魅。
Bot detected the issue body's language is not English, translate it automatically.
Yes, it is indeed two layers of detours. It is very frustrating that the company requires that cmake + ninja must be used. The reason is that the foreign team development team uses this combination, so we are required to switch to this.
Although I strongly recommend the use of xmake and elaborated on several personal opinions, I have no choice but to speak lightly and can only be forced to adopt such a compatible design. When developing and testing, I directly use xmake, which is much more convenient. At present, when developing locally and testing cicd, I try to use xmake and cmake as a supplement, just to meet the company's requirements.
Although this is indeed a problem with cmake, at present I can only choose to make it compatible. I finally chose to make this submission, hoping to provide some convenience to developers in the same situation as me. It did take some time to find this problem. , and I don’t think that developers like me will give up such a good tool when encountering such problems. I hope that xmake will become the first choice of developers in the future. Look at the excellent tools our Chinese make. For foreigners, foreign tools can dispel their charm.
这可能是由于 project( C)
里面有 language 设置,cmake 解析到这直接开始探测编译器了。所以 set compilers 得放到 project 之前才行。
可以试下这个 patch https://github.com/xmake-io/xmake/pull/5449
不过你这种搞法,之后会碰到很多问题的,有些特性问题 就没那么好规避了,毕竟多绕一层,就会损失一些 xmake 原有的特性,导致差异,还饶了两层。
尤其是一些 rules 目前还无法很好适配 project generator ,不光只是 cmakelists generator.
既然你这公司硬性规避不让用,个人又想要用 xmake,其实个人建议,你通过 xmake 生成初始 cmakelists.txt 后,自己改改,然后同时维护,cmakelists.txt 和 xmake.lua 。。自己平常用 xmake.lua ,对外提供 cmakelists.txt 互不冲突,也不用每次去生成,后期也就是加加 files flags啥的 。
我自己也是这么搞得。
Bot detected the issue body's language is not English, translate it automatically.
This may be because there is a language setting in
project(C)
, and cmake parses this and starts detecting the compiler directly. So set compilers must be placed before project.
You can try this patch https://github.com/xmake-io/xmake/pull/5449
However, you will encounter many problems in the future with this approach, and some feature issues are not so easy to avoid. After all, if you go around one more layer, you will lose some of xmake's original features, resulting in differences, and you will save two layers.
In particular, some rules are currently not well adapted to the project generator, not just the cmakelists generator.
Bot detected the issue body's language is not English, translate it automatically.
Since your company strictly avoids using it, and I personally want to use xmake, I personally suggest that after you generate the initial cmakelists.txt through xmake, you can modify it yourself, and then maintain cmakelists.txt and xmake.lua at the same time. . I usually use xmake.lua, and the external cmakelists.txt provided does not conflict with each other, and there is no need to generate it every time. In the later stage, I just add files flags and so on.
That's what I did myself.
我 merge 了,xmake update -s dev
Bot detected the issue body's language is not English, translate it automatically.
I merged, xmake update -s dev
既然你这公司硬性规避不让用,个人又想要用 xmake,其实个人建议,你通过 xmake 生成初始 cmakelists.txt 后,自己改改,然后同时维护,cmakelists.txt 和 xmake.lua 。。自己平常用 xmake.lua ,对外提供 cmakelists.txt 互不冲突,也不用每次去生成,后期也就是加加 files flags啥的 。
我自己也是这么搞得。
嗯呢,很好的建议,感谢,我也还是维护两份好了
Bot detected the issue body's language is not English, translate it automatically.
Since your company strictly avoids using it, and I personally want to use xmake, I personally suggest that after generating the initial cmakelists.txt through xmake, you can modify it yourself, and then maintain cmakelists.txt and xmake.lua at the same time. . I usually use xmake.lua, and the cmakelists.txt provided to the outside world does not conflict with each other, and there is no need to generate it every time. In the later stage, I just add files flags and so on.
I did the same thing myself.
Well, that’s a very good suggestion. Thank you. I’ll just maintain two copies.
Is your feature request related to a problem? Please describe.
生成 cmakelist 文件
xmake project -k cmakelists
可以正常生成 CMakeList.txt 文件然后创建 cmake_build 文件夹,并进入 cmake_build 文件夹:
cd cmake_build
使用命令调用 cmake 编译 cmakelist 文件
cmake .. -G Ninja
此时报错信息如下: ` The C compiler identification is unknown CMake Error at CMakeLists.txt:11 (project): No CMAKE_C_COMPILER could be found.
The C compiler identification is unknown CMake Error at CMakeLists.txt:11 (project): No CMAKE_C_COMPILER could be found.
Configuring incomplete, errors occurred!`
无法进行正常编译生成 ninja 文件
Describe the solution you'd like
将
set(CMAKE_C_COMPILER "tcc")
这一行,移动至 CMakeLists.txt 最上面,即可解决问题临时解决,让cmake 通过编译可以采用这种方式
Describe alternatives you've considered
此种解决方案,在下一次生成 cmakelists 文件后又会无法解决,故而需要对 生成 cmakelist 文件的脚本进行修改
在文件 xmake\plugins\project\cmake\cmakelists.lua 文件中增加如下函数
再在函数
_generate_cmakelists
中增加调用原则上需要对下面生成的
set(CMAKE_C_COMPILER "tcc")
内容注释掉,但是实际测试,不注释也没有问题, 暂时用这样不修改原有生成脚本的基础上可以解决问题Additional context