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

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to