[CMake] add_dependencies question

Nico Galoppo ngaloppo at gmail.com
Tue Feb 19 14:04:36 EST 2008


Alan,

thanks for the help. You are right that your approach works without
debug/optimized. Unfortunately, even though

TARGET_LINK_LIBRARIES(blendmaterials fem)

works, this doesn't (in a debug build tree):

TARGET_LINK_LIBRARIES(blendmaterials femd)

The former is also incorrect for a debug build tree, because libfem.a
is not even built in that tree.

I suspect this has to do with my (inproper?) use of
CMAKE_DEBUG_POSTFIX. I'll try to set up a hello world cmake file,
thanks for the suggestion!

--nico

On Feb 19, 2008 1:23 PM, Alan W. Irwin <irwin at beluga.phys.uvic.ca> wrote:
>
> On 2008-02-19 11:38-0500 Nico Galoppo wrote:
>
> > Hi,
> >
> > I'm trying to get a 'demo' program inside my project tree to link in
> > (and depend on) one of the built libraries from the same project tree.
> > I'm having trouble getting the build process for the demo app to
> > detect updates of the library. I've tried ADD_DEPENDENCIES() but to no
> > avail. This is what the tree looks like (partially)
> >
> > fem/
> > -fem/
> > --src/
> > --include/
> > -fem_io/
> > --src/
> > --include
> > -demos/
> > --blendmaterials/
> > ---src/
> >
> > In toplevel fem/CMakeLists.txt
> > PROJECT(fem)
> > ...
> > SET(CMAKE_DEBUG_POSTFIX "d")
> > SET(FEM_LIBS fem)
> > SET(FEM_LIBS_DEBUG femd)
> >
> > In fem/fem/CMakeLists.txt
> > ...
> > ADD_LIBRARY(fem ${FEM_LIBRARY_SOURCES} ${FEM_LIBRARY_HEADERS})
> >
> > In fem/demos/blendmaterials/src/CMakeLists.txt:
> > ...
> > ADD_EXECUTABLE(blendmaterials ${sources} ${headers})
> > ADD_DEPENDENCIES(blendmaterials fem fem_io)
> > TARGET_LINK_LIBRARIES(blendmaterials optimized ${FEM_LIBS} debug
> > ${FEM_LIBS_DEBUG})
>
> Your ADD_DEPENDENCIES is inconsistent for the debug case.  I suggest you
> just drop it.  Also, try experimenting with a simpler example without
> optimized or debug, e.g.,
>
> TARGET_LINK_LIBRARIES(blendmaterials ${FEM_LIBS})
>
> In my experience, that (without the ADD_DEPENDENCIES) should just work.  If
> you still have problems, then I would reduce it down to a really simple
> "hello-world" complete CMake test case that others here can try.  It's
> amazing how often I have prepared one of those for the CMake list to
> illustrate a point only to find that the really simple example worked, and
> the problem in the more complicated code was something else entirely such as
> a mispelled variable or scope problem. BTW, liberal use of MESSAGE is a good
> way to debug such problems which are often tough to spot by eyeballing the
> CMake code.
>
> Alan
> __________________________
> Alan W. Irwin
>
> Astronomical research affiliation with Department of Physics and Astronomy,
> University of Victoria (astrowww.phys.uvic.ca).
>
> Programming affiliations with the FreeEOS equation-of-state implementation
> for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
> package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
> Linux Links project (loll.sf.net); and the Linux Brochure Project
> (lbproject.sf.net).
> __________________________
>
> Linux-powered Science
> __________________________
>



-- 
Nico Galoppo :: http://www.ngaloppo.org


More information about the CMake mailing list