Reputation: 133
i have a project which consists of several files like the binary, config files, start stop script, etc.
here's a simplified directory structure
/etc/configfile
/etc/xgd/autostart/runfile.Desktop
/usr/local/sbin/startscript
/usr/local/bin/binaryfile
/usr/local/share/project/main.glade
/usr/local/share/project/button.png
a runscript will be configured using
configure_file(conf/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
and installed using
#copy sbin files
file(GLOB SBINFILES ${CMAKE_CURRENT_BINARY_DIR}/${SBINDIR}/*.sh)
# install scripts
install(FILES ${SBINFILES}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${SBINDIR}
COMPONENT binary)
and it contains following text
#!/bin/bash
# ###############################################
# runscript for my program
# date: 2018/05/21
# ###############################################
export G_MESSAGES_DEBUG=all
export LOGFILE=~/.logfile.log
pushd ${BINDIR}
${BINDIR}/${PROJECTNAME} 1>> $LOGFILE 2>> $LOGFILE
popd
well, this works as long as i try to install to /usr/local/share but when I install using
make DESTDIR=./dist install
there's still /usr/local/bin/binaryfile configured which is logical but not what i want..
Is there any way to add a that destdir to cmake configuration?
Upvotes: 1
Views: 300
Reputation: 66288
DESTDIR
cannot be addeed to CMake configuration, because it isn't known on that stage: the variable is known only at install step.
Scripts (and executables) provided by the project may be ready for installation with
make DESTDIR=<...> install
by using relative paths to other components:
# From /usr/local/sbin/startscript execute /usr/local/bin/binaryfile.
../bin/binaryfile 1>> $LOGFILE 2>> $LOGFILE
When it is needed, relative paths can be transformed to absolute using readlink
:
# From /usr/local/sbin/startscript execute /usr/local/bin/binaryfile
# using its absolute path
BINDIR=`readlink -f ../bin/`
pushd ${BINDIR}
${BINDIR}/${PROJECTNAME} 1>> $LOGFILE 2>> $LOGFILE
popd
Upvotes: 1