<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 &#39;make -j test1 test2&#39; I run &#39;make -j test12&#39; 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">&lt;<a href="mailto:eike@sf-mail.de" target="_blank">eike@sf-mail.de</a>&gt;</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">&gt; Hi,<br>
&gt;<br>
&gt; I am trying to get dependencies right in a project that uses auto-generated<br>
&gt; sources.<br>
&gt; I have a library, that uses auto-generated files, and other executables<br>
&gt; that use that library.<br>
&gt; I created a set of CMakeLists.txt files that show the problem.<br>
&gt;<br>
&gt; To run it you need test.c and org.c in the source directory, and one of<br>
&gt; them should contain int main(void) { return 0; } in it,<br>
&gt; the other can be empty. First try - the simplest approach:<br>
&gt;<br>
&gt; project(Test)<br>
&gt;<br>
&gt; add_custom_command(OUTPUT file.c<br>
&gt;     COMMAND echo &quot;GENERATING FILE&quot;<br>
&gt;     COMMAND rm -f file.c<br>
&gt;     COMMAND cp -i ${CMAKE_CURRENT_SOURCE_DIR}/org.c file.c<br>
&gt;     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.c<br>
&gt;   )<br>
&gt; add_library(LibFile file.c)<br>
&gt;<br>
&gt; add_executable(test1 test.c)<br>
&gt; target_link_libraries(test1 LibFile)<br>
&gt;<br>
&gt; add_executable(test2 test.c)<br>
&gt; target_link_libraries(test2 LibFile)<br>
&gt;<br>
&gt; When I build it with &#39;make&#39; it builds just fine.<br>
&gt; However, if (from the build/) directory I run: touch ../org.c; make -j<br>
&gt; test1 test2 it sometimes gives me this:<br>
&gt;<br>
&gt; [ 25%] [ 25%] Generating file.c<br>
&gt; Generating file.c<br>
&gt; GENERATING FILE<br>
&gt; GENERATING FILE<br>
&gt; cp: overwrite ‘file.c’? [ 25%] [ 25%] Built target gen_file<br>
&gt; 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>