Skip to content

Commit 17c6fc6

Browse files
authored
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
1 parent 8a5c041 commit 17c6fc6

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

CMakeLists.txt

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ if (WIN32)
5454
endif()
5555

5656
# force MSVC compiler charset to utf-8
57-
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
58-
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/source-charset:utf-8>")
59-
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/source-charset:utf-8>")
60-
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/execution-charset:utf-8>")
61-
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/execution-charset:utf-8>")
57+
if (MSVC)
58+
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/utf-8>")
59+
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/utf-8>")
60+
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/bigobj>")
61+
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/bigobj>")
6262
endif()
6363

6464
#
@@ -123,6 +123,29 @@ llama_option_depr(WARNING LLAMA_SYCL GGML_SYCL)
123123
llama_option_depr(WARNING LLAMA_SYCL_F16 GGML_SYCL_F16)
124124
llama_option_depr(WARNING LLAMA_CANN GGML_CANN)
125125

126+
if (NOT MSVC)
127+
if (LLAMA_SANITIZE_THREAD)
128+
message(STATUS "Using -fsanitize=thread")
129+
130+
add_compile_options(-fsanitize=thread)
131+
link_libraries (-fsanitize=thread)
132+
endif()
133+
134+
if (LLAMA_SANITIZE_ADDRESS)
135+
message(STATUS "Using -fsanitize=address")
136+
137+
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
138+
link_libraries (-fsanitize=address)
139+
endif()
140+
141+
if (LLAMA_SANITIZE_UNDEFINED)
142+
message(STATUS "Using -fsanitize=undefined")
143+
144+
add_compile_options(-fsanitize=undefined)
145+
link_libraries (-fsanitize=undefined)
146+
endif()
147+
endif()
148+
126149
#
127150
# build the library
128151
#
@@ -131,6 +154,11 @@ if (NOT TARGET ggml)
131154
add_subdirectory(ggml)
132155
# ... otherwise assume ggml is added by a parent CMakeLists.txt
133156
endif()
157+
158+
#
159+
# build the library
160+
#
161+
134162
add_subdirectory(src)
135163

136164
#

0 commit comments

Comments
 (0)