Dear CMake Gurus,
This is a little convoluted and long, but I’m hoping it’s possible in CMake…with as little change to source code as possible!
To wit, I work on a earth science model and one of the goals with our recent conversion to CMake is to make things “user portable” for the users. What I mean is that userA can build/install the model, and then userB can go to userA’s installation and run an experiment with that install.
Most of this is working, but I’m getting stuck on a new wrinkle. I was mainly focusing on running the model, etc. but there are postprocessing steps I often miss. What we did in old GNU Make days is during a model run when it’s time to make plots, the user ran a script in our (simplified for here) src/plots/
directory, src/plots/configure
which set up a bunch of symlinks in the source tree so the plotting package was happy. Of course, this meant only the user that built the experiment could run this because of directory permissions. But, with some ugly GNU Make, I was able to figure out how to run that script at make install
time so the symlinks got created.
Now, in CMake land, we have a rule that after installation, no script can ever refer back to the source directory. So, users now during postprocessing run install/plots/configure
instead (we didn’t install it to install/bin
as we wanted to keep all the plotting/postprocessing separate for various reasons). And like before, if userA built the model and userA runs install/plots/configure
all is well as userA has permission to write to install/plots
. But userB has an issue doing so.
So, what I’d like to do is:
- Install/copy
configure
toinstall/plots
- After copying, run
install/plots/configure
to set up the symlinks ininstall/plots
The first step we are doing with the usual:
install (
PROGRAMS configure
DESTINATION plots
)
as it’s just “copy this to there”.
It’s that second step I’m having trouble with. The script has to be run from the install/plots
directory because that’s where the symlinks need to be. Making it even more difficult is that an environment variable needs to be set (essentially to the full path of install
) because configure
is a shell script.
I’ve tried various things (making a custom target, ugly add_custom_command()
), but I seem to be failing at this…
Thanks,
Matt