简体   繁体   English

Cmake 生成的 Eclipse 项目 - 无源

[英]Cmake generated Eclipse Project - No Source

I am attempting to use CMake to generate eclipse project files.我正在尝试使用 CMake 生成 Eclipse 项目文件。 Although I am able to build successfully, I am unable to browse or edit the source in eclipse.虽然我能够成功构建,但我无法在 eclipse 中浏览或编辑源代码。 This is an out of tree build, where my build directory is at the same level as my source directory.这是一个树外构建,其中我的构建目录与我的源目录处于同一级别。 I am using the following command to generate the eclipse files:我正在使用以下命令生成 eclipse 文件:

cmake -G"Eclipse CDT4 - Unix Makefiles" -DBoost_NO_BOOST_CMAKE=ON -DBOOST_ROOT=/usr/local/lib -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../proc cmake -G"Eclipse CDT4 - Unix Makefiles" -DBoost_NO_BOOST_CMAKE=ON -DBOOST_ROOT=/usr/local/lib -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../proc

The source directory has many different modules, but the top level CMakeLists file is essentially a bunch of add_subdirectory commands adding each module.源目录有许多不同的模块,但顶级 CMakeLists 文件本质上是一堆 add_subdirectory 命令添加每个模块。 Is this incorrect?这不正确吗?

I create the eclipse project with the following command我使用以下命令创建 eclipse 项目

cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_BUILD_TYPE=Debug $PROJECT_SRC_DIR
// $PROJECT_SRC_DIR is where my highest level CMakeLists.txt is

My CMakeLists.txt does basically look like this我的 CMakeLists.txt 基本上看起来像这样

cmake_minimum_required (VERSION 3.5.0)
cmake_policy(VERSION 3.5.0)
project(myproject VERSION 0.0.0)
# definition, find packages, compiler settings
add_subdirectory(src) # where my code is
# src contains further subdirectories with CMakeLists.txt and subproject definition therein.

This creates an eclipse project with a virtual directory [Source Directory] which points to the directory where Eclipse shows the content of the highest level CMakeLists.txt file with a project(...) command.这将创建一个带有虚拟目录 [Source Directory] ​​的 eclipse 项目,该目录指向 Eclipse 使用project(...)命令显示最高级别 CMakeLists.txt 文件内容的目录。 Furthermore it shows [Subprojects] and [Targets] where the sources are shown for cmake subprojects (the directory content from the level of CMakeLists.txt where the subproject is defined) or targets (the list of file which are combined to an executable with the add_executable() command.此外,它还显示了 [Subprojects] 和 [Targets],其中显示了 cmake 子项目(定义子项目的 CMakeLists.txt 级别的目录内容)或目标(组合到可执行文件的文件列表) add_executable()命令。

Do you have a project defined?你有定义的项目吗?

I've made the same experience, both for Eclipse and KDevelop.我为 Eclipse 和 KDevelop 都做过同样的经历。 CMake prepares the configuration such that you can compile and debug from within those IDEs, but it doesn't actually add any information that would help the IDE to list source files for browsing them. CMake 准备了配置,以便您可以从这些 IDE 中进行编译和调试,但它实际上并未添加任何有助于 IDE 列出源文件以供浏览的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM