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.
The problem is that sometimes, myapp is built and linked *before* mylib is
actually built.
The net result is that myapp build step fails, as libmylib.a does not exist yet.
It seems to occur when multiple make jobs are run (make -j 3 ...)
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.
Is there a better way to solve this issue?
Thanks,
Manu
_______________________________________________
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