From 5ebb200de16b98f169e43c8903b3744554b6c409 Mon Sep 17 00:00:00 2001 From: idealvin Date: Tue, 18 Jul 2023 22:55:25 +0800 Subject: [PATCH] update xmake.lua & cmake file --- CMakeLists.txt | 8 +++++--- src/CMakeLists.txt | 4 ++++ src/xmake.lua | 5 +++++ xmake.lua | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b98e9e66..9d8bbd29e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,12 +33,12 @@ else() endif() -# build with libcurl (openssl & zlib also required) -option(WITH_LIBCURL "build with libcurl" OFF) - # build with openssl 1.1.0+ option(WITH_OPENSSL "build with openssl" OFF) +# build with libcurl (openssl & zlib also required) +option(WITH_LIBCURL "build with libcurl" OFF) + # build with libbacktrace option(WITH_BACKTRACE "build with libbacktrace" OFF) @@ -48,6 +48,8 @@ option(FPIC "build with -fPIC" OFF) # build all projects (libco, gen, test, unitest) option(BUILD_ALL "Build all projects" OFF) +option(DISABLE_HOOK "disable hooks for system APIs" OFF) + # specify the value of L1 cache line size, 64 by default set(CACHE_LINE_SIZE "64" CACHE STRING "set value of L1 cache line size") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d246bc6e..6b1c6a6cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,6 +63,10 @@ if(WITH_BACKTRACE) target_link_libraries(co PUBLIC backtrace) endif() +if(DISABLE_HOOK) + target_compile_definitions(co PRIVATE _CO_DISABLE_HOOK) +endif() + target_compile_features(co PUBLIC cxx_std_11) if(FPIC) diff --git a/src/xmake.lua b/src/xmake.lua index 523a6161e..bd5d27906 100644 --- a/src/xmake.lua +++ b/src/xmake.lua @@ -9,6 +9,7 @@ target("libco") add_options("with_openssl") add_options("with_libcurl") add_options("cache_line_size") + add_options("disable_hook") if is_plat("linux", "macosx") then add_options("with_backtrace") end @@ -26,6 +27,10 @@ target("libco") add_packages("openssl") end + if has_config("disable_hook") then + add_defines("_CO_DISABLE_HOOK") + end + if is_kind("shared") then set_symbols("debug", "hidden") add_defines("BUILDING_CO_SHARED") diff --git a/xmake.lua b/xmake.lua index 7513b51fa..760573412 100644 --- a/xmake.lua +++ b/xmake.lua @@ -64,6 +64,12 @@ option("fpic") add_cxflags("-fPIC") option_end() +option("disable_hook") + set_default(false) + set_showmenu(true) + set_description("disable system API hook") +option_end() + option("cache_line_size") set_default("64") set_showmenu(true)