Reputation: 1091
I've created the eclipse project with cmake. I use vtk with qt. Dir structure is as follows:
parent_dir:
source - source.h, source.cpp
build - this is where the .project resides
I've fired up the eclipse with workspace dir /path/parent .
I have followed the instructions described in http://www.cmake.org/Wiki/Eclipse_CDT4_Generator . Everything builds fine, but navigation is not working. That is, the eclipse gives me the warning that the source.h is not indexed yet.
Furthermore, autocompletion doesn't work with qt and vtk related classes. I had checked with Project|Properties, where the qt and vtk includes are included. What am I doing wrong? I would really like to have autocompletion nd navigation in eclipse working with my project. I'm using eclipse ganymede on ubuntu 8.04 64-bit.
thx in advance
Upvotes: 3
Views: 4151
Reputation: 31
This took me quite a while to figure out. You should make sure that the "Build" directory is really NOT part of the project directory, which means, the most high-level directory that contains the "CMakeLists.txt".
So in my case, I have "dir/tree/project_dir" and "dir/tree/project_dir/src", then I should create the build directories "dir/tree/build_dir".
Then, I created a small script that creates both Debug and Release projects:
#!/bin/sh
mkdir -p $1_build/Release
mkdir -p $1_build/Debug
cmake -E chdir $1_build/Release cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../../$1
cmake -E chdir $1_build/Debug cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../$1
Call the script from "dir/tree" with argument "project_dir".
Then, in Eclipse, click "File" --> "Import" --> "General" --> "Existing Projects into Workspace". Specify the directory "dir/tree/$1_build", it will automatically recognize both projects.
Now, both Release and Debug projects are loaded into Eclipse, and you have all nice options like Code Assiste (code completion), and quick debugging by double-clicking on errors.
Note that you can add some file-filters in Eclipse to remove the CMake files from the project tree.
Upvotes: 3
Reputation: 56488
According to the Wiki, you should have your build tree outside the source tree.
This linked resource isn't created if the build directory is a subdirectory of the source directory because Eclipse doesn't allow to load projects which have linked resources pointing to a parent directory. So we recommend to create your build directories not as children, but as siblings to the source directory.
You'll need to do something like this:
mkdir /home/user/parent_dir_build
cd /home/user/parent_dir_build
cmake /home/user/parent_dir
Upvotes: 4