Skip to content

Commit ccb7603

Browse files
fix find_package() & add option to disable asan (#366)
* 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 <[email protected]> * Update async_simple/CMakeLists.txt Co-authored-by: Chuanqi Xu <[email protected]> --------- Co-authored-by: Chuanqi Xu <[email protected]>
1 parent e1fdcf1 commit ccb7603

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
123123
#list(APPEND deplibs "-m64")
124124
endif()
125125
endif()
126-
127-
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
128-
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
129-
message("-- Use flag -fsanitize=address")
130-
list(APPEND CXX_FLAGS "-fsanitize=address")
126+
option(ASYNC_SIMPLE_ENABLE_ASAN "enable asan in debug when compiler is not msvc" ON)
127+
if (ASYNC_SIMPLE_ENABLE_ASAN)
128+
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
129+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
130+
message("-- Use flag -fsanitize=address")
131+
list(APPEND CXX_FLAGS "-fsanitize=address")
132+
endif()
131133
endif()
132134
endif()
133135

async_simple/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ if(UTHREAD)
2222
list(APPEND SRCS ${uthread_asm_src})
2323
endif()
2424

25+
26+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
27+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0.0")
28+
target_compile_options(async_simple_header_only INTERFACE "-fcoroutines")
29+
endif()
30+
endif()
2531
# If there is no Uthread, async_simple is a header only library
2632
if(UTHREAD)
2733
add_library(async_simple_static STATIC ${SRCS})

0 commit comments

Comments
 (0)