2020-05-05 09:42:02 +00:00
|
|
|
cmake_minimum_required (VERSION 3.7)
|
2020-06-16 23:02:53 +00:00
|
|
|
project(core
|
2020-08-28 21:26:22 +00:00
|
|
|
VERSION 0.3.4
|
2020-06-16 23:04:12 +00:00
|
|
|
LANGUAGES C)
|
2019-07-12 19:05:56 +00:00
|
|
|
|
2020-06-16 20:05:44 +00:00
|
|
|
add_executable(core src/main.c)
|
2019-07-12 19:05:56 +00:00
|
|
|
|
2020-06-29 20:58:43 +00:00
|
|
|
target_link_libraries(core -lsqlite3)
|
|
|
|
target_link_libraries(core -luuid)
|
|
|
|
|
2020-07-17 21:33:35 +00:00
|
|
|
set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
|
2020-08-18 11:52:19 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=gnu99 -Wpedantic -Werror -Wall -Wextra -ffile-prefix-map=${CMAKE_SOURCE_DIR}/src/=")
|
2019-07-12 19:05:56 +00:00
|
|
|
|
2020-06-15 22:35:55 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage")
|
2019-09-01 17:34:50 +00:00
|
|
|
|
2020-06-25 23:01:46 +00:00
|
|
|
add_definitions("-DMG_ENABLE_EXTRA_ERRORS_DESC -DMG_ENABLE_MQTT_BROKER")
|
2019-09-08 17:54:38 +00:00
|
|
|
|
2020-06-16 20:05:44 +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/endpoints ENDPOINTS_SRC)
|
2020-08-13 09:26:06 +00:00
|
|
|
aux_source_directory(vendor VENDOR_SRC)
|
2019-09-01 17:34:50 +00:00
|
|
|
|
2020-08-13 09:26:06 +00:00
|
|
|
add_dependencies(core sql)
|
2020-06-16 23:06:12 +00:00
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
configure_file("core.ini" "core.ini" COPYONLY)
|
2020-06-16 23:52:06 +00:00
|
|
|
configure_file("version.h.in" "version.h" @ONLY)
|
|
|
|
|
2019-09-01 17:34:50 +00:00
|
|
|
|
2020-08-13 09:26:06 +00:00
|
|
|
target_sources(core PRIVATE ${SRC_DIR} ${HANDLERS_SRC} ${HELPERS_SRC} ${MODELS_SRC} ${ENDPOINTS_SRC} ${VENDOR_SRC})
|
2020-05-05 09:42:02 +00:00
|
|
|
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
2020-08-13 09:26:06 +00:00
|
|
|
target_include_directories(core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
|
2020-06-16 23:52:06 +00:00
|
|
|
target_include_directories(core PRIVATE ${CMAKE_BINARY_DIR})
|
2019-07-12 19:05:56 +00:00
|
|
|
|
2020-08-13 09:26:06 +00:00
|
|
|
add_custom_target(sql
|
|
|
|
COMMAND ./compile_sql.sh
|
2020-06-16 23:02:53 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
2020-02-23 00:12:39 +00:00
|
|
|
add_custom_target(run
|
2020-05-05 09:42:02 +00:00
|
|
|
COMMAND ./core start
|
2020-02-23 00:12:39 +00:00
|
|
|
DEPENDS core
|
2020-06-16 23:52:06 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
2020-02-23 00:12:39 +00:00
|
|
|
)
|
2020-08-29 07:10:50 +00:00
|
|
|
|
2020-02-23 19:06:14 +00:00
|
|
|
add_custom_target(test
|
2020-08-14 21:18:22 +00:00
|
|
|
COMMAND ./run_tests.sh ${CMAKE_BINARY_DIR}/core "--leak-check=full --show-leak-kinds=all --track-origins=yes"
|
|
|
|
DEPENDS core
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
)
|
2020-08-29 20:58:02 +00:00
|
|
|
|
|
|
|
add_custom_target(docs
|
|
|
|
COMMAND doxygen
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2020-05-05 20:29:04 +00:00
|
|
|
)
|
2020-08-29 07:10:50 +00:00
|
|
|
|
2020-08-29 20:58:02 +00:00
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES Debug)
|
2020-08-29 07:10:50 +00:00
|
|
|
message("debug mode")
|
|
|
|
add_custom_target(debug
|
|
|
|
COMMAND valgrind -s ./core start
|
|
|
|
DEPENDS core
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
add_custom_target(debug-leak
|
|
|
|
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./core start
|
|
|
|
DEPENDS core
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
add_custom_target(debug-callgrind
|
|
|
|
COMMAND valgrind --tool=callgrind ./core start
|
|
|
|
DEPENDS core
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
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}
|
|
|
|
)
|
2020-08-29 20:58:02 +00:00
|
|
|
|
|
|
|
add_custom_target(test-callgrind
|
|
|
|
COMMAND ./run_tests.sh ${CMAKE_BINARY_DIR}/core "--tool=callgrind"
|
|
|
|
DEPENDS core
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
)
|
|
|
|
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
|