<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>body{font-family:Helvetica,Arial;font-size:13px}</style>
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
Installing arbitrary files is accomplished by adding install commands into your CMakeLists. The documentation for the command is here:
<a href="https://cmake.org/cmake/help/v3.3/command/install.html">https://cmake.org/cmake/help/v3.3/command/install.html</a></div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
<br>
</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
For something like an init script or systemd unit file they are going to live outside the normal installation prefix. So you will need to do something like the following:</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
<br>
</div>
<div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier">if (IS_DIRECTORY /usr/lib/systemd/system)</font></div>
<div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier">    install(FILES myprog.service DESTINATION /usr/lib/systemd/system)</font></div>
<div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier">else()</font></div>
<div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier">    install(FILES myprog DESTINATION /etc/init.d)</font></div>
<div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier">endif()</font></div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
<br>
</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
That code block will install the myprog.service file into /usr/lib/systemd/system if that directory exists and if not will install the myprog file (init script) int /etc/init.d</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
<br>
</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
I have found that checking if the usual systemd directory exists is sufficient to determine that systemd is present on the build system. If you are compiling on one debian version but want to support multiple versions then you will most likely install your
 init script and systemd files into some place specific to your application and use a post install script to detect which version should get installed. This will however bypass the package manager for installing these and thus if the package is removed/altered
 dpkg wont handle anything for you regarding these files.</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
<br>
</div>
<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
Check out the CpackDeb documentation for all the various variables that can be set to alter how the package builds and installs: <a href="https://cmake.org/cmake/help/v3.3/module/CPackDeb.html">https://cmake.org/cmake/help/v3.3/module/CPackDeb.html</a></div>
<div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><span style="font-family: Helvetica, Arial; font-size: 13px;">In particular if you need to have postinstall scripts then you will want to set the variable</span><font face="Helvetica"><span style="font-size: 12px;"> CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA</span></font></div>
<div id="bloop_sign_1447336080870376192" class="bloop_sign">
<div style="font-family:helvetica,arial;font-size:13px">-- <br>
Matt Keeler<br>
</div>
</div>
<br>
<p class="airmail_on">On November 12, 2015 at 07:37:14, Šimon Tóth (<a href="mailto:toth@fi.muni.cz">toth@fi.muni.cz</a>) wrote:</p>
<blockquote type="cite" class="clean_bq"><span>
<div>
<div></div>
<div>I have managed to port my SW to CMake fine, but now I'm running into <br>
issues with the CPack package generation (debian packages for now). <br>
<br>
I'm using the "dh_xxxx" commands in the package generation for debian. <br>
What would be the equivalent in CMake? In particular, installing cron <br>
scripts, init.d scripts and systemd service files. <br>
<br>
Also is there a way to detect the presence systemd (and install systemd <br>
service file if this is the case, init.d script otherwise)? <br>
<br>
-- <br>
RNDr. Šimon Tóth <br>
FI@MU (toth@fi.muni.cz) | CESNET (simon@cesnet.cz) <br>
-- <br>
<br>
Powered by www.kitware.com <br>
<br>
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
<br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
<br>
<br>
CMake Support: http://cmake.org/cmake/help/support.html <br>
CMake Consulting: http://cmake.org/cmake/help/consulting.html <br>
CMake Training Courses: http://cmake.org/cmake/help/training.html <br>
<br>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
<br>
<br>
Follow this link to subscribe/unsubscribe: <br>
http://public.kitware.com/mailman/listinfo/cmake <br>
</div>
</div>
</span></blockquote>
</body>
</html>