<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.E-MailFormatvorlage19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hey guys,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">that was so far very helpful in understanding the problem in more depth.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Putting in the right flags at least reduced the linker errors by nearly 99% or so, Thanks.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Maybe I am on the right path now and just need to tweak it a bit to make it work.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">The rtems-cmake repository looks also very promising to me, I surely have to dig deeper into the processes going on there.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Problem is that I should (ideally) not change the CMakeLists.txt from the library so it stays independent.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Do you have any thoughts on that Robin?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Do you think wrapping the library CMakeLists.txt in another one which then uses the repository might work?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">But I realized that I have missed some information while explaining this issue.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">The RTEMS application itself is built with SCons and therefore the desired build environment (flags and so forth) is already defined within a python dictionary.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Now we need to somehow build the library via CMake using the established environment, install and link against it via SCons.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Do you have worked with something like this before?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Best regards<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">André<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b>Von:</b> devel <devel-bounces@rtems.org> <b>Im Auftrag von
</b>Robin Müller<br>
<b>Gesendet:</b> Dienstag, 20. Juli 2021 11:46<br>
<b>An:</b> Michael Davidsaver <mdavidsaver@gmail.com>; devel@rtems.org<br>
<b>Betreff:</b> Re: Building a library for use with RTEMS via CMake<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">I managed to compile our project with CMake, using this repository:
<a href="https://github.com/spacefisch/rtems-cmake">https://github.com/spacefisch/rtems-cmake</a>
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">It uses the pkg-config files to set up the cross compiler given the BSP and RTEMS prefix information.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Maybe this can help you<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Kind Regards<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Robin<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, 20 Jul 2021 at 00:50, Michael Davidsaver <<a href="mailto:mdavidsaver@gmail.com">mdavidsaver@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">On 7/19/21 6:17 AM, <a href="mailto:Andre.Nahrwold@dlr.de" target="_blank">
Andre.Nahrwold@dlr.de</a> wrote:<br>
> Hello,<br>
> <br>
> I have built RTEMS 5 and its tools for the Xilinx Zynq Zedboard and installed the BSP and tools at a certain position on my machine.<br>
> The tools are added to the PATH variable and RTEMS_BSPS is also available in the environment.<br>
> <br>
> Now we need to build a library for the use with RTEMS via CMake.<br>
> For this we wanted to use the toolchain files.<br>
> Does anybody know how to correctly setup such a toolchain file using the RTEMS compiler?<br>
> <br>
> We managed to get a toolchain file working which at least built the library.<br>
> But when we wanted to link to this library during compilation of a RTEMS application we got a bunch of errors due to undefined references to standard library functions.<br>
> Does anybody has a clue where this might origin from?<br>
<br>
As it happens, I went through this exercise recently with libevent.<br>
The main obstacle for me was that the CMake try_compile() command<br>
actually tries to link an executable. With RTEMS 5 this can't be<br>
done generically without also adding '-lrtemsdefaultconfig'.<br>
<br>
eg.<br>
<br>
> string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -lrtemsdefaultconfig")<br>
<br>
Also, if you use networking you might want to add.<br>
<br>
> set(CMAKE_REQUIRED_LIBRARIES "-lbsd")<br>
<br>
for eg. CheckFunctionExists.cmake to work correctly.<br>
<br>
<br>
The (fairly complex) result of this all can be found here:<br>
<br>
<a href="https://github.com/mdavidsaver/pvxs/tree/master/bundle" target="_blank">https://github.com/mdavidsaver/pvxs/tree/master/bundle</a><br>
<br>
The essential parts are:<br>
<br>
- <a href="mailto:cmake/RTEMS.cmake@">cmake/RTEMS.cmake@</a><br>
<br>
Template toolchain file. (expand using definitions from RTEMS makefiles)<br>
<br>
- cmake/Platform/<br>
<br>
Hooks into the CMake startup process. The exact interplay between<br>
Platform/ and toolchain file is... quite involved. Also not well<br>
documented. The best I've found is:<br>
<br>
<a href="https://github.com/Kitware/CMake/blob/f86d8009c6a4482c81221114a2b04b375564cc94/Source/cmGlobalGenerator.cxx#L461-L504" target="_blank">https://github.com/Kitware/CMake/blob/f86d8009c6a4482c81221114a2b04b375564cc94/Source/cmGlobalGenerator.cxx#L461-L504</a><br>
<br>
<br>
<br>
> Building a RTEMS application which does not use the own library works fine.<br>
> <br>
> Our toolchain file looks like this:<br>
> <br>
> # CMake toolchain file for ARM<br>
> # The compiler is based on<br>
> # The RTEMS_BSPS environment variable is expected to be set.<br>
> set(ARCH arm)<br>
> set(CMAKE_SYSTEM_NAME RTEMS5)<br>
> <br>
> set(CMAKE_CXX_FLAGS "" CACHE STRING "ARM RTEMS5 gcc additional compiler flags" FORCE)<br>
> <br>
> set(RTEMS_TOOLS_PATH $ENV{RTEMS_BSPS}/../../tools/bin)<br>
> <br>
> set(CMAKE_C_COMPILER ${RTEMS_TOOLS_PATH}/arm-rtems5-gcc CACHE PATH "ARM RTEMS5 gcc" FORCE)<br>
> set(CMAKE_CXX_COMPILER ${RTEMS_TOOLS_PATH}/arm-rtems5-gcc CACHE PATH "ARM RTEMS5 gcc" FORCE)<br>
> set(CMAKE_CXX_COMPILER_AR ${RTEMS_TOOLS_PATH}/arm-rtems5-gcc-ar CACHE PATH "ARM RTEMS5 ar" FORCE)<br>
> set(CMAKE_CXX_COMPILER_RANLIB ${RTEMS_TOOLS_PATH}/arm-rtems5-gcc-ranlib CACHE PATH "ARM RTEMS5 gcc ranlib" FORCE)<br>
> set(CMAKE_RANLIB ${RTEMS_TOOLS_PATH}/arm-rtems5-ranlib CACHE PATH "ARM RTEMS5 ranlib" FORCE)<br>
> set(CMAKE_READELF ${RTEMS_TOOLS_PATH}/arm-rtems5-readelf CACHE PATH "ARM RTEMS5 readelf" FORCE)<br>
> set(CMAKE_STRIP ${RTEMS_TOOLS_PATH}/arm-rtems5-strip CACHE PATH "ARM RTEMS5 strip" FORCE)<br>
> set(CMAKE_ADDR2LINE ${RTEMS_TOOLS_PATH}/arm-rtems5-addr2line CACHE PATH "ARM RTEMS5 addr2line" FORCE)<br>
> set(CMAKE_LINKER ${RTEMS_TOOLS_PATH}/arm-rtems5-ld CACHE PATH "ARM RTEMS5 ld" FORCE)<br>
> set(CMAKE_NM ${RTEMS_TOOLS_PATH}/arm-rtems5-nm CACHE PATH "ARM RTEMS5 nm" FORCE)<br>
> set(CMAKE_OBJCOPY ${RTEMS_TOOLS_PATH}/arm-rtems5-objcopy CACHE PATH "ARM RTEMS5 objcopy" FORCE)<br>
> set(CMAKE_OBJDUMP ${RTEMS_TOOLS_PATH}/arm-rtems5-objdump CACHE PATH "ARM RTEMS5 objdump" FORCE)<br>
> <br>
> set(CMAKE_TARGET_CONFIG_POSTFIX .rtems5_gcc_arm)<br>
> <br>
> Best regards<br>
> Andre Nahrwold<br>
> --------------------------<br>
> Deutsches Zentrum für Luft- und Raumfahrt e. V. (DLR)<br>
> German Aerospace Center<br>
> Institute for Software Technolog | SRV-OSS BS | Lilienthalpl. 7 | 38108 Braunschweig | Geb. 112C Raum 001<br>
> M.Sc. Andre Nahrwold | Telephone +49 531 295-3834 | <a href="mailto:andre.nahrwold@dlr.de" target="_blank">
andre.nahrwold@dlr.de</a><br>
> DLR.de<br>
> <br>
> _______________________________________________<br>
> users mailing list<br>
> <a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/users" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a><br>
> <br>
<br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>