Skip to content

Commit

Permalink
build: add MKLDNN_PRODUCT_BUILD_MODE option
Browse files Browse the repository at this point in the history
MKLDNN_PRODUCT_BUILD_MODE=ON (default): warnings are errors
MKLDNN_PRODUCT_BUILD_MODE=OFF         : warnings are warnings
  • Loading branch information
Roman Dubtsov committed Nov 23, 2018
1 parent 9689ce0 commit 3e6664c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
18 changes: 13 additions & 5 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ set(VTUNEROOT "" CACHE STRING
# Miscellaneous
# =============

option(BENCHDNN_USE_RDPMC
"enables rdpms counter to report precise cpu frequency in benchdnn.
CAUTION: may not work on all cpus (hence disabled by default)"
OFF) # disabled by default

# =============
# Developer flags
# =============

set(MKLDNN_USE_CLANG_SANITIZER "" CACHE STRING
"instructs build system to use a Clang sanitizer. Possible values:
Address: enables MemorySanitizer
Expand All @@ -136,8 +145,7 @@ set(MKLDNN_USE_CLANG_SANITIZER "" CACHE STRING
Undefined: enables UndefinedBehaviourSanitizer
This feature is experimental and is only available on Linux.")


option(BENCHDNN_USE_RDPMC
"enables rdpms counter to report precise cpu frequency in benchdnn.
CAUTION: may not work on all cpus (hence disabled by default)"
OFF) # disabled by default
option(MKLDNN_PRODUCT_BUILD_MODE
"Enables/disables product build mode. For example,
setting MKLDNN_PRODUCT_BUILD_MODE=OFF makes warnings non-fatal"
ON)
5 changes: 4 additions & 1 deletion cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ if(platform_cmake_included)
endif()
set(platform_cmake_included true)

include("cmake/utils.cmake")

add_definitions(-DMKLDNN_DLL -DMKLDNN_DLL_EXPORTS)

# UNIT8_MAX-like macros are a part of the C99 standard and not a part of the
Expand Down Expand Up @@ -58,7 +60,8 @@ if(MSVC)
append(CMAKE_CCXX_FLAGS "-Wno-pass-failed")
endif()
elseif(UNIX OR MINGW)
append(CMAKE_CCXX_FLAGS "-Wall -Werror -Wno-unknown-pragmas")
append(CMAKE_CCXX_FLAGS "-Wall -Wno-unknown-pragmas")
append_if_product(CMAKE_CCXX_FLAGS "-Werror")
append(CMAKE_CCXX_FLAGS "-fvisibility=internal")
append(CMAKE_C_FLAGS "-std=c99")
append(CMAKE_CXX_FLAGS "-std=c++11 -fvisibility-inlines-hidden")
Expand Down
16 changes: 16 additions & 0 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ if(utils_cmake_included)
endif()
set(utils_cmake_included true)

include("cmake/options.cmake")

# Register new executable/test
# name -- name of the executable
# srcs -- list of source, if many must be enclosed with ""
Expand All @@ -45,6 +47,20 @@ macro(append var value)
set(${var} "${${var}} ${value}")
endmacro()

# Append to a variable if building a product build (as opposed to a developer
# build that is detected via the MKLDNN_PRODUCT_BUILD_MODE option)
macro(append_if_product var value)
if(MKLDNN_PRODUCT_BUILD_MODE)
append(${var} "${value}")
endif()
endmacro()

if(MKLDNN_PRODUCT_BUILD_MODE)
message(STATUS "This is a product build")
else()
message(WARNING "This is a developer build")
endif()

# Set variable depending on condition:
# var = cond ? val_if_true : val_if_false
macro(set_ternary var condition val_if_true val_if_false)
Expand Down

0 comments on commit 3e6664c

Please sign in to comment.