diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a808c3..fbc79f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ option( ENABLE_TINT2CONF "Enable tint2conf build, a GTK+2 theme configurator for option( ENABLE_EXAMPLES "Install additional tin2rc examples" OFF ) option( ENABLE_RSVG "Rsvg support (launcher only)" ON ) option( ENABLE_SN "Startup notification support" ON ) +option( ENABLE_ASAN "Build tint2 with AddressSanitizer" OFF ) include( FindPkgConfig ) include( CheckLibraryExists ) @@ -99,12 +100,12 @@ if( ENABLE_TINT2CONF ) add_dependencies( tint2conf version ) endif( ENABLE_TINT2CONF ) -if( CMAKE_BUILD_TYPE MATCHES Debug) - SET(DBG_C_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic ") - SET(DBG_L_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic ") +if( ENABLE_ASAN ) + SET(ASAN_C_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic ") + SET(ASAN_L_FLAGS " -O0 -g3 -gdwarf-2 -fsanitize=address -fno-common -fno-omit-frame-pointer -rdynamic ") else() - SET(DBG_C_FLAGS "") - SET(DBG_L_FLAGS "") + SET(ASAN_C_FLAGS "") + SET(ASAN_L_FLAGS "") endif() set( MANDIR share/man CACHE PATH "Directory for man pages" ) @@ -140,8 +141,8 @@ endif( RT_LIBRARY ) target_link_libraries( tint2 m ) add_dependencies( tint2 version ) -set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -fno-strict-aliasing -pthread ${DBG_C_FLAGS}" ) -set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${DBG_L_FLAGS}" ) +set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -fno-strict-aliasing -pthread ${ASAN_C_FLAGS}" ) +set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${ASAN_L_FLAGS}" ) install( TARGETS tint2 DESTINATION bin ) install( FILES sample/tint2rc DESTINATION ${SYSCONFDIR}/xdg/tint2 )