dependencies - CMake: Depending on another project -
i quite new cmake , want achieve "common" task it. until now, used eclipse cdt auto generated makefiles. suppose have 2 projects , b. builds static library , b needs library. of course, when building b, want ensure static library built up-to-date. thus, building of project b should trigger building of if changes made in sources of a. default behaviour of eclipse when inserting dependency of b.
so, easiest way achieve cmake? have read tutorials , similar questions, none gave me satisfying answer.
for example, there http://www.cmake.org/wiki/cmake/tutorials/exporting_and_importing_targets tutorial solution. however, seems quite complex such easy task. have "install" targets of a, not want install anything, want b depend on a. next, heard externalproject_add don't know how handle either.
if you're building them same cmakelists file, specifying linkage using target name enough:
add_library(librarya ${a_sources} target_link_libraries(librarya <any libraries depends on>) add_executable(programb) target_link_libraries(programb librarya <plus other libraries>)
if they're not in same cmakelists file, either include build using add_subdirectory(), (a child of b), or build them both same top-level file using add_subdirectory() each 1 (a , b siblings).