\subsection{Cross-Compilation, Toolchain files}

\begin{frame}
  \frametitle{Cross-compilation}

  \begin{center}
    \huge Dealing with different platforms
  \end{center}
\end{frame}

%--------------------------------------------------------------------------------------------------

\begin{frame}
    \frametitle{Cross-Compilation, Concepts}
    Building binaries for a platform other than the one on which the
    compiler runs.

    \vspace{1em}

    \textbf {Host Platform} \\
        {\info {Platform/System \textbf {ON} which the binaries are built, compiler(cross-compiler) runs.}}

    \vspace{1em}

    \textbf{Target Platform} \\
        {\info {Platform \textbf {FOR} which the binaries are built.}}
\end{frame}

%--------------------------------------------------------------------------------------------------

\begin{frame}
    \frametitle{Cross-Compilation, Concepts}
    \textbf {Toolchain}\\
    {\info {Set of tools and libraries to built binaries for a target platform, such as:}
    \begin{itemize}
        \item Binutils
        \item Cross Compiler
        \item C Library
        \item Debugger
    \end{itemize}
    }
\end{frame}


%--------------------------------------------------------------------------------------------------

\begin{frame}
    \frametitle{CMake \& Cross-Compilation}
    CMake needs help to recognize Cross-Compilation, e.g.\\
    \begin{itemize}
        \item Target System Name
        \item Cross Compiler Location
        \item Library Search Paths
        \item etc.
    \end{itemize}
\end{frame}

%--------------------------------------------------------------------------------------------------

\begin{frame}
    \frametitle{CMake \& Cross-Compilation}

    \textbf {Toolchain Files} - CMake Script enclosing toolchain info.

    E.g.:

    \begin{itemize}
    \item Target System Name -- {\code CMAKE\_SYSTEM\_NAME}
    \item Cross-Compiler to be used -- {\code CMAKE\_C\_COMPILER}
    \item Library and Package search root -- {\code {CMAKE\_FIND\_ROOT\_PATH}}
    \item Default compiler and linker flags specific to the target platform
    \end{itemize}

    {\info {\code {CMAKE\_TOOLCHAIN\_FILE}} used to provide toolchain file location}
\end{frame}

%--------------------------------------------------------------------------------------------------

\begin{frame}
  \frametitle{CMake \& Cross-Compilation}

  System introspection is still possible  while cross-compiling:

  \begin{itemize}
  \item {\code {try\_compile}} - works as expected
  \item {\code {try\_run}} - limited functionality, run phase is usually skipped
  \end{itemize}
\end{frame}

%--------------------------------------------------------------------------------------------------

\note{
    What is cross-compilation
        HOST, TARGET, compilers
    Toolchain files
        - meaning and content
    Cross compilation with cmake
        - CMAKE Variables
        - Searching \& finding packages
        - toolchain files
        - system introspection (try-compile, try-run)
        - HOST-TOOLS, why might be required
            - Using Executables in the build created during the build
}
