On 05.05.09 14:29:03, [email protected] wrote: > Hi, > > I have a question about CMake and dependency management when an executable is > built, and linked with static libraries which are built within the same > project. > > I use a top CMakeLists.txt which looks like: > PROJECT (proj) > SET (subprojects mylib myapp) > FOREACH (prj ${subprojects}) > ADD_SUBDIRECTORY (${prj} ${prj}) > ENDFOREACH (prj) > > mylib/ contains a CMakeList.txt file that contains something like > ADD_LIBRARY (mylib src/mylib.c) > > myapp/ contains a CMakeList.txt file that contains something like > ADD_EXECUTABLE (myapp src/myapp.c) > TARGET_LINK_LIBRARIES (myapp -L${PATH_TO_MYLIB} -Wl,--start-group -lmylib > -lsomeotherlib -Wl,--end-group) > > > I don't think I can use the FIND_LIBRARY command, because the actual link > command requires the start-group/end-group linker directives, and the actual > application is linked against several other libraries.
Ideally you wouldn't use linker flags, but just use the target you've created via add_library. But I guess that doesn't work with the start-group stuff. So... > There is no explicit dependencies between myapp and mylib, which I guess > explain why CMake allows myapp to be built before mylib is built. > > What would be the best way to add a dependency to solve this issue? > In other word, I'll go for ADD_DEPENDENCY(myapp x), but I'm not sure how to > define 'x' here. This would be the right way and "x" should simply be "mylib" in your example, which creates a dependency between the myapp target and the mylib target in your project. Andreas -- Just because the message may never be received does not mean it is not worth sending. _______________________________________________ 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
