Starting with SDK v8.0.0, CMake can be used to create the necessary build files (Unix Makefiles on Linux, MS Visual Studio Solutions on Windows, etc) for compiling the openjaus source code. 


Important Notes:

  1. We make a number of assumptions on how the average user will be building/using our code base, in order to make Getting Started as simple as possible. If you have more complex needs, you may need to modify the CMakeLists.txt files directly or set cmake variables to modify our default behavior.
  2. The provided CMake files were tested using CMake v3.19. They should work with CMake v3.9 or later but this has not been verified.


Table of CONTENTS



Installing the Source

  1. Download all the necessary packages from the openjaus client site
    • The openjaus SDK is split up across multiple packages depending the type of SDK you have (SAE, IOP, etc)
  2. Create a top-level folder that will contain all the openjaus provided code. This will be referred to as the {openjaus_sdk_root} folder.
  3. Unzip each package such that they are in a subfolder under the {openjaus_sdk_root} folder.
    • In the following screenshot, the folder structure for the SAE SDK is shown:

  • If you have additional packages, make sure they are directly under the openjaus_sdk_root folder and side by side with the packages show above.



Compiling the openjaus Libraries

Linux

  1. Install CMake (See Note 2 above)
  2. Open a command terminal window
  3. Go to the org.openjaus.sdk.cpp folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp 
  4. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  5. Go into the newly created build folder
    • cd build
  6. Run CMake from within the build folder and have it point to the directory that contains the CMakeLists.txt file
    • cmake ..
    • Note: This will use the default CMake generator which is Unix Makefiles on Linux. If you want to use a different generator you will need to specify as such using the CMake -G option.
  7. Run make to build the code
    • make all
    • Note: If you have multi-core CPU you can have make split the file across multiple "jobs". Below we us3 4 jobs for the compile:
      • make -j4 all
  8. Install the header files and built binaries
    • make install
    • Note: By default the headers and libraries will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install. 
      • If you want to install to different location set the OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON and use the CMAKE_INSTALL_PREFIX cmake variables when running the initial cmake command
        • cmake -D OJ_OVERRIDE_DEFALT_INSTALL_DIR=ON -D CMAKE_INSTALL_PREFIX={my_install_location} ../..
  9. Repeat steps 3 to 8 for each openjaus package
    • Note: The installation step (#8) must be completed before building follow-on projects to ensure that the headers are found and the libraries can be properly linked.
      • If you installed to a different location, you may need to specify that location using CMAKE_PREFIX_PATH


Windows

  1. Install CMake (See Note 2 above)
  2. Open a command terminal window
  3. Go to the org.openjaus.sdk.cpp folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp 
  4. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  5. Go into the newly created build folder
    • cd build
  6. Run CMake from within the build folder and have it point to the directory that contains the CMakeLists.txt file
    • cmake ..
    • Note: This will use the default CMake generator which is Visual Studio Project/Solution files on Windows. If you want to use a different generator you will need to specify as such using the CMake -G option.
  7. Open generated solution in MSVS and build
    • Note: By default the headers and libraries will be installed automatically after the build to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to run the install manually and the need to have administrator access to do the install. 
      • If you want to install to different location set the OJ_OVERRIDE_DEFAULT_INSTALL_DIR=ON and use the CMAKE_INSTALL_PREFIX cmake variables when running the initial cmake command
        • cmake -D OJ_OVERRIDE_DEFALT_INSTALL_DIR=ON -D CMAKE_INSTALL_PREFIX={my_install_location} ../..
      • If you don't want the install to run automatically set CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD=OFF 
  8. Repeat steps 3 to 8 for each openjaus package
    • Note: The installation step (#8) must be completed before building follow-on projects to ensure that the headers are found and the libraries can be properly linked.
      • If you installed to a different location, you may need to specify that location using CMAKE_PREFIX_PATH



Compiling the SDK Examples


Note: The openjaus-sdk library must be built and installed before the examples can be built and run. If they are not, you will get a cmake error. If you specified a different installation location when building the openjaus-sdk library, you may need to specify that location using the CMAKE_PREFIX_PATH variable.


Linux 

  1. Open a command terminal window
  2. Go to the org.openjaus.sdk.cpp examples folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp/examples
  3. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  4. Go into the newly created build folder
    • cd build
  5. Run CMake from within the build folder and have it point to the directory that contains the CMakeLists.txt file
    • cmake ..
  6. Run make to build the code
    • make all
  7. Install the header files and built binaries
    • make install
    • Note: By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install.


Windows

  1. Open a command terminal window
  2. Go to the org.openjaus.sdk.cpp examples folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp/examples
  3. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  4. Go into the newly created build folder
    • cd build
  5. Run CMake from within the build folder and have it point to the directory that contains the CMakeLists.txt file
    • cmake ..
  6. Open generated solution in MSVS and build 
    • Note: By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install.


Running the BasicExample -- Windows, Linux

  1. Open a command terminal window
  2. Go to the installation folder
    • cd {openjaus_sdk_root}/install/{OS_Architecture}/bin/BasicExample
  3. Run the BasicExample Application
    • Notes: 
      • On windows the library dlls will be installed side-by-side with the application which will allow the application to find them and run.
      • On linux, the library shared object(.so) files will need to be in a location where the application can find them; such as in the /usr/lib folder or by configuring the system using ldconfig.



Cross-Compiling the openjaus Libraries for ARM Devices


Note: These instructions were written using MentorGraphics Sourcery CodeBench Lite 2014.05-29. While the referenced cmake toolchain file is provided with the SDK, the Sourcery CodeBench toolchain is not. If not using this cross-compile toolchain, your steps may be different.


Using a Linux Host


  • Open a command terminal window
  • Go to the org.openjaus.sdk.cpp examples folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp
  • Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  • Go into the newly created build folder
    • cd build
  • Copy the cross-compile toolchain file to the build folder
    • cp ../buildtools/cmake/toolchains/codesourcery.cmake .
  • Run cmake using the toolchain file
    • cmake -D CMAKE_TOOLCHAIN_FILE=codesourcery.cmake ..
  • Build and install
    • make all install
    • Note: By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install.


Using a Windows Host


  • Open a command terminal window
  • Go to the org.openjaus.sdk.cpp examples folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp
  • Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  • Go into the newly created build folder
    • cd build
  • Copy the cross-compile toolchain file to the build folder
    • cp ../buildtools/cmake/toolchains/codesourcery.cmake .
    • Note: cp is the command to copy files when using PowerShell. If you're using Windows Command Prompt, the command will be different.
  • Run cmake using the toolchain file
    • cmake -G “MinGW Makefiles” -D CMAKE_TOOLCHAIN_FILE=codesourcery.cmake ..
    • Note: Cross-compiling using Sourcery CodeBench requires the generation of MinGW Makefiles versus Microsoft Visual Studio files.
  • Build and install
    • cs-make all install
    • Note: By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install.


Cross-Compiling the SDK Examples for ARM Devices


Note: These instructions were written using MentorGraphics Sourcery CodeBench Lite 2014.05-29. While the referenced cmake toolchain file is provided with the SDK, the Sourcery CodeBench toolchain is not. If not using this cross-compile toolchain, your steps may be different.


Note: The openjaus-sdk library must be built and installed before the examples can be built and run. If they are not, you will get a cmake error. If you specified a different installation location when building the openjaus-sdk library, you may need to specify that location using the CMAKE_PREFIX_PATH variable.


Using a Linux  Host

  1. Open a command terminal window
  2. Go to the org.openjaus.sdk.cpp examples folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp/examples
  3. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  4. Go into the newly created build folder
    • cd build
  5. Copy the cross-compile toolchain file to the build folder
    • cp ../../buildtools/cmake/toolchains/codesourcery.cmake .
  6. Run cmake using the toolchain file
    • cmake -D CMAKE_TOOLCHAIN_FILE=codesourcery.cmake ..
  7. Build and install
    • cs-make all install
    • Note: By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install.


Using a Windows Host

  1. Open a command terminal window
  2. Go to the org.openjaus.sdk.cpp examples folder 
    • cd {openjaus_sdk_root}/org.openjaus.sdk.cpp/examples
  3. Create a build folder to house the CMake generated build files. This keeps the source and build files separated
    • mkdir build
  4. Go into the newly created build folder
    • cd build
  5. Copy the cross-compile toolchain file to the build folder
    • cp ../buildtools/cmake/toolchains/codesourcery.cmake .
    • Note: cp is the command to copy files when using PowerShell. If you're using Windows Command Prompt, the command will be different.
  6. Run cmake using the toolchain file
    • cmake -G “MinGW Makefiles” -D CMAKE_TOOLCHAIN_FILE=codesourcery.cmake ..
  7. Build and install
    • cs-make all install
    • Note: By default the compiled application(s) will be installed to {openjaus_sdk_root}/install/{OS_Architecture} vs cmake's default location. This removes the need to have root access to do the install.

Running the BasicExample on ARM Devices

  1. Copy the contents of the installation folder to the ARM device
    • Note: {openjaus_ROOT}/install/{OS_Architecture} is the openjaus default installation path. If you used CMAKE_INSTALL_PREFIX when running cmake, then the BasicExample will be installed under that location.
  2. Open a command terminal window on the ARM  device
  3. Go to the installation location on the ARM device
  4. Run the BasicExample Application
    • Note: The ARM build will statically link against the openjaus libraries such that only the executable is needed