controller-legacy/CMakeLists.txt

67 lines
2.1 KiB
CMake

cmake_minimum_required (VERSION 3.7)
project(controller
VERSION 0.3.1
LANGUAGES C)
add_executable(controller src/main.c)
target_link_libraries(controller -lwiringPi)
target_link_libraries(controller -lwiringPiDev)
target_link_libraries(controller -lsqlite3)
target_link_libraries(controller -luuid)
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF)
set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=gnu99 -Wpedantic -Werror -Wall -Wextra -ffile-prefix-map=${CMAKE_SOURCE_DIR}/src/=")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage")
if(WIRING_PI_DEBUG)
message("Showing wiringPi calls as debug")
add_definitions("-DWIRING_PI_DEBUG")
endif(WIRING_PI_DEBUG)
aux_source_directory(src/ SRC_DIR)
aux_source_directory(src/models MODELS_SRC)
aux_source_directory(src/helpers HELPERS_SRC)
aux_source_directory(src/handlers HANDLERS_SRC)
aux_source_directory(src/drivers DRIVERS_SRC)
aux_source_directory(src/runners RUNNERS_SRC)
aux_source_directory(vendor VENDOR_SRC)
add_dependencies(controller sql)
configure_file("controller.ini" "controller.ini" COPYONLY)
configure_file("version.h.in" "version.h" @ONLY)
target_sources(controller PRIVATE ${SRC_DIR} ${MODELS_SRC} ${HELPERS_SRC} ${HANDLERS_SRC} ${DRIVERS_SRC} ${RUNNERS_SRC} ${VENDOR_SRC})
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
target_include_directories(controller PRIVATE ${CMAKE_BINARY_DIR})
add_custom_target(sql
COMMAND ./compile_sql.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(run
COMMAND ./controller start
DEPENDS controller
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(debug
COMMAND valgrind ./controller start
DEPENDS controller
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(debug-full
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./controller start
DEPENDS controller
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(docs
COMMAND doxygen
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)