LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2009, 01:01 AM   #1
damien_d
LQ Newbie
 
Registered: Dec 2008
Posts: 17

Rep: Reputation: 0
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.
 
Old 04-08-2009, 10:06 AM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
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)

...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cmake question yfaye Programming 3 04-09-2009 09:24 PM
PBuilder error after cmake Patrick793 Linux - Software 0 10-13-2008 05:11 PM
problem in mounting cdrom(audio files running but not reading data files) amit_usual Linux - Newbie 7 12-29-2007 05:52 AM
Shell programming: Question about source files and read data from the files ccwq Programming 3 08-05-2007 12:13 AM
Need some tar files to practice on AMDPwred Linux - General 7 01-16-2002 12:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration