Introduce 'ENABLE_STRICT_BUILD' option (#462)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 3 Jul 2018 02:01:09 +0000 (11:01 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 3 Jul 2018 02:01:09 +0000 (11:01 +0900)
* Introduce 'ENABLE_STRICT_BUILD' option

This commit introduces 'ENABLE_STRICR_BUILD' option which allows us to
detect compiler warnings as error.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
* Fix a typo (wraning -> warning)

CMakeLists.txt

index b76a50f..94eb03b 100644 (file)
@@ -49,10 +49,17 @@ endif(${ENABLE_COVERAGE} AND NOT ${ENABLE_TEST})
 
 option(ENABLE_EXAMPLE_BUILD "Build examples" ON)
 option(ENABLE_CONTRIB_BUILD "Build incubating projects under contrib/" ON)
+option(ENABLE_STRICT_BUILD "Treat warning as error" OFF)
 
 ###
 ### Target
 ###
+add_library(nncc_common INTERFACE)
+if(ENABLE_STRICT_BUILD)
+  # TODO Remove -Wno-reoder
+  target_compile_options(nncc_common INTERFACE -Werror -Wall -Wextra -Wno-reorder)
+endif(ENABLE_STRICT_BUILD)
+
 add_library(nncc_coverage INTERFACE)
 if(ENABLE_COVERAGE)
   target_compile_options(nncc_coverage INTERFACE -g -O0 -fprofile-arcs -ftest-coverage)
@@ -64,6 +71,7 @@ endif(ENABLE_COVERAGE)
 ###
 function(add_nncc_library)
   add_library(${ARGV})
+  target_link_libraries(${ARGV0} PRIVATE nncc_common)
   target_link_libraries(${ARGV0} PUBLIC nncc_coverage)
 endfunction(add_nncc_library)