[CMake] install target added with add_subdirectory(EXCLUDE_FROM_ALL)
Nick Tasios
nicktasios at gmail.com
Wed Apr 15 06:20:40 EDT 2015
Hello everyone,
I recently started using cmake and I'm having some trouble setting-up my
project. I've searched quite a lot and couldn't find a clear answer.
The project has a top level CMakeLists.txt which builds the executable.
In my project, I have included external libraries which I add using
add_subdirectory. Most of these already came with a CMakeLists.txt file,
and some have multiple targets, i.e. to build shared or static
libraries, etc. In the project, though, I want to be able to choose only
a specific target to build, i.e. I might only want to build the shared
libraries. To do this, I add the option EXCLUDE_FROM_ALL when calling
add_subdirectory, and just add the target to the target link libraries
of the top-level executable.
This works fine, only in the install step I would like for the built
libraries to move to where the executable is. From my understanding, the
install directive of the sub projects is ignored, because install
depends on all and these sub projects are excluded from it.
So the question is, if there is a clean way to compile only the targets
(libraries) that are needed by the executable, and be able to install
these in the directory the executable is being installed. The method
needs to work cross-platform.
Cheers!
More information about the CMake
mailing list