In this blog post, we’ll show you how to use a CMake Toolchain file to cross-compile the OpenDOF C libraries. (The method shown below is not the only possibility, but it is the most common.)

The first step is to create a CMAKE_TOOLCHAIN_FILE. This file specifies, among other things, which compiler and which system utilities will be used. For detailed information about toolchains, go to https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html.

Once you have the toolchain file, run the following commands to build the OpenDOF libraries:

cmake <top source directory of library to build> -DCMAKE_TOOLCHAIN_FILE=<toolchain file location> <other arguments such as install prefix location>

cmake --build . --target install

Note: When running OpenDOF builds for a target system’s architecture, any system introspection that requires running a binary on the target system will fail. OpenDOF libraries have provided variables to bypass system introspection in these cases. One case that this is used for is in determining endianness of the target system.