2019-11-15 00:23:43 +00:00
|
|
|
cmake_minimum_required (VERSION 3.7)
|
2020-06-20 22:10:37 +00:00
|
|
|
project(controller
|
2020-08-27 11:22:10 +00:00
|
|
|
VERSION 0.3.7
|
2020-06-20 22:10:37 +00:00
|
|
|
LANGUAGES C)
|
2019-11-15 00:23:43 +00:00
|
|
|
|
2020-06-20 22:10:37 +00:00
|
|
|
add_executable(controller src/main.c)
|
2019-11-15 00:23:43 +00:00
|
|
|
|
2020-06-29 23:58:24 +00:00
|
|
|
target_link_libraries(controller -lwiringPi)
|
|
|
|
target_link_libraries(controller -lwiringPiDev)
|
2020-08-24 14:00:08 +00:00
|
|
|
target_link_libraries(controller -lsqlite3)
|
2020-06-29 23:58:24 +00:00
|
|
|
target_link_libraries(controller -luuid)
|
|
|
|
|
2020-04-28 23:49:36 +00:00
|
|
|
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF)
|
2019-11-15 00:23:43 +00:00
|
|
|
|
2020-11-21 23:56:01 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D'__FILENAME__=\"$(subst $(realpath ${CMAKE_SOURCE_DIR}/src/)/,,$(abspath $<))\"'")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=gnu99 -Wpedantic -Werror -Wall -Wextra")
|
2019-11-15 00:23:43 +00:00
|
|
|
|
2020-06-15 22:40:05 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage")
|
2020-02-08 12:50:54 +00:00
|
|
|
|
2020-11-21 23:56:01 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
|
|
|
|
file(GLOB_RECURSE ALL_SOURCE_FILES src/*.c)
|
|
|
|
|
2019-11-15 00:23:43 +00:00
|
|
|
if(WIRING_PI_DEBUG)
|
2020-04-24 13:08:26 +00:00
|
|
|
message("Showing wiringPi calls as debug")
|
|
|
|
add_definitions("-DWIRING_PI_DEBUG")
|
2019-11-15 00:23:43 +00:00
|
|
|
endif(WIRING_PI_DEBUG)
|
|
|
|
|
2020-06-20 22:10:37 +00:00
|
|
|
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)
|
2020-08-20 12:09:55 +00:00
|
|
|
aux_source_directory(vendor VENDOR_SRC)
|
2019-11-15 00:23:43 +00:00
|
|
|
|
2020-08-24 14:00:08 +00:00
|
|
|
add_dependencies(controller sql)
|
|
|
|
|
2020-06-20 22:10:37 +00:00
|
|
|
configure_file("version.h.in" "version.h" @ONLY)
|
2020-04-16 23:38:25 +00:00
|
|
|
|
2020-08-24 14:00:08 +00:00
|
|
|
|
2020-08-20 12:09:55 +00:00
|
|
|
target_sources(controller PRIVATE ${SRC_DIR} ${MODELS_SRC} ${HELPERS_SRC} ${HANDLERS_SRC} ${DRIVERS_SRC} ${RUNNERS_SRC} ${VENDOR_SRC})
|
2020-01-07 01:23:16 +00:00
|
|
|
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
2020-08-20 12:09:55 +00:00
|
|
|
target_include_directories(controller PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
|
2020-06-20 22:10:37 +00:00
|
|
|
target_include_directories(controller PRIVATE ${CMAKE_BINARY_DIR})
|
2020-02-08 12:50:54 +00:00
|
|
|
|
2020-08-24 14:00:08 +00:00
|
|
|
add_custom_target(sql
|
|
|
|
COMMAND ./compile_sql.sh
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
2020-02-08 12:50:54 +00:00
|
|
|
add_custom_target(run
|
2020-11-21 23:56:01 +00:00
|
|
|
COMMAND ${CMAKE_BINARY_DIR}/controller
|
2020-04-13 22:50:55 +00:00
|
|
|
DEPENDS controller
|
2020-11-21 23:56:01 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2020-02-08 12:50:54 +00:00
|
|
|
)
|
2020-11-21 23:56:01 +00:00
|
|
|
|
2020-02-09 23:58:17 +00:00
|
|
|
add_custom_target(docs
|
|
|
|
COMMAND doxygen
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
)
|
2020-11-21 23:56:01 +00:00
|
|
|
|
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
message(STATUS "loading debug targets")
|
|
|
|
add_custom_target(debug
|
|
|
|
COMMAND gdb ${CMAKE_BINARY_DIR}/controller
|
|
|
|
DEPENDS controller
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
add_custom_target(valgrind
|
|
|
|
COMMAND valgrind -s ${CMAKE_BINARY_DIR}/controller
|
|
|
|
DEPENDS controller
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
add_custom_target(valgrind-leak
|
|
|
|
COMMAND valgrind --leak-check=full --show-leak-kinds=all ${CMAKE_BINARY_DIR}/controller
|
|
|
|
DEPENDS controller
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
clang-tidy
|
|
|
|
COMMAND /usr/bin/clang-tidy
|
|
|
|
${ALL_SOURCE_FILES}
|
|
|
|
--header-filter=${CMAKE_SOURCE_DIR}/include/*
|
|
|
|
--
|
|
|
|
-std=gnu99
|
|
|
|
-I${CMAKE_SOURCE_DIR}/include
|
|
|
|
-I${CMAKE_SOURCE_DIR}/vendor
|
|
|
|
-I${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
|