<div dir="ltr">Hi -- sorry about the really late reply, I've been away. Up to Hadrian's Wall, and then for a Dark Skies observatory evening.<div>It was ace. :)</div><div>I've added the following to my CMakeLists.txt file:</div><div><br></div><div>> set(WEBPACK ${CMAKE_SOURCE_DIR}/node_modules/.bin/webpack)</div><div><div>> configure_file(webpack.config.js webpack.config.js)</div><div>> add_custom_target(public/bundle.js)</div><div>> add_custom_command(OUTPUT public/bundle.js COMMAND ${WEBPACK})</div></div><div><br></div><div>However, when I try to run `cmake ..` (I'm using a build subdirectory), I get the following error:</div><div><br></div><div><div>> CMake Error at CMakeLists.txt:30 (add_custom_target):</div><div>>   add_custom_target called with invalid target name "public/bundle.js".</div><div>>   Target names may not contain a slash.  Use ADD_CUSTOM_COMMAND to generate</div><div>>   files.</div></div><div><br></div><div>I'm guessing that this means that I should be running some of those commands in a CMakeLists.txt file in a subdirectory (maybe public/) and calling `add_subdirectory(public)` from my top-level file?</div><div>I've tried this a couple of ways, but so far haven't got it working.</div><div>Am I on the right sort of approach, or have I wandered far from the beaten track?</div><div>Thanks again for your help,</div><div>   Doug.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 22 January 2017 at 00:16, Michael Ellery <span dir="ltr"><<a href="mailto:mellery451@gmail.com" target="_blank">mellery451@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">add_custom_command is the probably the right thing…but it needs to be triggered by a dependency relationship. You will specify public/bundle.js as the OUTPUT parameter of the add_custom_command and then some other target or install command needs to have that file listed in its sources, and then CMAKE will understand that it needs to run the custom command to generate that OUTPUT file before it runs the dependent target. I think add_custom_command can also be explicitly linked to a specific target (there are two forms of the command) - and in that case I think it always runs (?) when that target rebuilds…I’m not completely sure about that, so you might need to test.<br>
<br>
Alternatively, if you want to run the generation at the time of makefile generation (when CMAKE is run…), then have a look at execute_process. The downside of that is that it will generally always run when CMAKE is run, but never during the make process so it doesn’t really handle updates to the source (input) files very well. I’m not sure which technique applies best to your situation here.<br>
<br>
HTH,<br>
Mike<br>
<div><div class="h5"><br>
> On Jan 21, 2017, at 4:01 PM, doug livesey <<a href="mailto:biot023@gmail.com">biot023@gmail.com</a>> wrote:<br>
><br>
> Hi, I want to call the following command as part of a build:<br>
><br>
> $ ./node_modules/.bin/webpack<br>
><br>
> This should generate a file public/bundle.js<br>
><br>
> I'm really struggling with this. I guess there's something fundamental that I'm not understanding. `add_custom_command` doesn't seem to be doing anything.<br>
> I would anticipate that it would put the command I want to call in the makefile, but it hasn't.<br>
> If anyone could advise me on what I'm not getting here, that would be brilliant.<br>
> Cheers,<br>
>    Doug.<br>
</div></div>> --<br>
><br>
> Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>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" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br>
<br>
</blockquote></div><br></div>