eclipse - 如何更改 Eclipse 中的 cmake 生成器?

标签 eclipse cmake

出于某种原因,当我尝试在 eclipse 中构建时,它会强制使用 -G Ninja。我宁愿 Eclipse 只是不指定 cmake 的 -G 选项,但我无法弄清楚如何配置 Eclipse 来做到这一点。

例如,在我的控制台窗口中:

Building in: /home/bgass/eclipse-workspace/scomlib/build/default
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/bgass/eclipse-workspace/scomlib
CMake Error: Error: generator : Ninja
Does not match the generator used previously: Unix Makefiles
Either remove the CMakeCache.txt file or choose a different binary directory.
cmake --build . -- -v
GNU Make 4.2.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Build complete (0 errors, 0 warnings): /home/bgass/eclipse-workspace/scomlib/build/default

在终端中,即使没有指定生成器,它也能正常工作。

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/bgass/eclipse-workspace/scomlib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bgass/eclipse-workspace/scomlib/build/default

最佳答案

我都是在eclipse外执行cmake,然后在Eclipse中打开生成的eclipse工程。

使用 -G "Eclipse CDT4 - Unix Makefiles" 将 Eclipse 指定为生成器。

以下是全套 Eclipse 生成器。

  Eclipse CDT4 - NMake Makefiles
                               = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - MinGW Makefiles
                               = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.

键入 cmake --help 以查看您的特定 cmake 版本支持哪些生成器。

关于eclipse - 如何更改 Eclipse 中的 cmake 生成器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55290446/

相关文章:

Eclipse 中的 Python 分析

java - 我试图从 jsp 文件调用 servlet 来执行业务逻辑并返回到同一页面

java - 有没有比 findViewById() 更好的方法将 XML 元素与 Android 中的 java 类链接起来

postgresql - 使用 CMake 安装 libpq 依赖项

c++ - 带柯南的 Cmakelists

c++ - 与Boost Filesystem的静态链接不起作用

java - SWT 未启用 shell

java - 如何在java小程序中翻转卡片

gcc - cmake 检测哪个库 libc++ 或 libstdc++ 配置为用于 g++ 或 clang++

c++ - CMake add_library(<lib> OBJECT <src>) 有环境变量吗?