Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ If you want to build as static library (default is shared), you can pass the arg
| BUILD_SHARED_LIBS | Enables/disables shared library. Default is ON. |
| BUILD_EXAMPLES_SRC | Enables/disables to build examples source codes. Default is ON. |
| BUILD_TESTS_SRC | Enables/disables to build test source codes. Default is ON. |
| ENABLE_ASAN | Enables/disables to build with ASAN support. Default is OFF. |

An example:
```
Expand Down
23 changes: 23 additions & 0 deletions concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce C++11 standard
set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(PROJECT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/WorkerQueue.cpp)

option(ENABLE_ASAN "Enable AddressSanitizer" OFF)

add_library(${LIBRARY_NAME} ${PROJECT_SOURCES})
add_library(WorkerQueue::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME})

Expand Down Expand Up @@ -43,6 +45,27 @@ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION "Cross platform asynchronous worker queue based on modern C++")
set(CPACK_PACKAGE_MAINTAINER "kadirlua")

# =========================================================
# ASAN
# =========================================================

if(ENABLE_ASAN)
message(STATUS "AddressSanitizer enabled")

if(MSVC)
# Apply to the library AND anyone linking to it
target_compile_options(${LIBRARY_NAME} PUBLIC /fsanitize=address /Zi)

# /INFERASANLIBS tells the linker to find the correct ASAN runtime (static or dll)
# /INCREMENTAL:NO is mandatory for ASAN
target_link_options(${LIBRARY_NAME} PUBLIC /INFERASANLIBS /INCREMENTAL:NO /DEBUG)

elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(${LIBRARY_NAME} PUBLIC -fsanitize=address -fno-omit-frame-pointer)
target_link_options(${LIBRARY_NAME} PUBLIC -fsanitize=address)
endif()
endif()

# =========================================================
# Version header generation
# =========================================================
Expand Down
Loading