*folder* CMakeLists.txt: project(root) add_subdirectory(proj_b) add_subdirectory(proj_c) add_subdirectory(proj_a)
*folder/proj_a* CMakeList.txt: project(proj_a) add_executable(*main *main.cpp) target_link_libraries(*main **proj_b* *proj_c*) *folder/proj_b* CMakeList.txt: project(proj_b) add_library(*proj_b* proj_b.cpp) *folder/proj_c* CMakeList.txt: project(proj_c) add_library(*proj_c *proj_b.cpp) 17.04.2016 11:31, vakano пишет:
Hi, The project structure as below: folder/proj_a folder/proj_b folder/proj_c proj_a, proj_b, proj_c are in the same level, proj_a is the main project use to generate executable main, proj_b and proj_c use to generate lib_b, lib_c, then link with executable main, my question is how to add the dependency to let the lib_b and lib_c compile before executable main, I have tried the function, add_dependencies(main lib_b lib_c) and target_link_libraries(main lib_b lib_c), but did not work, what I want is to achieve the make file dependency setting like: "${MAKE}" -f Makefile-${CND_CONF}.mk main main: lib_b, lib_c Any suggestion will be highly appreciated! BTW, as checked from another topic, I use different project name in cmakelist( project(proj_a), project(proj_b), project(proj_c) ), does it block the dependency generation automatically? Thanks, Le -- View this message in context: http://cmake.3232098.n2.nabble.com/How-to-add-dependency-relations-between-libs-and-executable-tp7593264.html Sent from the CMake mailing list archive at Nabble.com.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake