<div dir="ltr">The workaround I found so far is to add a custom target that depends on the targets I want to build.<div>So if I add this:</div><div><div>add_custom_target(test12 DEPENDS test1 test2)</div></div><div><br></div>
<div>to my CMake file, and instead of running 'make -j test1 test2' I run 'make -j test12' everything seems to be fine...</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Mon, Sep 30, 2013 at 1:07 PM, Rolf Eike Beer <span dir="ltr"><<a href="mailto:eike@sf-mail.de" target="_blank">eike@sf-mail.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Am Montag, 30. September 2013, 12:58:40 schrieb Jakub Schmidtke:<br>
<div><div class="h5">> Hi,<br>
><br>
> I am trying to get dependencies right in a project that uses auto-generated<br>
> sources.<br>
> I have a library, that uses auto-generated files, and other executables<br>
> that use that library.<br>
> I created a set of CMakeLists.txt files that show the problem.<br>
><br>
> To run it you need test.c and org.c in the source directory, and one of<br>
> them should contain int main(void) { return 0; } in it,<br>
> the other can be empty. First try - the simplest approach:<br>
><br>
> project(Test)<br>
><br>
> add_custom_command(OUTPUT file.c<br>
> COMMAND echo "GENERATING FILE"<br>
> COMMAND rm -f file.c<br>
> COMMAND cp -i ${CMAKE_CURRENT_SOURCE_DIR}/org.c file.c<br>
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.c<br>
> )<br>
> add_library(LibFile file.c)<br>
><br>
> add_executable(test1 test.c)<br>
> target_link_libraries(test1 LibFile)<br>
><br>
> add_executable(test2 test.c)<br>
> target_link_libraries(test2 LibFile)<br>
><br>
> When I build it with 'make' it builds just fine.<br>
> However, if (from the build/) directory I run: touch ../org.c; make -j<br>
> test1 test2 it sometimes gives me this:<br>
><br>
> [ 25%] [ 25%] Generating file.c<br>
> Generating file.c<br>
> GENERATING FILE<br>
> GENERATING FILE<br>
> cp: overwrite ‘file.c’? [ 25%] [ 25%] Built target gen_file<br>
> Built target gen_file<br>
<br>
</div></div>What a coincidence ;) I recently updated my CMake sources. I decided to do a<br>
partial rebuild as the executables themselves were in use and I wanted to<br>
avoid any hassle. So I typed<br>
<br>
make -j 10 CMakeLib CPackLib CTestLib<br>
<br>
And that resulted in basically the same problem: make tried to link CMakeLib<br>
three times in parallel, obviously failing. So the problem here is not limited<br>
to generated files I think.<br>
<br>
Eike<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a></blockquote></div><br></div>