<div dir="ltr">I moved the add_custom_target to the 4th line of my top-level CMakeLists.txt.  The only lines before it are cmake_minimum_required, project, and a single set.  I also made sure that the name of the target matches the target name in add_custom_command and add_dependencies.  I am still getting the same set of errors.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 6:00 PM, Mark Abraham <span dir="ltr"><<a href="mailto:mark.j.abraham@gmail.com" target="_blank">mark.j.abraham@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi,</p>
<p dir="ltr">CMakeLists.txt files are processed from start to finish, so if you want to refer to a target created in a subdirectory, then you need to have added that subdirectory before using that target.</p>
<p dir="ltr">Mark</p>
<div class="gmail_quote"><div><div class="h5">On 16/04/2015 1:25 am, "Daniel Dilts" <<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div class="h5"><div dir="ltr"><div>I have a function  that does something like this:</div><div><br></div><div>add_dependencies(${LibraryName} SomeTarget)<br>add_custom_command(TARGET SomeTarget PRE_BUILD<br>  COMMAND MyExecutable.exe<br>  USES_TERMINAL<br>  )</div><div><br></div><div>It creates the dependency without any issues, but it gives the following error on the custom command:</div><div><br></div><div>CMake Error at CMakeLists.txt:37 (add_custom_command):<br>  The target name "SomeTarget" is unknown in this context.</div><div><br></div><div>SomeTarget is created using add_library later in the build system.</div><div><br></div><div>Is there some way to make this work?  SomeTarget is created deeper in the build system (3-5 directories down).</div></div>
<br></div></div>--<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://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div>
</blockquote></div><br></div>