diff options
author | Gaolingx <947770192@qq.com> | 2025-05-07 22:04:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-07 17:04:39 +0300 |
commit | 17c6fc6b7303915e0fd74bee53c4de8d21746d52 (patch) | |
tree | cd7e97f725c46f1730664fab3d9630a9271cc632 | |
parent | 8a5c0410e127bd7d5221dc1d7354b1edff2385c0 (diff) |
fix some MSVC build problem. (#392)
* cmake: force MSVC compiler charset to utf-8
* build: apply MSVC /bigobj option to c/cpp files only
* Update CMakeLists.txt
-rw-r--r-- | CMakeLists.txt | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 10049391..3e9c3cc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,11 +54,11 @@ if (WIN32) endif() # force MSVC compiler charset to utf-8 -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - add_compile_options("$<$<COMPILE_LANGUAGE:C>:/source-charset:utf-8>") - add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/source-charset:utf-8>") - add_compile_options("$<$<COMPILE_LANGUAGE:C>:/execution-charset:utf-8>") - add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/execution-charset:utf-8>") +if (MSVC) + add_compile_options("$<$<COMPILE_LANGUAGE:C>:/utf-8>") + add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/utf-8>") + add_compile_options("$<$<COMPILE_LANGUAGE:C>:/bigobj>") + add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>") endif() # @@ -123,6 +123,29 @@ llama_option_depr(WARNING LLAMA_SYCL GGML_SYCL) llama_option_depr(WARNING LLAMA_SYCL_F16 GGML_SYCL_F16) llama_option_depr(WARNING LLAMA_CANN GGML_CANN) +if (NOT MSVC) + if (LLAMA_SANITIZE_THREAD) + message(STATUS "Using -fsanitize=thread") + + add_compile_options(-fsanitize=thread) + link_libraries (-fsanitize=thread) + endif() + + if (LLAMA_SANITIZE_ADDRESS) + message(STATUS "Using -fsanitize=address") + + add_compile_options(-fsanitize=address -fno-omit-frame-pointer) + link_libraries (-fsanitize=address) + endif() + + if (LLAMA_SANITIZE_UNDEFINED) + message(STATUS "Using -fsanitize=undefined") + + add_compile_options(-fsanitize=undefined) + link_libraries (-fsanitize=undefined) + endif() +endif() + # # build the library # @@ -131,6 +154,11 @@ if (NOT TARGET ggml) add_subdirectory(ggml) # ... otherwise assume ggml is added by a parent CMakeLists.txt endif() + +# +# build the library +# + add_subdirectory(src) # |