The INSTALL(SCRIPT ...) syntax might be just the answer I need, thanks!. As I mentioned, the index creating script in the custom step needs to operate on the copied directory tree in its final location, so if it's not all there yet it will fail. So, if CMake has some distinction between "build" and "install" (I'm familiar with Makefiles, where the syntax enforces no such separation -- just targets, dependencies, and commands), then this would mean the step has to be executed at the end of the "install" phase.
Can I specify somehow that this install command must be executed after the INSTALL(DIRECTORY ...) command has completed? Thanks, CR On Mon, Jul 10, 2017 at 6:04 PM, Michael Ellery <mellery...@gmail.com> wrote: > > > On Jul 10, 2017, at 10:46 AM, Christopher E Robison < > cerobi...@utexas.edu> wrote: > > > > I've recently begun using CMake on an existing project I've taken over, > and I feel like I'm mostly getting used to it, though there is still a vast > amount to learn. I've got nearly the entire project building successfully, > with the exception of a directory of external scripts that need to be > configured at the end of the install process to create some index files. > > > > So, in a nutshell, there's a script that takes care of this post-install > configuration, that needs to be executed once the target tree of > directories and script files are in place, copied from the source tree. And > I'm finding that when the script is called during the build, the > INSTALL(DIRECTORY ...) command from the CMakeLists.txt directory hasn't > been run yet, so the tree of script files hasn't been put in place yet and > the script (and the build) fails. > > > > FWIW, if I leave out the add_custom_command and add_custom_target that > execute the script, the directory tree does copy correctly. > > > > I have not found any guidance on how to specify that the directory tree > gets copied first. How is this normally done? > > > > > > Thanks, > > CR > > > > > > > > I think you might be getting confused by two distinct phases: BUILD and > INSTALL. > > BUILD is what happens when building your sources and all the results of > this step are in your build directory (or source directory if you do > in-source building). Both add_custom_command and add_custom_target are > evaluated (and potentially executed) at BUILD time. The BUILD phase is > what is processed when you just do “make” in Makefile terms. > > INSTALL is what happens when you request your project to be installed. The > various install() directives in your CMake files will be processed during > INSTALL. In Makefile terms, this what happens when you do “make install” > (BUILD is also done in that case since INSTALL always depends on BUILD) > > So the first question is: does this custom step need to be done at BUILD > time or INSTALL time? Running custom code is easier at BUILD time since you > have the add_custom_command and the like. If you need to run custom code at > INSTALL time, maybe consider this: > > https://stackoverflow.com/questions/41254902/cmake-run- > script-for-install-target > > …although I have not done something like this myself. I suspect it is > difficult to get just right, depending on the various platforms you support. > > Does that make sense? > > -Mike > > > >
-- 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