From 8ee1d196568bb8ce84b4c0faac4d4c9f6353c78b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 17 Apr 2018 19:52:59 +0900 Subject: [PATCH] Introduce CMake functions for example build (#82) 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 --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index abbdb4e..0c7c24a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) -- 2.7.4