From: 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Mon, 5 Aug 2019 07:53:58 +0000 (+0900) Subject: Introduce interface for strict build and coverage (#6207) X-Git-Tag: submit/tizen/20190809.050447~174 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b953b190a7c1a5f06a6fbef06fa12601c2b831ec;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce interface for strict build and coverage (#6207) Introduce interface nnfw_common and nnfw_coverage in nnfw cmake script Introduce cmake option variable for strict build and variable setting for coverage build Signed-off-by: Hyeongseok Oh --- diff --git a/infra/nnfw/CMakeLists.txt b/infra/nnfw/CMakeLists.txt index 2b76616..1a93d03 100644 --- a/infra/nnfw/CMakeLists.txt +++ b/infra/nnfw/CMakeLists.txt @@ -57,6 +57,36 @@ include("cmake/CfgOptionFlags.cmake") nnfw_find_package(GTest QUIET) +if(NOT DEFINED ENABLE_TEST) + # Enable test by default + set(ENABLE_TEST ${GTest_FOUND}) +endif(NOT DEFINED ENABLE_TEST) + +if(${ENABLE_TEST} AND NOT ${GTest_FOUND}) + message(FATAL_ERROR "Google Test is required to enable test") +endif(${ENABLE_TEST} AND NOT ${GTest_FOUND}) + +if(NOT DEFINED ENABLE_COVERAGE) + set(ENABLE_COVERAGE FALSE) +endif(NOT DEFINED ENABLE_COVERAGE) + +if(${ENABLE_COVERAGE} AND NOT ${ENABLE_TEST}) + message(FATAL_ERROR "Test should be enabled to measure test coverage") +endif(${ENABLE_COVERAGE} AND NOT ${ENABLE_TEST}) + +add_library(nnfw_common INTERFACE) +if(ENABLE_STRICT_BUILD) + target_compile_options(nnfw_common INTERFACE -Werror -Wall -Wextra) +endif(ENABLE_STRICT_BUILD) + +# TODO Replace using default build option setting in cmake/buildtool/config/config_linux.cmake +# to link nnfw_coverage on each module which want to check coverage +add_library(nnfw_coverage INTERFACE) +if(ENABLE_COVERAGE) + target_compile_options(nnfw_coverage INTERFACE -g -O1 -fprofile-arcs -ftest-coverage) + target_link_libraries(nncc_coverage INTERFACE gcov) +endif(ENABLE_COVERAGE) + nnfw_include(ExtendCMakeFunction) set(NNFW_SOURCE_ROOT "${CMAKE_SOURCE_DIR}/../..") diff --git a/infra/nnfw/cmake/CfgOptionFlags.cmake b/infra/nnfw/cmake/CfgOptionFlags.cmake index c95cad7..4cc3c94 100644 --- a/infra/nnfw/cmake/CfgOptionFlags.cmake +++ b/infra/nnfw/cmake/CfgOptionFlags.cmake @@ -57,3 +57,4 @@ option(BUILD_BOOST "Build boost source" OFF) # GTest support # option(BUILD_GTEST "Download and build Google Test" ON) +option(ENABLE_STRICT_BUILD "Treat warning as error" ON)