MantisBT - CMake
View Issue Details
0015984CMakeCMakepublic2016-02-23 09:002016-06-10 14:31
Thiago 
Kitware Robot 
normalminoralways
closedmoved 
x86_64LinuxDebian 8
CMake 3.4.3 
 
0015984: "Eclipse CDT4 - Unix Makefiles" does not include subprojects source dir in the Eclipse projects
Assuming there is a project called "app1" that adds another sibling project "lib1" on its CMakeLists.txt. When calling cmake -G "Eclipse CDT4 - Unix Makefiles" to generate Eclipse projects, not only app1 project is created as the main project, but both projects are added as virtual [Subprojects], as expected.

That is great, however, only the source code of app1 is indexed by Eclipse. In order to indexing work for lib1 too, we need to manually right click the project and go to the "C/C++ Project paths" and add "[Subprojects]" or "[Subprojects]/lib1" in the Source list. That action would result in a tag being added to the .cproject:

<pathentry kind="src" path="[Subprojects]/lib1"/> is added to <storageModule moduleId="org.eclipse.cdt.core.pathentry">

It would be great if cmake added CMAKE_SOURCE_DIR of all subprojects to the parent project's .cproject during eclipse project generation
----------------------------------------------------------------------
App1's CMakeLists.txt
----------------------------------------------------------------------
cmake_minimum_required(VERSION 3.0)
project(MyApp1)

set(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT TRUE)

add_subdirectory("../lib1" "${CMAKE_CURRENT_BINARY_DIR}/lib1")
add_executable(app1 src/main.cpp)
target_link_libraries(app1 L1)

----------------------------------------------------------------------
Lib1's CMakeLists.txt
----------------------------------------------------------------------
cmake_minimum_required(VERSION 3.0)
project(MyLib1)

set(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT TRUE)
add_library(L1 SHARED src/main.cpp)
target_include_directories(L1 PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)

Go to an out-of-source dir and run:
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../../app3/

Import the project on eclipse

Try to see a lib1's function definition from app1 source code.

Only the lib1's header will be found by eclipse. lib1's function definition is not in the indexing databse and will not be found
It is a great addition to https://cmake.org/Bug/view.php?id=12579 [^] as well
No tags attached.
Issue History
2016-02-23 09:00ThiagoNew Issue
2016-06-10 14:29Kitware RobotNote Added: 0042944
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042944)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.