Unverified Commit 803c3b36 authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

both command line arg and env var NGRAPH_WARNINGS_AS_ERRORS (#558)

* add support for both command line arg and env var to set NGRAPH_WARINGS_AS_ERRORS'
parent aeee2039
......@@ -60,6 +60,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set directory where the custom finders live
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(var_functions)
#-----------------------------------------------------------------------------------------------
# Installation logic...
#-----------------------------------------------------------------------------------------------
......@@ -97,11 +99,11 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
if(DEFINED ENV{NGRAPH_WARNINGS_AS_ERRORS})
if($ENV{NGRAPH_WARNINGS_AS_ERRORS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
message(STATUS "Warnings as errors")
endif()
ngraph_var(NGRAPH_WARNINGS_AS_ERRORS DEFAULT "OFF")
if ("${NGRAPH_WARNINGS_AS_ERRORS}" MATCHES "^(ON|TRUE)$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
message(STATUS "Warnings as errors")
endif()
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
......
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ******************************************************************************
# function check existence of cmake and environment variable and read their value
# If the variable is not defined then the supplied default value used
# example:
# ngraph_var(NGRAPH_VARIABLE_NAME DEFAULT "OFF")
# checks if variable NGRAPH_VARIABLE_NAME was passed in via the cmake command line
# if found then passed in value is used
# else checks for the existence of the environment variable NGRAPH_VARIABLE_NAME
# if found it's value is used
# if none of the above then the default value is used
function(NGRAPH_VAR)
set(options)
set(oneValueArgs DEFAULT)
set(multiValueArgs)
cmake_parse_arguments(NGRAPH_VAR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT DEFINED ${NGRAPH_VAR_UNPARSED_ARGUMENTS})
set(${NGRAPH_VAR_UNPARSED_ARGUMENTS} ${NGRAPH_VAR_DEFAULT} PARENT_SCOPE)
if(DEFINED ENV{${NGRAPH_VAR_UNPARSED_ARGUMENTS}})
set(${NGRAPH_VAR_UNPARSED_ARGUMENTS} $ENV{${NGRAPH_VAR_UNPARSED_ARGUMENTS}} PARENT_SCOPE)
endif()
endif()
endfunction()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment