<div dir="ltr"><div>Hi Antal,</div><div><br></div><div>Thank you for your feedback. I finally discovered the cmake variable equivalent for 
DESTDIR which is CMAKE_STAGING_PREFIX.</div><div>So:</div><div><br></div><div><span style="font-family:monospace">set(EXEC_PREFIX "/usr")</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">set(SYSLOG_NG_CMAKE_ARGS<br>    ${CCACHE_LAUNCH_RULE}<br>    -DCMAKE_INSTALL_PREFIX=${EXEC_PREFIX}<br>    -DCMAKE_STAGING_PREFIX=${SYSLOG_NG_INSTALL_DIR}<br>    )</span></div><div><br></div><div>And then use this CMAKE_ARGS in the External project.</div><div><br></div><div>Now I running into another issue:</div><div><br></div><div><span style="font-family:monospace"><b>root@5526d87140af:/thanos/src/target/build# cat /thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CMakeError.log<br>Determining size of struct cmsgcred failed with the following output:<br>Change Dir: /thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CMakeTmp<br><br>Run Build Command:"/usr/bin/make" "cmTC_05392/fast"<br>make[3]: Entering directory '/thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CMakeTmp'<br>/usr/bin/make -f CMakeFiles/cmTC_05392.dir/build.make CMakeFiles/cmTC_05392.dir/build<br>make[4]: Entering directory '/thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CMakeTmp'<br>Building C object CMakeFiles/cmTC_05392.dir/STRUCT_CMSGCRED.c.o<br>/usr/bin/cc  -D_GNU_SOURCE=1  -fPIE   -o CMakeFiles/cmTC_05392.dir/STRUCT_CMSGCRED.c.o   -c /thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c<br>/thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:19:22: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'<br> #define SIZE (sizeof(struct cmsgcred))<br>                      ^<br>/thanos/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:21:12: note: in expansion of macro 'SIZE'<br>   ('0' + ((SIZE / 10000)%10)),<br>            ^~~~<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:19:22: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'<br> #define SIZE (sizeof(struct cmsgcred))<br>                      ^<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:22:12: note: in expansion of macro 'SIZE'<br>   ('0' + ((SIZE / 1000)%10)),<br>            ^~~~<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:19:22: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'<br> #define SIZE (sizeof(struct cmsgcred))<br>                      ^<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:23:12: note: in expansion of macro 'SIZE'<br>   ('0' + ((SIZE / 100)%10)),<br>            ^~~~<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:19:22: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'<br> #define SIZE (sizeof(struct cmsgcred))<br>                      ^<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:24:12: note: in expansion of macro 'SIZE'<br>   ('0' + ((SIZE / 10)%10)),<br>            ^~~~<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:19:22: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'<br> #define SIZE (sizeof(struct cmsgcred))<br>                      ^<br>/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CheckTypeSize/STRUCT_CMSGCRED.c:25:12: note: in expansion of macro 'SIZE'<br>   ('0' +  (SIZE    % 10)),<br>            ^~~~<br>CMakeFiles/cmTC_05392.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_05392.dir/STRUCT_CMSGCRED.c.o' failed<br>make[4]: *** [CMakeFiles/cmTC_05392.dir/STRUCT_CMSGCRED.c.o] Error 1<br>make[4]: Leaving directory '/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CMakeTmp'<br>Makefile:126: recipe for target 'cmTC_05392/fast' failed<br>make[3]: *** [cmTC_05392/fast] Error 2<br>make[3]: Leaving directory '/home/src/target/build_sim_cc_x86_64/syslog-ng-ext/src/syslog-ng-ext-build/CMakeFiles/CMakeTmp'</b></span></div><div><br></div><div><br></div><div>It seems something related with the definition of __linux__ and __FreeBSD__.</div><div><br></div><div>Can you help me?</div><div><br></div><div>Thanks in advance,</div><div>Alex<br></div><div><br>

