@@ -20,11 +20,17 @@ include(GNUInstallDirs)
2020set_property (GLOBAL PROPERTY TARGET_MESSAGES OFF )
2121
2222if (NOT CMAKE_BUILD_TYPE )
23- set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('Debug' or 'Release', default is 'Debug')" FORCE )
23+ set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('DebugSan' or ' Debug' or 'Release', default is 'Debug')" FORCE )
2424endif ()
25- if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
25+
26+ if (CMAKE_BUILD_TYPE STREQUAL "DebugSan" )
27+ message (STATUS "Selected Debug Build with sanitizers" )
28+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -g -fno-omit-frame-pointer -fsanitize=address,undefined" )
29+ elseif (CMAKE_BUILD_TYPE STREQUAL "Debug" )
30+ message (STATUS "Selected Debug Build" )
2631 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -g" )
2732else ()
33+ message (STATUS "Selected Release Build" )
2834 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fvisibility-inlines-hidden -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -march=native" )
2935endif ()
3036
@@ -43,7 +49,6 @@ file(STRINGS ${PHASAR_SRC_DIR}/include/phasar/Config/Version.h VERSION_NUMBER_FI
4349string (REPLACE " " ";" VERSION_NUMBER_FILE ${VERSION_NUMBER_FILE} )
4450list (GET VERSION_NUMBER_FILE 2 VERSION_NUMBER_PHASAR)
4551
46-
4752include ("phasar_macros" )
4853
4954option (PHASAR_BUILD_UNITTESTS "Build all tests (default is ON)" ON )
@@ -52,6 +57,8 @@ option(PHASAR_BUILD_OPENSSL_TS_UNITTESTS "Build OPENSSL typestate tests (require
5257
5358option (PHASAR_BUILD_IR "Build IR test code (default is ON)" ON )
5459
60+ option (PHASAR_ENABLE_CLANG_TIDY_DURING_BUILD "Run clang-tidy during build (default is OFF)" OFF )
61+
5562option (PHASAR_BUILD_DOC "Build documentation" OFF )
5663
5764option (PHASAR_DEBUG_LIBDEPS "Debug internal library dependencies (private linkage)" OFF )
@@ -96,12 +103,10 @@ endif()
96103configure_file (config.h.in config.h @ONLY )
97104include_directories (${CMAKE_CURRENT_BINARY_DIR} )
98105
99-
100106include_directories (
101107 ${PHASAR_SRC_DIR} /include
102108)
103109
104-
105110set (PHASAR_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} /phasar)
106111
107112set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX} /${PHASAR_INSTALL_LIBDIR} )
@@ -122,6 +127,9 @@ find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log
122127#find_package(Boost 1.72.0 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
123128include_directories (${Boost_INCLUDE_DIRS} )
124129
130+ # Disable clang-tidy for the external projects
131+ set (CMAKE_CXX_CLANG_TIDY "" )
132+
125133# We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here
126134# The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator
127135# is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as
@@ -237,8 +245,17 @@ endif()
237245add_subdirectory (external/WALi-OpenNWA )
238246include_directories (external/WALi-OpenNWA/Source/wali/include )
239247
248+ # Set up clang-tidy to run during PhASAR's compilation to indicate code smells
249+ if (PHASAR_ENABLE_CLANG_TIDY_DURING_BUILD)
250+ message (STATUS "Enabled clang-tidy during build" )
251+ set (CMAKE_CXX_CLANG_TIDY
252+ clang-tidy;
253+ -header-filter=include/phasar.*h$;
254+ # -warnings-as-errors=*;
255+ )
256+ endif ()
240257
241- # Add the Phasar subdirectories
258+ # Add PhASAR's subdirectories
242259add_subdirectory (include )
243260add_subdirectory (lib )
244261
0 commit comments