Introduce CMake functions for example build (#82)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 17 Apr 2018 10:52:59 +0000 (19:52 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 17 Apr 2018 10:52:59 +0000 (19:52 +0900)
This commit introduces the following CMake functions for example build:
 - add_nncc_example_executable
 - nncc_example_link_libraries

These functions allow us to easily disable examples when measuring test
coverage.

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

index abbdb4e..0c7c24a 100644 (file)
@@ -32,6 +32,8 @@ 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})
 
+option(ENABLE_EXAMPLE_BUILD "Build examples" ON)
+
 ###
 ### Function
 ###
@@ -43,6 +45,18 @@ function(add_nncc_library)
   endif(ENABLE_COVERAGE)
 endfunction(add_nncc_library)
 
+function(add_nncc_example_executable)
+  if(ENABLE_EXAMPLE_BUILD)
+    add_executable(${ARGV})
+  endif(ENABLE_EXAMPLE_BUILD)
+endfunction(add_nncc_example_executable)
+
+function(nncc_example_link_libraries)
+  if(ENABLE_EXAMPLE_BUILD)
+    target_link_libraries(${ARGV})
+  endif(ENABLE_EXAMPLE_BUILD)
+endfunction(nncc_example_link_libraries)
+
 function(add_nncc_test)
   if(ENABLE_TEST)
     add_executable(${ARGV})