cmake_minimum_required (VERSION 3.7) project(core VERSION 0.1.1 LANGUAGES C) add_executable(core src/main.c) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wpedantic -Werror -Wall -Wextra -luuid -lsqlite3 -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") 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) add_dependencies(core migrations) 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}) target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_include_directories(core PRIVATE ${CMAKE_BINARY_DIR}) 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_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 "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} )