[CMake] Correct usage of add_library

Cedric Doucet cedric.doucet at inria.fr
Wed Dec 23 05:32:12 EST 2015


Hello, 

I have a code which consist in a kernel and several independent modules which depend on this kernel. 
I would like to let users build the module they want by typing, for example, 

make module1 

to build the first module. 
But, as this first module depends on the kernel, I need this kernel to be built BEFORE module1. 

My file organization is the following: 

project_directory/ 
CMakeLists.txt 
src/ 
CMakeLists.txt 
kernel/ 
CMakeLists.txt 
modules/ 
CMakeLists.txt 
module1/ 
module2/ 

I guess I should use the add_library command to build the kernel first, but I don't know exactly how to do it since there are many possible usages of this command: 
https://cmake.org/cmake/help/latest/command/add_library.html 

Does someone know what is the cleanest way to do it? 

Cédric 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151223/98ab2eb1/attachment.html>


More information about the CMake mailing list