[CMake] SubDirs and Libraries

Peter Kahn citizenkahn at gmail.com
Wed Oct 4 22:53:29 EDT 2006


I was using it as a variable ${LibName} that was my problem.  Thanks.

On 10/4/06, Brad King <brad.king at kitware.com> wrote:
> Peter Kahn wrote:
> > What is the standard way of having cmake access libaries built on the
> > same subdir level?
> >
> > I have a project with two subdirs: Util and App.   Util builds a
> > library called 'utillib'.  Ap builds a
> > library and an exe (aplib, and ap.exe).
> > Main\
> >    CMakeLists.tst
> >    Util\CMakeLists.txt
> >    App\CmakeLists.txt
> >
> > If I define the utillib in Main\Util\CMakeLists.txt  how can the
> > Main\App\CMakeLists.txt use it?  Should I define something in
> > Main\CMakeLists.txt first and then populate it when Main\Util builds?
>
> Just reference targets by their logical name (given to ADD_EXECUTABLE or
> ADD_LIBRARY commands).
>
> # CMakeLists.txt
> ADD_SUBDIRECTORY(Util)
> ADD_SUBDIRECTORY(App)
>
> # Util/CMakeLists.txt
> ADD_LIBRARY(mylib ...)
>
> # App/CMakeLists.txt
> ADD_EXECUTABLE(myexe ...)
> TARGET_LINK_LIBRARIES(myexe mylib)
>
> -Brad
>
>


-- 
Peter Kahn
citizenkahn at gmail.com
citizenkahn at jabber80.com, pkahnpie1 at AIM, skype: citizenkahn
http://kahnstipation.blogspot.com | http://analogoustendencies.blogspot.com/
Awareness - Intention - Action


More information about the CMake mailing list