</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 5, 2019 at 7:43 AM Antal Nemes (anemes) <<a href="mailto:Antal.Nemes@oneidentity.com">Antal.Nemes@oneidentity.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
 Hi Alex,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
There are two concepts: CMAKE_INSTALL_PREFIX and DESTDIR, that I think you need to apply now.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
As a refresher, here is my understanding. CMAKE_INSTALL_PREFIX must be set to the directory, where the artifacts should reside in the custom os. That is most probably "/usr". That should set the the RPATH correctly.<br>
</div>
<br>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
However, from packaging point of view, this causes a little trouble. Because when someone calls make install, the artifacts will be installed to CMAKE_INSTALL_PREFIX, merging the new files with the build OS files. And from that it is very hard to collect the
 artifacts properly.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
That is what DESTDIR is intended to resolve. Instead of calling make install, one needs to call make DESTDIR=<abs path to artifact directory> install. That will create the same structure that would have been created in CMAKE_INSTALL_PREFIX, just in $DESTDIR/$CMAKE_INSTALL_PREFIX.
 From that you can call targz or anything on the directory to collect the artifacts.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
For example: after</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_JAVA=no</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
$ make -j</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
$ <span>mkdir /tmp/result<br>
</span><span></span>$ make DESTDIR=/tmp/result install</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
created a /tmp/result/usr/sbin/syslog-ng etc files, but with RPATH:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>$ objdump -x /tmp/result/usr/sbin/syslog-ng |grep RPATH<br>
</span>
<div>  RPATH                /usr/lib<br>
</div>
<span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
as expected.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am afraid I do not know how to translate these into ExternalProject_add though.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Br,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
  Antal<br>
</div>
<div id="gmail-m_2540456560771610007appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_2540456560771610007divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> syslog-ng <<a href="mailto:syslog-ng-bounces@lists.balabit.hu" target="_blank">syslog-ng-bounces@lists.balabit.hu</a>> on behalf of Alexandre Santos <<a href="mailto:alexandre.rosas.santos@gmail.com" target="_blank">alexandre.rosas.santos@gmail.com</a>><br>
<b>Sent:</b> Monday, November 4, 2019 19:40<br>
<b>To:</b> <a href="mailto:syslog-ng@lists.balabit.hu" target="_blank">syslog-ng@lists.balabit.hu</a> <<a href="mailto:syslog-ng@lists.balabit.hu" target="_blank">syslog-ng@lists.balabit.hu</a>><br>
<b>Subject:</b> [syslog-ng] Building syslog with cmake as external project</font>
<div> </div>
</div>
<div>
<div style="background-color:rgb(255,235,156);width:100%;border-style:solid;border-color:rgb(156,101,0);border-width:1pt;padding:2pt;font-size:10pt;line-height:12pt;font-family:"Calibri";color:black;text-align:left">
<span style="color:rgb(156,101,0);font-weight:bold">CAUTION:</span> This email originated from outside of the organization. Do not follow guidance, click links, or open attachments unless you recognize the sender and know the content is safe.</div>
<br>
<div>
<div dir="ltr">
<div><font size="2">Hi All,</font></div>
<div><font size="2"><br>
</font></div>
<div><font size="2">I am trying to build syslog-ng with cmake to add it to a custom Linux distribution.</font></div>
<div><font size="2"><br>
</font></div>
<div><font size="2">The problem is that when the syslog-ng is compiled it gets the RPATH of the location where it has been generated:
<br>
</font></div>
<div><font size="2"><br>
</font></div>
<div><b><font size="2"><span style="font-family:monospace">root@5526d87140af:/home/src/</span></font></b><b><font size="2"><span style="font-family:monospace">chassisx/build# ldd syslog-ng-install/sbin/syslog-</span></font></b><b><font size="2"><span style="font-family:monospace">ng<br>
        linux-vdso.so.1 (0x00007fff151ed000)<br>
        libsyslog-ng.so.3.24.1 =><span style="color:rgb(255,0,0)"> /home/src/target/build/</span></span></font></b><span style="color:rgb(255,0,0)"><b><font size="2"><span style="font-family:monospace">syslog-ng-install/lib/</span></font></b></span><b><font size="2"><span style="font-family:monospace"><span style="color:rgb(255,0,0)">libsyslog-ng.so.3.24.1
