67 lines
2.2 KiB
CMake
67 lines
2.2 KiB
CMake
cmake_minimum_required (VERSION 3.7)
|
|
project(core)
|
|
|
|
add_executable(core main.c)
|
|
|
|
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (OFF)" OFF)
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -g -fprofile-arcs -ftest-coverage")
|
|
|
|
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)
|
|
|
|
add_definitions("-DMG_ENABLE_EXTRA_ERRORS_DESC")
|
|
|
|
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(endpoints ENDPOINTS_SRC)
|
|
|
|
configure_file("core.ini" "core.ini" COPYONLY)
|
|
|
|
target_sources(core PRIVATE ${VENDOR_SRC} ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC})
|
|
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
|
|
|
|
add_custom_target(migrations
|
|
COMMAND ./compile_migrations.sh
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
)
|
|
|
|
add_custom_target(run
|
|
COMMAND ./core start
|
|
DEPENDS core
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
)
|
|
add_custom_target(debug
|
|
COMMAND valgrind ./core start
|
|
DEPENDS core
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
)
|
|
add_custom_target(debug-full
|
|
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./core start
|
|
DEPENDS core
|
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
|
|
)
|
|
add_custom_target(docs
|
|
COMMAND doxygen
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|
|
|
|
add_custom_target(test
|
|
COMMAND ./run_tests.sh ${CMAKE_BINARY_DIR}/core "dev"
|
|
DEPENDS core
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
)
|
|
add_custom_target(coverage
|
|
COMMAND gcovr -s --root ${CMAKE_SOURCE_DIR} -e ${CMAKE_SOURCE_DIR}/vendor --html-details ${CMAKE_BINARY_DIR}/coverage.html --html-title "Emgauwa Core Coverage" ${CMAKE_BINARY_DIR}/CMakeFiles/core.dir
|
|
DEPENDS test
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
)
|