Compiling the SDK for QNX with CMake
Posted: 12 Jun 2013, 12:17
This HowTo will show you how to compile the SDK with CMake, but will not explain CMake in depth. For the interested reader we recommend to read the CMake Tutorial and the CMake Documentation to get a full understanding of CMake.
Important: This HowTo shows the possibility of building the source SDK (this will NOT work for all examples even in EVAL packages).
Requirements
Important: This HowTo shows the possibility of building the source SDK (this will NOT work for all examples even in EVAL packages).
Requirements
- Unified Automation SDK with qnx platform
- CMake (> 2.8.0)
- qnx (optional: qnx Momentics IDE)
- CMake toolchain files for qnx
- example for a toolchain file used on windows (assumed you have installed qnx to its default path):
Code: Select all
# this one is important SET(CMAKE_SYSTEM_NAME QNX) #this one not so much SET(CMAKE_SYSTEM_VERSION 641) # specify the cross compiler SET(CMAKE_C_COMPILER C:/QNX641/host/win32/x86/usr/bin/i386-pc-nto-qnx6.4.0-gcc-4.3.3.exe) SET(CMAKE_CXX_COMPILER C:/QNX641/host/win32/x86/usr/bin/i386-pc-nto-qnx6.4.0-g++-4.3.3.exe) SET(CMAKE_AR "C:/QNX641/host/win32/x86/usr/bin/ntox86-ar.exe" CACHE PATH "QNX ar Program" ) # which library to find SET(XML_LIBRARY xml2) SET(SSL_LIBRARY ssl) # where to search the lib SET(LIBRARY_ARCH x86) # where is the target environment SET(CMAKE_FIND_ROOT_PATH C:/QNX641/target/qnx6) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- example for a toolchain file used on linux (assumed you have installed qnx to its default path):
Code: Select all
# this one is important SET(CMAKE_SYSTEM_NAME QNX) #this one not so much SET(CMAKE_SYSTEM_VERSION 641) # specify the cross compiler SET(CMAKE_C_COMPILER /opt/qnx641/host/linux/x86/usr/bin/i386-pc-nto-qnx6.4.0-gcc-4.3.3) SET(CMAKE_CXX_COMPILER /opt/qnx641/host/linux/x86/usr/bin/i386-pc-nto-qnx6.4.0-g++-4.3.3) SET(CMAKE_AR "/opt/qnx641/host/linux/x86/usr/bin/ntox86-ar" CACHE PATH "QNX ar Program" ) # which library to find SET(XML_LIBRARY xml2) SET(SSL_LIBRARY ssl) # where to search the lib SET(LIBRARY_ARCH x86) # where is the target environment SET(CMAKE_FIND_ROOT_PATH /opt/qnx641/target/qnx6) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- The toolchain file is located in folder "toolchains" in your sdk. Available toolchain files are:
- toolchain-qnx-arm.cmake
- toolchain-qnx-mips.cmake
- toolchain-qnx-powerpc.cmake
- toolchain-qnx-sh.cmake
- toolchain-qnx-x86.cmake
- Create a build folder where to build the sources (e.g.: "path/to/sdk/bld").
- You can create the Makefiles for compiling on the command line as follows:
Code: Select all
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=../dist -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake ../src
- If you want to create Makefiles for the qnx Momentics IDE, use the following CMake command:
Code: Select all
cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_INSTALL_PREFIX=../dist -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake ../src
- Now compile and install the sources:
Code: Select all
make make install