Table of Contents

CMake

https://cmake.org/Wiki/CMake_Useful_Variables http://www.vtk.org/Wiki/CMake_Cross_Compiling#Setting_up_the_system_and_toolchain

verbose build

Method 1

CMakeList.txt
set(CMAKE_VERBOSE_MAKEFILE ON)

Method 2

make VERBOSE=1

Method 3

cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON $path_to_project_source

multiline strings

Use 2 space indentation

message(STATUS "This is a very long
  message spanning on
  several lines
")

add all *.c files

cmake_minimum_required(VERSION 2.8)
 
file(GLOB helloworld_SRC
    "*.h"
    "*.cpp"
)
 
add_executable(helloworld ${helloworld_SRC})

linker flags

Check:

set (CMAKE_EXE_LINKER_FLAGS "-Wl,--unresolved-symbols=ignore-in-object-files") 

debug build

mkdir Debug
cd Debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
mkdir Release
cd Release
cmake -DCMAKE_BUILD_TYPE=Release ..
make
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")

libraries

add_executable(ws2812 ${COMMON_SOURCES} ${TARGET_SOURCES})
target_link_libraries(ws2812 rpi_ws281x)
 
set(RPI_WS281X_SOURCES
    mailbox.c
    ws2811.c
    pwm.c
    dma.c
    rpihw.c
)
 
add_library(rpi_ws281x STATIC ${RPI_WS281X_SOURCES})

find_package vs find_library