blubberbernd
blubberbernd

Reputation: 3701

cmake, add_subdirectory without adding it to the generated project file?

I have a project that is build with cmake. In my cmakelists I have a add_subdirectory(externals/foo) to build the dependency "foo" which has it's own cmakelists.

Now it is so that also the whole foo sources and headers are included in the generated Project file (I'm using Eclipse). But all I want is to only have my project available in Eclipse (Eclipse has problems with subprojects in the same folder structure). So that the cmakelists from "foo" is only used to build "foo" automatically and link it to my project. I don't want to see it in my IDE however.

Is this possible? If yes: How?

Upvotes: 2

Views: 1202

Answers (2)

Tobias Schlegel
Tobias Schlegel

Reputation: 3970

No, how should the ide know what to compile if you don't tell it what to compile? If you don't want to have the project in you project file, just don't add it.

Just compile the external lib by itself (use "cmake externals/foo") and then add the libraries in your project's CMakeLists.txt with

target_link_libraries(your_project externals/foo/bin/foo.lib)

Upvotes: 0

Sam Hartsfield
Sam Hartsfield

Reputation: 1451

When I use Eclipse with CMake, I create the Eclipse project manually (with the New Project wizard) and for CMake I use the standard makefile generator. It requires a little extra setup: you need to set the build directory in the project properties if you're doing an out-of-source build, and I usually set the build command to make VERBOSE=1.

I'm not sure since I haven't used the Eclipse generator(s), but for the lack of a better solution, perhaps this method would solve your issue, since it gives you more control over the Eclipse project.

Upvotes: 1

Related Questions