2- Setting up the Development Environment:



Create the Cross-Compilation configuration file that you will use for Owasys 4 projects for cmake:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
SET(CMAKE_C_COMPILER /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-c++)

# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf )

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)


### !!!!! These will prevent finding SSL libraries and stuff below !!! What a pain in the ass

# for libraries and headers in the target directories
#SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


SET(OPENSSL_ROOT_DIR /opt/compiled-arm-linux/openssl-1.1.0)


Create a New Owasys Project

Open KDevelop


-DCMAKE_TOOLCHAIN_FILE=/home/politick/projects/Toolchain-arm-linux-gneabi.cmake




You will need to have the IDE regenerate the CMake files. To do this,

Right click on the project,

Open Configuration...

Select a configuration or press Show Advanced or someting... so the Apply button becomes active. Once you press the Apply button, cmake will re-run.

I typically have 2 configurations,= { rel and debug }. The differences:

Installation prefix:

  • /home/politick/projects/debug
  • /home/politick/projects/

Build Type

  • Debug
  • Release



Delete Default

NOTE: For some reason, it did not take when I added it in the wizard. I had to follow the steps below an delete the current build anyway as the target was the x64 and not the ARM for some reason.

My guess is that CMake is not re-run and the project is not re-configured for the new tool chain. But if you delete and add a new, CMake is re-run automatically.


You can go into the build directory and remove the CMakeCache.txt and Makefile, that will likely fix as they will have to be re-generated



In case you forgot to add this IMPORTANT step, you can

  1. Right click on project
  2. Click on "Open Configuration..."
  3. Then click on CMake icon
    1. Delete current build by clicking on the "Minus" button
  4. Re-do the configuration and don't forget to add the extra parameter
  5. Press the Apply button to generate the new cmake files



Maintain your CMakeLists.txt

You need to maintain your CMakeList manually.  It should probably look like this:

cmake_minimum_required(VERSION 2.6)
project(owasys4)

#link_directories(
#/opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib
#/opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/ 
#)

include_directories(
~/projects/include/
)

add_executable(owasys4 main.cpp)

target_link_libraries(owasys4 RTU_Module IOs_Module GPS2_Module pthread dl )
#set_target_properties(owasys4 PROPERTIES PUBLIC_HEADER "Message.h")

install(TARGETS owasys4 
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)


Adding a new source.c file to the project