cmake_minimum_required (VERSION 3.7) project(core VERSION 0.2.6 LANGUAGES C) add_executable(core src/main.c) target_link_libraries(core -lsqlite3) target_link_libraries(core -luuid) set(CMAKE_C_FLAGS "$ENV{CFLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -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") add_definitions("-DMG_ENABLE_EXTRA_ERRORS_DESC -DMG_ENABLE_MQTT_BROKER") 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/endpoints ENDPOINTS_SRC) aux_source_directory(vendor VENDOR_SRC) add_dependencies(core sql) configure_file("core.ini" "core.ini" COPYONLY) configure_file("version.h.in" "version.h" @ONLY) target_sources(core PRIVATE ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC} ${VENDOR_SRC}) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor) target_include_directories(core PRIVATE ${CMAKE_BINARY_DIR}) add_custom_target(sql COMMAND ./compile_sql.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_custom_target(run COMMAND ./core start DEPENDS core WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_custom_target(debug COMMAND valgrind ./core start DEPENDS core WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_custom_target(debug-full COMMAND valgrind --leak-check=full --show-leak-kinds=all ./core start DEPENDS core WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_custom_target(docs COMMAND doxygen WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) add_custom_target(test COMMAND ./run_tests.sh ${CMAKE_BINARY_DIR}/core 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} )