[CMake] directory traverse guidance
luxInteg
lux-integ at btconnect.com
Tue Jan 25 14:09:23 EST 2011
On Tuesday 25 January 2011 07:53:24 Andreas Pakulat wrote:
> On 25.01.11 02:57:27, luxInteg wrote:
> > Greetings
> >
> > I am learning cmake
> >
> > consider my project with two directories dir1 and dir2
> >
> > if I want to:-
> > move to dir1 and add a library libA in dir1
> > move to dir2 and add a library libB in dir2
> > move back to dir1 and add a test testA in dir1
> > move back to dir2 and add a test testB to dir2
> >
> >
> > (the moving back is because of the interdependencies of the tests with
> > the libraries i.e. testA reaquires libB etc))
> >
> > how do I do this?
>
> You don't. All you need is 2 CMakeLists.txt, one in dir1 with libA and
> testA targets and the other in dir2 with libB and testB targets. CMake
> as a declarative language (to a certain extent) does not depend on the
> order in which you declare targets and use them.
Before I made my posting, I tried a setup (as you suggested) but with more
than two directories -lets call this N
my extended setup had dir1 ......dirN
each with
add_library(someLIB ${sourceFiles(1...N)})
add_depedencies(someLIB someTEST)
then
add_test(someTEST someFILE(1...N).c )
target_link_libraries(someTEST
libA
libB
.....
libN )
and it failed siting some 'graph' dependency problem.
Basically I have to build a set of tests after building some static libraries
and some of these tests require linking to libraries that occur much later
in the build-scheme. {In other words libA.a might be built and testA (built
in the same directory as liba.A} but it requires linking not only to libA.a
but to the 'later-built' libN.a)
Guidance on how this is 'do-able' will be appreciaed.
sincerely
luxInteg.
More information about the CMake
mailing list