diff options
| -rw-r--r-- | CMakeLists.txt | 4 | ||||
| -rw-r--r-- | cube/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | icd/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | vulkaninfo/CMakeLists.txt | 5 |
4 files changed, 28 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bc37cb7..16fb6995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,10 @@ option(BUILD_ICD "Build icd" ON) # Require the user to ask that it be installed if they really want it. option(INSTALL_ICD "Install icd" OFF) +if (UNIX AND NOT APPLE) # i.e. Linux + option(ENABLE_ADDRESS_SANITIZER "Use addres sanitization" OFF) +endif() + if(WIN32) # Optional: Allow specify the exact version used in the vulkaninfo executable # Format is major.minor.patch.build diff --git a/cube/CMakeLists.txt b/cube/CMakeLists.txt index a2f026e7..3c37189e 100644 --- a/cube/CMakeLists.txt +++ b/cube/CMakeLists.txt @@ -239,6 +239,11 @@ elseif(NOT WIN32) if (NEED_RT) target_link_libraries(vkcube rt) endif() + + if (ENABLE_ADDRESS_SANITIZER) + target_compile_options(vkcube PUBLIC -fsanitize=address) + target_link_options(vkcube PUBLIC -fsanitize=address) + endif () else() if(CMAKE_CL_64) set(LIB_DIR "Win64") @@ -284,6 +289,11 @@ elseif(NOT WIN32) ${OPTIONAL_WAYLAND_DATA_FILES}) target_link_libraries(vkcubepp Vulkan::Vulkan) target_compile_definitions(vkcubepp PUBLIC ${CUBE_PLATFORM}) + + if (ENABLE_ADDRESS_SANITIZER) + target_compile_options(vkcubepp PUBLIC -fsanitize=address) + target_link_options(vkcubepp PUBLIC -fsanitize=address) + endif () else() if(CMAKE_CL_64) set(LIB_DIR "Win64") @@ -342,5 +352,10 @@ if(UNIX AND NOT APPLE) # i.e. Linux target_link_libraries(vkcube-wayland rt) endif() install(TARGETS vkcube-wayland RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (ENABLE_ADDRESS_SANITIZER) + target_compile_options(vkcube-wayland PUBLIC -fsanitize=address) + target_link_options(vkcube-wayland PUBLIC -fsanitize=address) + endif () endif() endif() diff --git a/icd/CMakeLists.txt b/icd/CMakeLists.txt index 41772f70..950300de 100644 --- a/icd/CMakeLists.txt +++ b/icd/CMakeLists.txt @@ -130,6 +130,10 @@ else() if((UNIX AND NOT APPLE) AND INSTALL_ICD) # i.e. Linux install(TARGETS VkICD_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + if (ENABLE_ADDRESS_SANITIZER) + target_compile_options(VkICD_${target} PUBLIC -fsanitize=address) + target_link_options(VkICD_${target} PUBLIC -fsanitize=address) + endif () endmacro() endif() diff --git a/vulkaninfo/CMakeLists.txt b/vulkaninfo/CMakeLists.txt index d23dcf89..d2d66dff 100644 --- a/vulkaninfo/CMakeLists.txt +++ b/vulkaninfo/CMakeLists.txt @@ -93,6 +93,11 @@ if(UNIX AND NOT APPLE) # i.e. Linux target_link_libraries(vulkaninfo PkgConfig::DirectFB) target_compile_definitions(vulkaninfo PRIVATE -DVK_USE_PLATFORM_DIRECTFB_EXT -DVK_NO_PROTOTYPES) endif() + + if (ENABLE_ADDRESS_SANITIZER) + target_compile_options(vulkaninfo PUBLIC -fsanitize=address) + target_link_options(vulkaninfo PUBLIC -fsanitize=address) + endif () endif() if(APPLE) |
