cmake sanitizer support

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2024-03-20 19:55:03 -07:00
parent 784c3b7531
commit c42a500f6d
1 changed files with 8 additions and 2 deletions

View File

@ -30,6 +30,8 @@ project(STA VERSION 2.5.0
option(USE_CUDD "Use CUDD BDD package")
option(CUDD_DIR "CUDD BDD package directory")
option(USE_TCL_READLINE "Use TCL readliine package")
option(USE_SANITIZE "Compile with santize address enabled")
# Turn on to debug compiler args.
set(CMAKE_VERBOSE_MAKEFILE OFF)
@ -333,8 +335,6 @@ add_custom_command(OUTPUT ${STA_TCL_INIT}
# Do not use REQUIRED because it also requires TK, which is not used by OpenSTA.
find_package(TCL)
option(USE_TCL_READLINE "Use TCL readliine package")
set(TCL_READLINE 0)
# check for tclReadline
if (USE_TCL_READLINE)
@ -539,6 +539,12 @@ target_include_directories(OpenSTA
# common to gcc/clang
set(CXX_FLAGS -Wall -Wextra -pedantic -Wcast-qual -Wredundant-decls -Wformat-security)
if(USE_SANITIZE)
message(STATUS "Sanitize: ${USE_SANITIZE}")
set(CXX_FLAGS "${CXX_FLAGS};-fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
endif()
target_compile_options(OpenSTA
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:${CXX_FLAGS}>