optimize CMakeLists.txt

This commit is contained in:
2024-09-09 08:00:44 +08:00
parent be611c26c8
commit 7ddc6aad72

View File

@@ -20,20 +20,9 @@ if (ENABLE_ASAN)
-fsanitize=undefined -fsanitize=undefined
-fno-omit-frame-pointer -fno-omit-frame-pointer
) )
add_link_options(
-fsanitize=address
-fsanitize=undefined
)
message("asan is on. if have any problems, disable it.") message("asan is on. if have any problems, disable it.")
endif () endif ()
if (WIN32)
add_link_options(
-static
)
endif ()
# For CURL # For CURL
set(BUILD_STATIC_LIBS ON) set(BUILD_STATIC_LIBS ON)
if (WIN32) if (WIN32)
@@ -61,4 +50,19 @@ FetchContent_MakeAvailable(cJSON curl)
add_executable(main main.c) add_executable(main main.c)
target_include_directories(main PUBLIC ${cJSON_SOURCE_DIR}) target_include_directories(main PUBLIC ${cJSON_SOURCE_DIR})
target_link_libraries(main cjson-static libcurl_static pthread) target_link_libraries(main cjson-static libcurl_static pthread)
if (ENABLE_ASAN)
target_link_options(
main BEFORE PUBLIC
-fsanitize=address
-fsanitize=undefined
)
endif ()
if (WIN32)
target_link_options(
main BEFORE PUBLIC
-static
)
endif ()