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.
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. HTH, Mike > On Jan 21, 2017, at 4:01 PM, doug livesey <biot...@gmail.com> wrote: > > Hi, I want to call the following command as part of a build: > > $ ./node_modules/.bin/webpack > > This should generate a file public/bundle.js > > 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. > I would anticipate that it would put the command I want to call in the > makefile, but it hasn't. > If anyone could advise me on what I'm not getting here, that would be > brilliant. > Cheers, > Doug. > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake