CMake:指定构建工具链
对 CMake 非常陌生,到目前为止我发现它非常有帮助。我有一组自定义库,我想使用交叉编译为多个平台构建它们。工具链已安装,我可以手动创建所需的 Makefile
,但我希望能够使用 CMake。
有没有办法告诉 cmake
使用哪个工具链,无论是在命令行还是在 CMakeLists.txt
文件中?
Very new to CMake, and so far I'm finding it to be extremely helpful. I have a set of custom libraries that I would like to build for multiple platforms using cross-compilation. The toolchains are installed, and I can hand-create the Makefile
s that I need to do so, but I would like to be able to make use of CMake.
Is there a way to tell cmake
which toolchain to use, either at the command line or in the CMakeLists.txt
file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这里:基本上,你定义了一个“工具链文件” " 它设置诸如系统名称、编译器路径等内容。然后您可以像这样调用
cmake
:Have a look here: basically, you define a "toolchain file" that sets things like the system name, paths to compilers and so on. You then call
cmake
like so:要自定义构建设置,以便不必每次都指定参数:
对于 Visual Studio - 此处
对于 Vusual Studio 代码:
安装 Cmake Tools 扩展(如果尚未安装)。
在 .vscode/settings.json 文件中设置参数 cmake.configureArgs。您还可以从设置
->
CMake Tools 配置->
添加项目< /强>。我的看起来像这样:To customize the build settings so you don't have to specify the parameter every time:
For Visual Studio - here
For Vusual Studio Code :
Install the Cmake Tools extension if haven't done so already.
In the .vscode/settings.json file set the parameter cmake.configureArgs. You can also set it from Settings
->
CMake Tools configuration->
Add Item. Mine looks like this: