build: Add -Werror by default
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
This commit is contained in:
parent
1170781f9a
commit
0c15e18f94
|
|
@ -32,6 +32,7 @@ option(CUDD_DIR "CUDD BDD package directory")
|
|||
option(USE_TCL_READLINE "Use TCL readline package" ON)
|
||||
option(ENABLE_TSAN "Compile with thread santizer enabled" OFF)
|
||||
option(ENABLE_ASAN "Compile with address santizer enabled" OFF)
|
||||
option(ALLOW_WARNINGS "Allow compiler warnings without failing the build" OFF)
|
||||
|
||||
# Turn on to debug compiler args.
|
||||
set(CMAKE_VERBOSE_MAKEFILE OFF)
|
||||
|
|
@ -594,6 +595,18 @@ endif()
|
|||
# common to gcc/clang
|
||||
set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls
|
||||
-Wformat-security -Werror=misleading-indentation -Wundef)
|
||||
if(NOT ALLOW_WARNINGS)
|
||||
list(APPEND CXX_FLAGS -Werror)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(STA_WARNING_FLAGS ${CXX_FLAGS} -Wno-format-zero-length)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(STA_WARNING_FLAGS ${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments)
|
||||
else()
|
||||
set(STA_WARNING_FLAGS ${CXX_FLAGS})
|
||||
endif()
|
||||
|
||||
if(ENABLE_TSAN)
|
||||
message(STATUS "Thread sanitizer: ${ENABLE_TSAN}")
|
||||
|
|
@ -607,12 +620,12 @@ if(ENABLE_ASAN)
|
|||
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
|
||||
endif()
|
||||
|
||||
target_compile_options(OpenSTA
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:GNU>:${CXX_FLAGS} -Wno-format-zero-length>
|
||||
$<$<CXX_COMPILER_ID:Clang>:${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments>
|
||||
$<$<CXX_COMPILER_ID:AppleClang>:${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments>
|
||||
add_library(OpenSTAWarnings INTERFACE)
|
||||
target_compile_options(OpenSTAWarnings
|
||||
INTERFACE
|
||||
${STA_WARNING_FLAGS}
|
||||
)
|
||||
target_link_libraries(OpenSTA OpenSTAWarnings)
|
||||
|
||||
# Disable compiler specific extensions like gnu++11.
|
||||
set_target_properties(OpenSTA PROPERTIES CXX_EXTENSIONS OFF)
|
||||
|
|
|
|||
|
|
@ -1467,15 +1467,14 @@ TEST_F(ArcDcalcResultTest, CopyResult) {
|
|||
EXPECT_FLOAT_EQ(delayAsFloat(copy.loadSlew(1)), 6e-12f);
|
||||
}
|
||||
|
||||
// Test ArcDcalcArg assignment
|
||||
TEST_F(ArcDcalcArgTest, Assignment) {
|
||||
// Test ArcDcalcArg copy construction with alternate values
|
||||
TEST_F(ArcDcalcArgTest, CopyConstructionAltValues) {
|
||||
ArcDcalcArg arg;
|
||||
arg.setLoadCap(3.5e-12f);
|
||||
arg.setInputDelay(1.5e-9f);
|
||||
arg.setInSlew(200e-12f);
|
||||
|
||||
ArcDcalcArg other;
|
||||
other = arg;
|
||||
ArcDcalcArg other(arg);
|
||||
EXPECT_FLOAT_EQ(other.loadCap(), 3.5e-12f);
|
||||
EXPECT_FLOAT_EQ(other.inputDelay(), 1.5e-9f);
|
||||
EXPECT_FLOAT_EQ(other.inSlewFlt(), 200e-12f);
|
||||
|
|
@ -2829,14 +2828,13 @@ TEST_F(ArcDcalcArgTest, InputDelayConstructorZero) {
|
|||
EXPECT_FLOAT_EQ(arg.inputDelay(), 0.0f);
|
||||
}
|
||||
|
||||
TEST_F(ArcDcalcArgTest, CopyAssignment) {
|
||||
TEST_F(ArcDcalcArgTest, CopyConstructionAltValues2) {
|
||||
ArcDcalcArg arg;
|
||||
arg.setLoadCap(3.0e-12f);
|
||||
arg.setInputDelay(2.0e-9f);
|
||||
arg.setInSlew(75e-12f);
|
||||
|
||||
ArcDcalcArg copy;
|
||||
copy = arg;
|
||||
ArcDcalcArg copy(arg);
|
||||
EXPECT_FLOAT_EQ(copy.loadCap(), 3.0e-12f);
|
||||
EXPECT_FLOAT_EQ(copy.inputDelay(), 2.0e-9f);
|
||||
EXPECT_FLOAT_EQ(copy.inSlewFlt(), 75e-12f);
|
||||
|
|
|
|||
Loading…
Reference in New Issue