[CMake] Library with source in multiple sub-directories

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Jun 17 08:26:55 EDT 2005


You all most have it. A parent can only see variables if they are in 
the cache. So in you sub directories you would need a line like this

SET(LAYER_LIB_SRC "sub/source0.cpp;sub/source1.cpp" CACHE INTERNAL "sub 
dir source files")

I make it internal so that it does not show up as a variable to edit. I 
am not sure what version of CMake you are using. But just to let you 
know I don't think there is a way to have this work with version 2.0 
and the up and coming 2.2. Check out this post for an explanation why:

http://public.kitware.com/pipermail/cmake/2005-June/006607.html

========================================================
Bradley Lowekamp
Management Systems Designers Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
'blowekamp at mail.nih.gov


On Jun 17, 2005, at 3:56 AM, Mr David McKinnon wrote:

> Hi,
>   I have a fairly simple question that in my initial attempts I have 
> not
> been able solve sufficiently.
>
>   I would like to build a library with the ADD_LIBRARY command from a
> set of source files that span multiple sub-directories. I am creating a
> list of the source files using the SET command in each of the
> sub-directories (SET(source1 ...)) then trying to append all the 
> sources
> together in the top-level directory as follows SET(all_source 
> ${source1}
> ${source2} ...) and using these as follows ADD_LIBRARY(a_library
> ${all_source}) but the result is that non of the source files from
> ${source1} etc. appear in the source file list in ${all_source}.
>
>   Is this right approach to this type of library building? Am I missing
> something on the lower directory levels that does not permit the source
> file information to be passed to the higher levels.
>
> Thanks,
> David McKinnon...
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
>



More information about the CMake mailing list