On Thursday 11 November 2010, luxInteg wrote: > Greetings > > I am learning cmake. > > I think I now know how to generate libraries and executables but I have > not yet grasped how the tree and directory structure is handled and by > conseqence how one navigates therein. > > > I have this problem. Lets say my build tree has these directories > > L---$originalSourceTree/build/lib > M---$originalSourceTree/build/bin > > libraries say libA.so libB.a are in L. I want to generate executables > A.bin and B.bin in M but > they each need to link to newly generated libraries libA.so libB.a > > > a) how do I direct cmake (in the CMakeLists.txt/base directory) to build > the libraries in ( L )above first -i.e. before atempting to do finds of > nonexistant libraries ?
The add_library() commands must be before the add_executable() commands, otherwise the libraries "A" and "B" are not yet know when you do target_link_libraries(exe A B) Beside that, the dependencies in the generated makefiles are complete, so whenever you do a build, cmake makes sure that the libraries are up-to-date before it builds the executable. > b) if I insert lines such 'find_library(LIB libA path ../lib' in the > CmakeLists.txt in the base directory this results in an error so what > does one insert? find_library() is not necessary, you can simply use the names of the library targets when linking against them. > c) Further down the road, if the generated executables ae linked to > libraries in the build tree, what happens when one does a 'make install' to > the 'permanent' filesystem? Are the dependencies transfered? No, not really. You mean that the executables find the shared libs when starting ? This depends on the loader. You can adjust this via the RPATH-related target properties. Alex _______________________________________________ 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