Introduce 'nncc_coverage' interface target (#335)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 14 Jun 2018 09:20:05 +0000 (18:20 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 14 Jun 2018 09:20:05 +0000 (18:20 +0900)
This commit introduces 'nncc_coverage' interface target which propagates
compilation options for coverage build, and use it to simplify add_nncc_library
implementation.

It is possible to eliminate unnecessary link statement (to libc) inside
add_nncc_library with this commit.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
CMakeLists.txt

index 0fdadb0..1e5135a 100644 (file)
@@ -51,17 +51,20 @@ option(ENABLE_EXAMPLE_BUILD "Build examples" ON)
 option(ENABLE_CONTRIB_BUILD "Build incubating projects under contrib/" ON)
 
 ###
+### Target
+###
+add_library(nncc_coverage INTERFACE)
+if(ENABLE_COVERAGE)
+  target_compile_options(nncc_coverage INTERFACE -g -O0 -fprofile-arcs -ftest-coverage)
+  target_link_libraries(nncc_coverage INTERFACE gcov)
+endif(ENABLE_COVERAGE)
+
+###
 ### Function
 ###
 function(add_nncc_library)
   add_library(${ARGV})
-  if(ENABLE_COVERAGE)
-    target_compile_options(${ARGV0} PUBLIC -g -O0 -fprofile-arcs -ftest-coverage)
-    target_link_libraries(${ARGV0} PUBLIC gcov)
-  else()
-    # NOTE This line disallows target_link_libraries call with plain signature
-    target_link_libraries(${ARGV0} PUBLIC c)
-  endif(ENABLE_COVERAGE)
+  target_link_libraries(${ARGV0} PUBLIC nncc_coverage)
 endfunction(add_nncc_library)
 
 function(add_nncc_example_executable)