</span>(0x00007f81baf89000)<br>
        libeventlog.so => <span style="color:rgb(255,0,0)">/home/src/target/build/</span></span></font></b><span style="color:rgb(255,0,0)"><b><font size="2"><span style="font-family:monospace">syslog-ng-install/lib/</span></font></b></span><b><font size="2"><span style="font-family:monospace"><span style="color:rgb(255,0,0)">libeventlog.so</span>
 (0x00007f81bad84000)<br>
        libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/</span></font></b><b><font size="2"><span style="font-family:monospace">libgmodule-2.0.so.0 (0x00007f81bab80000)<br>
        libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/</span></font></b><b><font size="2"><span style="font-family:monospace">libgthread-2.0.so.0 (0x00007f81ba97e000)<br>
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-</span></font></b><b><font size="2"><span style="font-family:monospace">2.0.so.0 (0x00007f81ba66a000)<br>
        libivykis.so.0 => <span style="color:rgb(255,0,0)">/home/src/target/build/</span></span></font></b><span style="color:rgb(255,0,0)"><b><font size="2"><span style="font-family:monospace">syslog-ng-install/lib/</span></font></b></span><b><font size="2"><span style="font-family:monospace"><span style="color:rgb(255,0,0)">libivykis.so.0</span>
 (0x00007f81ba45b000)<br>
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.</span></font></b><b><font size="2"><span style="font-family:monospace">so.3 (0x00007f81ba1e8000)<br>
        libresolv.so.2 => /lib/x86_64-linux-gnu/</span></font></b><b><font size="2"><span style="font-family:monospace">libresolv.so.2 (0x00007f81b9fd1000)<br>
        libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/</span></font></b><b><font size="2"><span style="font-family:monospace">libssl.so.1.1 (0x00007f81b9d65000)<br>
        libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/</span></font></b><b><font size="2"><span style="font-family:monospace">libcrypto.so.1.1 (0x00007f81b98cc000)<br>
        libsecret-storage.so => <span style="color:rgb(255,0,0)">/home/src/target/build/</span></span></font></b><span style="color:rgb(255,0,0)"><b><font size="2"><span style="font-family:monospace">syslog-ng-install/lib/</span></font></b></span><b><font size="2"><span style="font-family:monospace"><span style="color:rgb(255,0,0)">libsecret-storage.so
</span>(0x00007f81b96c8000)<br>
        libpthread.so.0 => /lib/x86_64-linux-gnu/</span></font></b><b><font size="2"><span style="font-family:monospace">libpthread.so.0 (0x00007f81b94ab000)<br>
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.</span></font></b><b><font size="2"><span style="font-family:monospace">6 (0x00007f81b910c000)<br>
        /lib64/ld-linux-x86-64.so.2 (0x00007f81bb48e000)<br>
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.</span></font></b><b><font size="2"><span style="font-family:monospace">so.2 (0x00007f81b8f08000)</span></font></b></div>
<div><span style="font-family:monospace"></span></div>
<br>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2">I am using the cmake file in attachment.</font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2"></font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2"><br>
</font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2">Can you help me?</font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2">Thanks in advance,</font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2"><br>
</font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2">Alex<br>
</font></font></span></div>
<div><span style="font-family:monospace"><font face="arial,sans-serif"><font size="2"><br>
</font></font></span></div>
</div>
</div>
</div>
</div>

______________________________________________________________________________<br>
Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a><br>
Documentation: <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support/documentation/?product=syslog-ng</a><br>
FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/syslog-ng-faq</a><br>
<br>
</blockquote></div>