@@ -550,6 +550,17 @@ SET_TARGET_PROPERTIES(${LIBVNCSERVER_LIBRARIES}
550550 PROPERTIES SOVERSION "${VERSION_SO} " VERSION "${LibVNCServer_VERSION} " C_STANDARD 90
551551)
552552
553+ function (enable_debug_sanitizers target_name )
554+ if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU" )
555+ target_compile_options (${target_name} PRIVATE
556+ "$<$<CONFIG :Debug >:-fsanitize =address >"
557+ "$<$<CONFIG :Debug >:-fsanitize =undefined >"
558+ "$<$<CONFIG :Debug >:-fno -omit -frame -pointer >"
559+ )
560+ set_property (TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG " -fsanitize=address -fsanitize=undefined" )
561+ endif ()
562+ endfunction ()
563+
553564# EXAMPLES
554565set (LIBVNCSERVER_EXAMPLES
555566 backchannel
@@ -616,6 +627,13 @@ if(SDL2_FOUND)
616627 )
617628endif (SDL2_FOUND )
618629
630+ if (APPLE )
631+ set (LIBVNCCLIENT_EXAMPLES
632+ ${LIBVNCCLIENT_EXAMPLES}
633+ applehpdebug
634+ )
635+ endif ()
636+
619637if (GTK2_FOUND)
620638 include_directories (${GTK2_INCLUDE_DIRS} )
621639 set (LIBVNCCLIENT_EXAMPLES
@@ -641,6 +659,10 @@ if(FFMPEG_FOUND)
641659 )
642660endif (FFMPEG_FOUND )
643661
662+ if (APPLE AND WITH_LIBVNCCLIENT AND WITH_EXAMPLES)
663+ enable_debug_sanitizers (vncclient )
664+ endif ()
665+
644666if (WITH_EXAMPLES)
645667 if (WITH_LIBVNCSERVER)
646668 foreach (e ${LIBVNCSERVER_EXAMPLES} )
@@ -661,6 +683,10 @@ if(WITH_EXAMPLES)
661683 set_target_properties (client_examples_${e} PROPERTIES OUTPUT_NAME ${e} )
662684 set_target_properties (client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /examples/client )
663685 target_link_libraries (client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES} ${LIBSSHTUNNEL_LIBRARY} )
686+ if (APPLE AND e STREQUAL "applehpdebug" )
687+ target_link_libraries (client_examples_${e} "-framework Security" "-framework CoreFoundation" "-framework GSS" "-framework Kerberos" )
688+ enable_debug_sanitizers (client_examples_${e} )
689+ endif ()
664690 endforeach (e ${LIBVNCCLIENT_EXAMPLES} )
665691 endif (WITH_LIBVNCCLIENT )
666692
0 commit comments