简体   繁体   中英

Cmake generated Eclipse Project - No Source

I am attempting to use CMake to generate eclipse project files. Although I am able to build successfully, I am unable to browse or edit the source in 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:

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. Is this incorrect?

I create the eclipse project with the following command

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

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. 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.

Do you have a project defined?

I've made the same experience, both for Eclipse and 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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