On 25.01.11 19:09:23, luxInteg wrote: > 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)
So your library depends on the test? This doesn't look like it makes much sense. Also cmake will already take care of dependencies via target_link_libraries. > then > add_test(someTEST someFILE(1...N).c ) This is actually not going to do anything useful, add_test expects an executable or the name of a target created by add_executable. > 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) As I said, this works just fine if you let cmake handle the dependencies via add_library+add_executable+add_test. If you still can't make it work, please try out the attached project and try to make it break by adding more targets, dependencies or source files and then post the resulting project. Andreas -- Learn to pause -- or nothing worthwhile can catch up to you.
cmdep.tar.gz
Description: Binary data
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake