<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 7, 2019 at 9:32 PM Setzer Sebastian (CM-CI2/ECS2) via CMake <<a href="mailto:cmake@cmake.org">cmake@cmake.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Dear list,<br>
The manual says:<br>
<a href="https://cmake.org/cmake/help/latest/command/add_custom_target.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/latest/command/add_custom_target.html</a><br>
Reference files and outputs of custom commands created with add_custom_command() command calls in the same directory (CMakeLists.txt file). They will be brought up to date when the target is built.<br>
Use the add_dependencies() command to add dependencies on other targets.<br>
<br>
This is different from what the manual of add_custom_command says, and would be surprising for all users who only read the manual of add_custom_command and then think they know what the parameter means for add_custom_target.<br>
<br>
But on the other hand, when I test with this:<br>
--------------------------------------------------<br>
cmake_minimum_required (VERSION 3.14)<br>
project(dependency_test LANGUAGES)<br>
<br>
add_custom_target(T1<br>
                  COMMAND echo T1<br>
                  )<br>
add_custom_target(T2<br>
                  COMMAND echo T2<br>
                  DEPENDS T1<br>
                  )<br>
<br>
# cmake -GNinja -B build .<br>
# ninja T2<br>
--------------------------------------------------<br>
Then T1 and T2 are built, so contrary to what the manual says, it seems to work.<br>
<br>
Is the manual just outdated (Maybe behavior has changed and only manual for add_custom_command has been updated)?<br>
Should it be the same as for add_custom_command, or are there really some differences?<br></blockquote></div><div><br></div><div>As it happens, I just updated the docs for these in the last day or so. You can find it in the not-yet-merged merge request here:</div><div><br></div><div><a href="https://gitlab.kitware.com/cmake/cmake/merge_requests/3891">https://gitlab.kitware.com/cmake/cmake/merge_requests/3891</a><br></div><div><br></div><div>I wrote an explanation of the specific behavior of the dependencies in the associated issue here:</div><div><br></div><div><a href="https://gitlab.kitware.com/cmake/cmake/issues/19771#note_635547">https://gitlab.kitware.com/cmake/cmake/issues/19771#note_635547</a><br></div><div><br></div><div>There is a difference between the two, but it's subtle and specific to the sort of scenario I mentioned in that issue comment.</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div><div>Consulting services (CMake, C++, build/release processes): <a href="https://crascit.com/services" target="_blank">https://crascit.com/services</a></div></div></div></div></div></div></div></div></div></div></div></div>