Am Montag, 30. September 2013, 12:58:40 schrieb Jakub Schmidtke: > Hi, > > I am trying to get dependencies right in a project that uses auto-generated > sources. > I have a library, that uses auto-generated files, and other executables > that use that library. > I created a set of CMakeLists.txt files that show the problem. > > To run it you need test.c and org.c in the source directory, and one of > them should contain int main(void) { return 0; } in it, > the other can be empty. First try - the simplest approach: > > project(Test) > > add_custom_command(OUTPUT file.c > COMMAND echo "GENERATING FILE" > COMMAND rm -f file.c > COMMAND cp -i ${CMAKE_CURRENT_SOURCE_DIR}/org.c file.c > DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.c > ) > add_library(LibFile file.c) > > add_executable(test1 test.c) > target_link_libraries(test1 LibFile) > > add_executable(test2 test.c) > target_link_libraries(test2 LibFile) > > When I build it with 'make' it builds just fine. > However, if (from the build/) directory I run: touch ../org.c; make -j > test1 test2 it sometimes gives me this: > > [ 25%] [ 25%] Generating file.c > Generating file.c > GENERATING FILE > GENERATING FILE > cp: overwrite ‘file.c’? [ 25%] [ 25%] Built target gen_file > Built target gen_file
What a coincidence ;) I recently updated my CMake sources. I decided to do a partial rebuild as the executables themselves were in use and I wanted to avoid any hassle. So I typed make -j 10 CMakeLib CPackLib CTestLib And that resulted in basically the same problem: make tried to link CMakeLib three times in parallel, obviously failing. So the problem here is not limited to generated files I think. Eike -- 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://www.cmake.org/mailman/listinfo/cmake