-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
Provide cmake CMAKE_GNUtoMS utility #1181
Comments
看似是个不错的特性,但是我最近可能没时间实现,先暂定 2.5.2 ,后期看具体工作量和实现难度再具体排期看下,也欢迎提pr。。
还可以试试 intel 的 ifort 来编译,目前 xmake 也支持。
使用 set_plat/set_arch 针对特定 target 设置特定平台,或者使用 set_toolchains 针对 target 设置 特定 toolchains,不过这特性,最近 dev/master 有做过改进,比 2.3.9 支持的更好些。 |
有没有现成的工具或者命令可以转,或者有没有参考文章。。如果比较复杂的话,只能排到下个版本了。。 |
原理上就是综合使用gnu的linker和msvc的lib.exe,先生成.def再用.def生成import lib |
那这个主要在什么时机调用呢? 生成 xxx.dll.a 的时候 同时生成对应 msvc 的 lib? 这样的话,感觉就只能在 windows/mingw 上使用么。。macos/mingw上link完,又没法调用 lib.exe 要么不作为rule提供,单纯封装个 lua module 辅助接口,自己想用的时候,调用下,gnu2ms("xxx.dll.a", "*.def", "xxx.lib") 不过这样,得自己生成传入 def 了。。 |
cmake这个功能就是仅windows/mingw的,用辅助接口也可以,把中间生成的def文件当做临时文件用完删即可 |
加上了,dev上,试下这个模块接口:https://github.com/xmake-io/xmake/blob/dev/xmake/modules/utils/platform/gnu2mslib.lua import("utils.platform.gnu2mslib")
gnu2mslib("xxx.lib", "xxx.dll.a")
gnu2mslib("xxx.lib", "xxx.def")
gnu2mslib("xxx.lib", "xxx.dll.a", {dllname = "xxx.dll", arch = "x64"}) 支持从 def 生成 xxx.lib ,也支持从 xxx.dll.a 自动导出 .def ,然后再生成 xxx.lib 如果不想自动从dll.a生成 def,想借用 gnu linker 生成的 def,那就自己通过
也可以直接 |
Is your feature request related to a problem? Please describe.
https://cmake.org/cmake/help/latest/prop_tgt/GNUtoMS.html
cmake有一个GNUtoMS的功能,可以把MinGW生成的动态库(xxx.dll & xxx.dll.a)转换成Visual Studio可以识别的格式(xxx.dll & xxx.lib),从而实现混合编译
这个功能对Fortran & C++混合项目特别有帮助,因为VS不提供fortran编译器,只能用MinGW的gfortran来编译fortran部分,然后和VS的项目链接。往往这样的项目同时有一些其他的库以vs格式提供,因此纯用MinGW编译也不行,只能使用cmake的这个功能来混合编译
Describe the solution you'd like
提供一个模块把*.dll.a转换成*.lib
Describe the alternative solution you'd like
在target中提供一个选项,在platform为windows时使用gnu toolchain来编译target然后转化成vs格式
Additional context
另外,目前是否有办法在xmake.lua中指定一部分target用mingw,另一部分用vs编译?
The text was updated successfully, but these errors were encountered: