diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d6fb7f56..654ea705c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,10 +70,6 @@ if(EVEREST_CORE_BUILD_TESTING) include(CTest) set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) - - evc_include(CodeCoverage) - - append_coverage_compiler_flags() endif() include(ev-define-dependency) @@ -115,7 +111,6 @@ else() find_package(ryml REQUIRED) endif() -add_subdirectory(lib) include(ev-project-bootstrap) @@ -126,6 +121,8 @@ if (ISO15118_2_GENERATE_AND_INSTALL_CERTIFICATES) file(TOUCH config/certs/ca/mf/MF_ROOT_CA.pem) endif() +add_subdirectory(lib) + # config # FIXME (aw): this should be optional add_subdirectory(config) @@ -148,18 +145,6 @@ endif() # testing if(EVEREST_CORE_BUILD_TESTING) add_subdirectory(tests) - - setup_target_for_coverage_gcovr_html( - NAME ${PROJECT_NAME}_gcovr_coverage - EXECUTABLE test_config - DEPENDENCIES test_config everest - ) - - setup_target_for_coverage_lcov( - NAME ${PROJECT_NAME}_lcov_coverage - EXECUTABLE test_config - DEPENDENCIES test_config everest - ) else() message("Not running unit tests") endif() diff --git a/cmake/ev-project-bootstrap.cmake b/cmake/ev-project-bootstrap.cmake index e9f5ce6db..3c07727b9 100644 --- a/cmake/ev-project-bootstrap.cmake +++ b/cmake/ev-project-bootstrap.cmake @@ -9,4 +9,5 @@ include(${CMAKE_CURRENT_LIST_DIR}/config-run-script.cmake) include(${CMAKE_CURRENT_LIST_DIR}/config-run-nodered-script.cmake) # source generate scripts / setup +include(${CMAKE_CURRENT_LIST_DIR}/ev-targets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/everest-generate.cmake) diff --git a/cmake/ev-targets.cmake b/cmake/ev-targets.cmake new file mode 100644 index 000000000..d4a2dde9a --- /dev/null +++ b/cmake/ev-targets.cmake @@ -0,0 +1,38 @@ +include_guard(GLOBAL) + +add_custom_target(everest_targets) + +set_target_properties(everest_targets + PROPERTIES + LIBRARIES "" + MODULES "" +) + +function(_ev_register_target TYPE NAME) + if (NOT TARGET ${NAME}) + message(FATAL_ERROR "The supplied name ${NAME} of type ${TYPE} is not a valid target") + endif() + + set_property( + TARGET everest_targets + APPEND + PROPERTY ${TYPE} ${NAME} + ) +endfunction() + +function(ev_register_library_target NAME) + _ev_register_target(LIBRARIES ${NAME}) +endfunction() + +function(ev_register_module_target NAME) + _ev_register_target(MODULES ${NAME}) +endfunction() + +function(ev_get_targets NAME TYPE) + get_target_property(tmp everest_targets ${TYPE}) + if (NOT tmp STREQUAL "" AND NOT tmp) + message(FATAL_ERROR "There is no target of type ${TYPE} defined") + endif() + + set(${NAME} ${tmp} PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/cmake/everest-generate.cmake b/cmake/everest-generate.cmake index bbfe81839..c72c0d35a 100644 --- a/cmake/everest-generate.cmake +++ b/cmake/everest-generate.cmake @@ -534,6 +534,8 @@ function (ev_add_cpp_module MODULE_NAME) add_dependencies(${MODULE_NAME} generate_cpp_files) + ev_register_module_target(${MODULE_NAME}) + install(TARGETS ${MODULE_NAME} DESTINATION "${EVEREST_MODULE_INSTALL_PREFIX}/${MODULE_NAME}" ) diff --git a/lib/staging/can_dpm1000/CMakeLists.txt b/lib/staging/can_dpm1000/CMakeLists.txt index 064da1177..5f0c54325 100644 --- a/lib/staging/can_dpm1000/CMakeLists.txt +++ b/lib/staging/can_dpm1000/CMakeLists.txt @@ -10,6 +10,8 @@ target_sources(can_dpm1000 src/dpm1000.cpp ) +ev_register_library_target(can_dpm1000) + if(BUILD_DEV_TESTS) add_subdirectory(tests) endif() diff --git a/lib/staging/evse_security/CMakeLists.txt b/lib/staging/evse_security/CMakeLists.txt index 1d722f471..6e12b99d7 100644 --- a/lib/staging/evse_security/CMakeLists.txt +++ b/lib/staging/evse_security/CMakeLists.txt @@ -19,3 +19,5 @@ target_link_libraries(evse_security_conversions everest::evse_security everest::framework ) + +ev_register_library_target(evse_security_conversions) diff --git a/lib/staging/external_energy_limits/CMakeLists.txt b/lib/staging/external_energy_limits/CMakeLists.txt index cdf7f3fac..d57215bf6 100644 --- a/lib/staging/external_energy_limits/CMakeLists.txt +++ b/lib/staging/external_energy_limits/CMakeLists.txt @@ -19,4 +19,6 @@ add_dependencies(external_energy_limits generate_cpp_files) target_link_libraries(external_energy_limits PRIVATE everest::framework -) \ No newline at end of file +) + +ev_register_library_target(external_energy_limits) diff --git a/lib/staging/gpio/CMakeLists.txt b/lib/staging/gpio/CMakeLists.txt index cd497d6c8..639b9b8d4 100644 --- a/lib/staging/gpio/CMakeLists.txt +++ b/lib/staging/gpio/CMakeLists.txt @@ -15,3 +15,5 @@ target_link_libraries(gpio PRIVATE ) +ev_register_library_target(gpio) + diff --git a/lib/staging/helpers/CMakeLists.txt b/lib/staging/helpers/CMakeLists.txt index 008972fdb..f1c7df477 100644 --- a/lib/staging/helpers/CMakeLists.txt +++ b/lib/staging/helpers/CMakeLists.txt @@ -23,6 +23,8 @@ target_link_libraries(everest_staging_helpers add_dependencies(everest_staging_helpers generate_cpp_files) +ev_register_library_target(everest_staging_helpers) + if (BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/lib/staging/ocpp/CMakeLists.txt b/lib/staging/ocpp/CMakeLists.txt index 591e0f234..dd7682b6a 100644 --- a/lib/staging/ocpp/CMakeLists.txt +++ b/lib/staging/ocpp/CMakeLists.txt @@ -28,6 +28,8 @@ target_link_libraries(ocpp_evse_security everest::framework ) +ev_register_library_target(ocpp_evse_security) + # OCPP conversions @@ -59,3 +61,5 @@ target_link_libraries(ocpp_conversions everest::framework ) +ev_register_library_target(ocpp_conversions) + diff --git a/lib/staging/slac/fsm/ev/CMakeLists.txt b/lib/staging/slac/fsm/ev/CMakeLists.txt index 4d4673fed..822bd1a95 100644 --- a/lib/staging/slac/fsm/ev/CMakeLists.txt +++ b/lib/staging/slac/fsm/ev/CMakeLists.txt @@ -17,3 +17,5 @@ target_link_libraries(slac_fsm_ev slac::slac fsm::fsm ) + +ev_register_library_target(slac_fsm_ev) diff --git a/lib/staging/slac/fsm/evse/CMakeLists.txt b/lib/staging/slac/fsm/evse/CMakeLists.txt index cb8be1751..8e673c815 100644 --- a/lib/staging/slac/fsm/evse/CMakeLists.txt +++ b/lib/staging/slac/fsm/evse/CMakeLists.txt @@ -20,3 +20,5 @@ target_link_libraries(slac_fsm_evse slac::slac fsm::fsm ) + +ev_register_library_target(slac_fsm_evse) diff --git a/lib/staging/slac/io/CMakeLists.txt b/lib/staging/slac/io/CMakeLists.txt index 146be44e5..f9e3d4de7 100644 --- a/lib/staging/slac/io/CMakeLists.txt +++ b/lib/staging/slac/io/CMakeLists.txt @@ -15,3 +15,5 @@ target_link_libraries(slac_io PUBLIC slac::slac ) + +ev_register_library_target(slac_io) diff --git a/lib/staging/tls/CMakeLists.txt b/lib/staging/tls/CMakeLists.txt index 17188f8c9..53ebc8700 100644 --- a/lib/staging/tls/CMakeLists.txt +++ b/lib/staging/tls/CMakeLists.txt @@ -35,3 +35,5 @@ target_link_libraries(tls if(EVEREST_CORE_BUILD_TESTING) add_subdirectory(tests) endif() + +ev_register_library_target(tls) diff --git a/lib/staging/util/CMakeLists.txt b/lib/staging/util/CMakeLists.txt index 9ceb4c91f..8b61985bf 100644 --- a/lib/staging/util/CMakeLists.txt +++ b/lib/staging/util/CMakeLists.txt @@ -9,3 +9,5 @@ target_include_directories(everest_staging_util if (BUILD_TESTING) add_subdirectory(tests) endif() + +ev_register_library_target(everest_staging_helpers) diff --git a/modules/Auth/lib/CMakeLists.txt b/modules/Auth/lib/CMakeLists.txt index 916e00886..0e56410a1 100644 --- a/modules/Auth/lib/CMakeLists.txt +++ b/modules/Auth/lib/CMakeLists.txt @@ -35,3 +35,5 @@ if(EVEREST_ENABLE_COMPILE_WARNINGS) PRIVATE ${EVEREST_COMPILE_OPTIONS} ) endif() + +ev_register_library_target(auth_handler) diff --git a/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt b/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt index 133b91bbf..116e12a77 100644 --- a/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt +++ b/modules/MicroMegaWattBSP/umwc_comms/CMakeLists.txt @@ -32,3 +32,5 @@ target_link_libraries(umwc_comms everest::framework everest::gpio ) + +ev_register_library_target(umwc_comms) diff --git a/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt b/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt index 8ea2bbe27..d9a64f2c1 100644 --- a/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt +++ b/modules/PN532TokenProvider/pn532_serial/CMakeLists.txt @@ -15,3 +15,5 @@ add_library(pn532_serial STATIC PN532Serial.cpp) target_include_directories(pn532_serial PUBLIC "${PROJECT_BINARY_DIR}") target_link_libraries(pn532_serial PRIVATE Threads::Threads everest::framework) + +ev_register_library_target(pn532_serial) diff --git a/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt b/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt index 2166c4a91..baa0da76f 100644 --- a/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt +++ b/modules/PhyVersoBSP/phyverso_gpio/CMakeLists.txt @@ -29,3 +29,5 @@ target_link_libraries(phyverso_gpio phyverso_config fmt::fmt ) + +ev_register_library_target(phyverso_gpio) diff --git a/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt b/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt index 362d58d3a..3d47d654d 100644 --- a/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt +++ b/modules/PhyVersoBSP/phyverso_mcu_comms/CMakeLists.txt @@ -25,6 +25,8 @@ target_link_libraries(phyverso_config fmt::fmt ) +ev_register_library_target(phyverso_config) + add_library(phyverso_mcu_comms STATIC) target_sources(phyverso_mcu_comms PRIVATE @@ -49,3 +51,5 @@ target_link_libraries(phyverso_mcu_comms everest::framework phyverso_config ) + +ev_register_library_target(phyverso_mcu_comms) diff --git a/modules/YetiDriver/yeti_comms/CMakeLists.txt b/modules/YetiDriver/yeti_comms/CMakeLists.txt index fa2f84cc9..0c1f99870 100644 --- a/modules/YetiDriver/yeti_comms/CMakeLists.txt +++ b/modules/YetiDriver/yeti_comms/CMakeLists.txt @@ -29,3 +29,5 @@ target_link_libraries(yeti_comms everest::framework everest::gpio ) + +ev_register_library_target(yeti_comms) diff --git a/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt b/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt index 95747df35..f34c22ebb 100644 --- a/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt +++ b/modules/YetiEvDriver/evyeti_comms/CMakeLists.txt @@ -32,3 +32,5 @@ target_link_libraries(evyeti_comms Pal::Sigslot everest::framework ) + +ev_register_library_target(evyeti_comms) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cc3446784..7bba947c5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1 +1,21 @@ +# enabling coverage related things + +evc_include(CodeCoverage) + +# add compiler flags to all targets which should be coveraged + +foreach(type MODULES LIBRARIES) + ev_get_targets(targets ${type}) + + foreach(target ${targets}) + append_coverage_compiler_flags_to_target(${target}) + endforeach() +endforeach() + +get_target_property(GENERATED_OUTPUT_DIR generate_cpp_files EVEREST_GENERATED_OUTPUT_DIR) +setup_target_for_coverage_gcovr_html( + NAME ${PROJECT_NAME}_gcovr_coverage + EXCLUDE "${GENERATED_OUTPUT_DIR}/*" +) + add_subdirectory(everest-core_tests)