diff options
author | 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com> | 2019-08-05 16:53:58 +0900 |
---|---|---|
committer | GitHub Enterprise <noreply-CODE@samsung.com> | 2019-08-05 16:53:58 +0900 |
commit | b953b190a7c1a5f06a6fbef06fa12601c2b831ec (patch) | |
tree | 91582df92dac6fb8bf266a9c3e108b68293d0ad3 /infra | |
parent | 1e6adff6915045f231185df8d77a79169abd4407 (diff) | |
download | nnfw-b953b190a7c1a5f06a6fbef06fa12601c2b831ec.tar.gz nnfw-b953b190a7c1a5f06a6fbef06fa12601c2b831ec.tar.bz2 nnfw-b953b190a7c1a5f06a6fbef06fa12601c2b831ec.zip |
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 <hseok82.oh@samsung.com>
Diffstat (limited to 'infra')
-rw-r--r-- | infra/nnfw/CMakeLists.txt | 30 | ||||
-rw-r--r-- | infra/nnfw/cmake/CfgOptionFlags.cmake | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/infra/nnfw/CMakeLists.txt b/infra/nnfw/CMakeLists.txt index 2b7661672..1a93d032d 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 c95cad742..4cc3c9478 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) |