Skip to content

Commit

Permalink
fix find_package() & add option to disable asan (#366)
Browse files Browse the repository at this point in the history
* fix target

* add option to disable asan

* only add -fcoroutines options in gcc 10.x

* Update async_simple/CMakeLists.txt

Co-authored-by: Chuanqi Xu <yedeng.yd@linux.alibaba.com>

* Update async_simple/CMakeLists.txt

Co-authored-by: Chuanqi Xu <yedeng.yd@linux.alibaba.com>

---------

Co-authored-by: Chuanqi Xu <yedeng.yd@linux.alibaba.com>
  • Loading branch information
poor-circle and ChuanqiXu9 authored Jan 30, 2024
1 parent e1fdcf1 commit ccb7603
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
#list(APPEND deplibs "-m64")
endif()
endif()

if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Use flag -fsanitize=address")
list(APPEND CXX_FLAGS "-fsanitize=address")
option(ASYNC_SIMPLE_ENABLE_ASAN "enable asan in debug when compiler is not msvc" ON)
if (ASYNC_SIMPLE_ENABLE_ASAN)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Use flag -fsanitize=address")
list(APPEND CXX_FLAGS "-fsanitize=address")
endif()
endif()
endif()

Expand Down
6 changes: 6 additions & 0 deletions async_simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ if(UTHREAD)
list(APPEND SRCS ${uthread_asm_src})
endif()


if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0.0")
target_compile_options(async_simple_header_only INTERFACE "-fcoroutines")
endif()
endif()
# If there is no Uthread, async_simple is a header only library
if(UTHREAD)
add_library(async_simple_static STATIC ${SRCS})
Expand Down

0 comments on commit ccb7603

Please sign in to comment.