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(USE_TCL_READLINE "Use TCL readline package" ON)
|
||||||
option(ENABLE_TSAN "Compile with thread santizer enabled" OFF)
|
option(ENABLE_TSAN "Compile with thread santizer enabled" OFF)
|
||||||
option(ENABLE_ASAN "Compile with address 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.
|
# Turn on to debug compiler args.
|
||||||
set(CMAKE_VERBOSE_MAKEFILE OFF)
|
set(CMAKE_VERBOSE_MAKEFILE OFF)
|
||||||
|
|
@ -594,6 +595,18 @@ endif()
|
||||||
# common to gcc/clang
|
# common to gcc/clang
|
||||||
set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls
|
set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls
|
||||||
-Wformat-security -Werror=misleading-indentation -Wundef)
|
-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)
|
if(ENABLE_TSAN)
|
||||||
message(STATUS "Thread sanitizer: ${ENABLE_TSAN}")
|
message(STATUS "Thread sanitizer: ${ENABLE_TSAN}")
|
||||||
|
|
@ -607,12 +620,12 @@ if(ENABLE_ASAN)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
|
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_options(OpenSTA
|
add_library(OpenSTAWarnings INTERFACE)
|
||||||
PRIVATE
|
target_compile_options(OpenSTAWarnings
|
||||||
$<$<CXX_COMPILER_ID:GNU>:${CXX_FLAGS} -Wno-format-zero-length>
|
INTERFACE
|
||||||
$<$<CXX_COMPILER_ID:Clang>:${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments>
|
${STA_WARNING_FLAGS}
|
||||||
$<$<CXX_COMPILER_ID:AppleClang>:${CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments>
|
|
||||||
)
|
)
|
||||||
|
target_link_libraries(OpenSTA OpenSTAWarnings)
|
||||||
|
|
||||||
# Disable compiler specific extensions like gnu++11.
|
# Disable compiler specific extensions like gnu++11.
|
||||||
set_target_properties(OpenSTA PROPERTIES CXX_EXTENSIONS OFF)
|
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);
|
EXPECT_FLOAT_EQ(delayAsFloat(copy.loadSlew(1)), 6e-12f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test ArcDcalcArg assignment
|
// Test ArcDcalcArg copy construction with alternate values
|
||||||
TEST_F(ArcDcalcArgTest, Assignment) {
|
TEST_F(ArcDcalcArgTest, CopyConstructionAltValues) {
|
||||||
ArcDcalcArg arg;
|
ArcDcalcArg arg;
|
||||||
arg.setLoadCap(3.5e-12f);
|
arg.setLoadCap(3.5e-12f);
|
||||||
arg.setInputDelay(1.5e-9f);
|
arg.setInputDelay(1.5e-9f);
|
||||||
arg.setInSlew(200e-12f);
|
arg.setInSlew(200e-12f);
|
||||||
|
|
||||||
ArcDcalcArg other;
|
ArcDcalcArg other(arg);
|
||||||
other = arg;
|
|
||||||
EXPECT_FLOAT_EQ(other.loadCap(), 3.5e-12f);
|
EXPECT_FLOAT_EQ(other.loadCap(), 3.5e-12f);
|
||||||
EXPECT_FLOAT_EQ(other.inputDelay(), 1.5e-9f);
|
EXPECT_FLOAT_EQ(other.inputDelay(), 1.5e-9f);
|
||||||
EXPECT_FLOAT_EQ(other.inSlewFlt(), 200e-12f);
|
EXPECT_FLOAT_EQ(other.inSlewFlt(), 200e-12f);
|
||||||
|
|
@ -2829,14 +2828,13 @@ TEST_F(ArcDcalcArgTest, InputDelayConstructorZero) {
|
||||||
EXPECT_FLOAT_EQ(arg.inputDelay(), 0.0f);
|
EXPECT_FLOAT_EQ(arg.inputDelay(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ArcDcalcArgTest, CopyAssignment) {
|
TEST_F(ArcDcalcArgTest, CopyConstructionAltValues2) {
|
||||||
ArcDcalcArg arg;
|
ArcDcalcArg arg;
|
||||||
arg.setLoadCap(3.0e-12f);
|
arg.setLoadCap(3.0e-12f);
|
||||||
arg.setInputDelay(2.0e-9f);
|
arg.setInputDelay(2.0e-9f);
|
||||||
arg.setInSlew(75e-12f);
|
arg.setInSlew(75e-12f);
|
||||||
|
|
||||||
ArcDcalcArg copy;
|
ArcDcalcArg copy(arg);
|
||||||
copy = arg;
|
|
||||||
EXPECT_FLOAT_EQ(copy.loadCap(), 3.0e-12f);
|
EXPECT_FLOAT_EQ(copy.loadCap(), 3.0e-12f);
|
||||||
EXPECT_FLOAT_EQ(copy.inputDelay(), 2.0e-9f);
|
EXPECT_FLOAT_EQ(copy.inputDelay(), 2.0e-9f);
|
||||||
EXPECT_FLOAT_EQ(copy.inSlewFlt(), 75e-12f);
|
EXPECT_FLOAT_EQ(copy.inSlewFlt(), 75e-12f);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue