Skip to content

Commit c6e5221

Browse files
committed
CMake: build with ASAN conditionally
1 parent 5b2006c commit c6e5221

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
7070
cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF)
7171
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
7272
cmake_dependent_option(ENABLE_PCI_MEMORY "Enable detecting GPU memory size with libpci" OFF "LINUX OR BSD" OFF)
73-
cmake_dependent_option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embeded) yyjson library" OFF "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
7473

74+
option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embeded) yyjson library" OFF)
75+
option(ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF)
7576
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
7677
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
7778

@@ -116,7 +117,8 @@ if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
116117
endif()
117118

118119
set(FASTFETCH_FLAGS_DEBUG "-fno-omit-frame-pointer")
119-
if(NOT WIN32 AND NOT APPLE)
120+
if(ENABLE_ASAN)
121+
message(STATUS "Address sanitizer enabled (DEBUG only)")
120122
set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address")
121123
endif()
122124
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")

0 commit comments

Comments
 (0)