cmake:在 CMakeLists.txt 中选择一个生成器 [英] cmake: Selecting a generator within CMakeLists.txt

查看:32
本文介绍了cmake:在 CMakeLists.txt 中选择一个生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想强制 CMake 使用 CMakeLists.txt 中的Unix Makefiles"生成器.

I would like to force CMake to use the "Unix Makefiles" generator from within CMakeLists.txt.

这是我现在使用的命令.

cmake -G "Unix Makefiles" .

我希望是这样.

cmake .

在安装了 VC 和自定义工具链的 Windows 上运行时.

When running on windows with VC installed and a custom tool-chain.

我希望能够在 CMakeLists.txt 文件中设置生成器.

I would expect to be-able to set the generator in the CMakeLists.txt file.

也许是这样的.

set(CMAKE_GENERATOR "Unix Makefiles")

推荐答案

这对我有用 - 在您的项目目录中创建一个名为 PreLoad.cmake 的文件,其中包含:

Here is what worked for me - create a file called PreLoad.cmake in your project dir containing this:

set (CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)

这篇关于cmake:在 CMakeLists.txt 中选择一个生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