[CMake] Add subdir and library in CmakeList.txt

William A. Hoffman billlist at nycap.rr.com
Fri Sep 23 15:08:57 EDT 2005


>
>Is it possible to include a SUBDIR list as well as a library in one CMakeList.txt file? 
>
>I want to be able to build a library in the current directory, as well as call the CMakeList.txt file in 2 subdirectories.  My CMakeList.txt file looks like: 
>SUBDIRS(dir1 dir2) 
>
>SET(SOURCES <file list> ) 
>
>ADD_LIBRARY(libname SHARED ${SOURCES}) 
>
>But when I run cmake, I get messages looking for the files listed in the subdirectories, rather than the current directory: 
>CMake Error: can not find file /home/cmake_demo/current_dir/dir1/file1.c 
>
>Tried .c .C .c++ .cc .cpp .cxx .m .M .mm .h .h++ .hm .hpp .hxx .in .txx 
>
>Is this possible?  If not, how do I build the library in current dir?  How do I say I also want to build subdirectories?  I tried using the PREORDER flag in the SUBDIRS statement since I want to build those first, that that didn't seem to help at all.

This is certainly possible.   Where is file1.c added?  Could the error be in one of the sub dirs?

-Bill



More information about the CMake mailing list