How to use cMake
cmake generates a bunch of intermediate files, including the final Makefile. To make things clean, make a separate directory for the build process:
mkdir build
cd build
cmake ..
To re-run cmake after changing the CMakeLists.txt, do:
cd build
rm -rf *
cmake ..
Cross Compile to ARM
To cross compile to an embedded target, add the following lines to you CMakeLists.txt at the very top (after VERSION)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER arm-none-linux-gnueabi-gcc)
Add include paths
include_directories("${PROJECT_SOURCE_DIR}/../" "${PROJECT_SOURCE_DIR}/build/" "${PROJECT_SOURCE_DIR}")
FIND_LIBRARY(json json-c json)
1st parameter: output, The variable that will hold the results of FIND_LIBRARY
2nd parameter: the library to look for (in this case, libjson-c.so)
3rd parameter: the path to look, starting with ${PROJECT_SOURCE_DIR}
The returned varilable can be used in the following statement to add the library to link time:
TARGET_LINK_LIBRARIES(${json})
Assign a variable
SET(LIBS ${ubox} ${blobmsg_json} ${json})
assigns the concatenated value of ubox, blobmsg_json and json to the variable LIBS