[CMake] Source In Multiple Directories

Brad King brad.king at kitware.com
Fri Mar 25 11:45:58 EST 2005


Joe Cotellese wrote:
> I am trying to build a library which has sources in two directories. The 
> structure is as follows
> 
>  >prj
>  >----common
>  >----prjsrc
> 
> I'm creating a top level CMakeList file in prj. My question is what is 
> the best way to structure my CMakeList file. I don't want to create 
> libraries for both common and prjsrc. I'd rather just reference the 
> source in the parent CMakeList file. Is this legal and does it make 
> sense? Is there a better way to reference code in multiple directories?

The simplest way to do this is just specify the relative path to each 
source:

ADD_LIBRARY(mylib common/src1.c prjsrc/src2.c)

-Brad


More information about the CMake mailing list