LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Best practice for data files using CMake (https://www.linuxquestions.org/questions/programming-9/best-practice-for-data-files-using-cmake-717344/)

damien_d 04-07-2009 01:01 AM

Best practice for data files using CMake
 
Hello,

I am currently writing a few libraries, some of which have some data files (e.g. a large file containing coefficients for a calculation).

The libraries require the data files in order to work - they are useless without them. At the moment, I am doing something very, very dirty, like:

Code:

#define DATA_FILE_PATH "~/code/EGM96/trunk/input.dat"
Which is so wrong on so many levels.

I am using cmake (and am very new to it) as the build system and would like to know the best practice for data files, and even arrangements for outputting binaries from the build process.

The code is laid out like
Code:

~/code
~/code/library1
~/code/library2
~/code/ProgramRelyingOnAboveLibrariesAndDataFiles

Eventually, I'd like to be able to do "make install" to place them in a nice install location.

Completely open to suggestions.

Damien.

dwhitney67 04-08-2009 10:06 AM

How about placing your config (data) file in /usr/shared/[YourAppName], where [YourAppName] is whatever your application is called.

I have not used Cmake, however there should be a way to install files (whether binary or data) using /usr/bin/install. I use this utility with my Makefiles for the "install:" entry point.

For example:
Code:

APP=MyApp
DEST=/usr/share/$(APP)

...

install:
        @if [ ! -d $(DEST) ]; then \
                mkdir -p $(DEST); \
        fi
        @install -m 444 $(DATAFILES) $(DEST)

...



All times are GMT -5. The time now is 12:04 AM.