[CMake] working with, and installing, data files

Michael Wild themiwi at gmail.com
Fri Nov 6 07:01:43 EST 2009


On 6. Nov, 2009, at 11:07 , Crni Gorac wrote:

> I'm using CMake as build system for a program that is in turn reading
> some data files in run-time.  Obviously, program has to be able to
> find data files both when installed, and when I'm developing it (and
> I'd like to skip having to do "make install" each time when I change
> data files while doing the development).  I looked into how some other
> CMake based projects (CMake included) are handling this, but still I'd
> appreciate any kind of advice on how to do it "properly".  At the
> moment, I'm thinking about having an environment variable to point to
> data directory, that I could define during the development to point to
> the data directory in my source tree.  If that variable not defined,
> then the program would check pre-defined data directory location, that
> would be #define-d in compile time, so that correct path could be put
> there with regards to the installation prefix; any suggestions for
> better arrangement here? If I understood it properly, CMake is doing
> something similar itself...
>
> Thanks.


That's how I do it, and it works fine for me. Another possibility  
would be to search relative to the executable location and ensure that  
the data files get configured into the build tree such that they have  
the same relative path. This could be also useful for software which  
get's installed into a "sandbox", i.e. everything goes into the same  
folder (as e.g. eclipse does it). This way the user can move that  
folder around without breaking the software.


Michael


More information about the CMake mailing list