50 lines
1.7 KiB
CMake
50 lines
1.7 KiB
CMake
cmake_minimum_required (VERSION 3.7)
|
|
project(controller)
|
|
|
|
add_executable(controller main.c)
|
|
|
|
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF)
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -Werror -Wpedantic -lwiringPi -lwiringPiDev -luuid -llmdb -g")
|
|
|
|
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
|
|
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
|
|
|
|
if(WIRING_PI_DEBUG)
|
|
message("Showing wiringPi calls as debug")
|
|
add_definitions("-DWIRING_PI_DEBUG")
|
|
endif(WIRING_PI_DEBUG)
|
|
|
|
aux_source_directory(vendor VENDOR_SRC) # vendor first to put their warnings on top
|
|
aux_source_directory(. SRC_DIR)
|
|
aux_source_directory(models MODELS_SRC)
|
|
aux_source_directory(helpers HELPERS_SRC)
|
|
aux_source_directory(handlers HANDLERS_SRC)
|
|
aux_source_directory(drivers DRIVERS_SRC)
|
|
aux_source_directory(runners RUNNERS_SRC)
|
|
|
|
configure_file("controller.ini" "controller.ini" COPYONLY)
|
|
|
|
target_sources(controller PRIVATE ${VENDOR_SRC} ${SRC_DIR} ${MODELS_SRC} ${HELPERS_SRC} ${HANDLERS_SRC} ${DRIVERS_SRC} ${RUNNERS_SRC})
|
|
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
|
|
|
|
add_custom_target(run
|
|
COMMAND ./controller start
|
|
DEPENDS controller
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
)
|
|
add_custom_target(debug
|
|
COMMAND valgrind ./controller start
|
|
DEPENDS controller
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
)
|
|
add_custom_target(debug-full
|
|
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./controller start
|
|
DEPENDS controller
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
)
|
|
add_custom_target(docs
|
|
COMMAND doxygen
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|