@@ -83,11 +83,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake)
8383include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/common.cmake)
8484
8585# override ggml options
86- set (GGML_SANITIZE_THREAD ${LLAMA_SANITIZE_THREAD} )
87- set (GGML_SANITIZE_ADDRESS ${LLAMA_SANITIZE_ADDRESS} )
88- set (GGML_SANITIZE_UNDEFINED ${LLAMA_SANITIZE_UNDEFINED} )
89- set (GGML_ALL_WARNINGS ${LLAMA_ALL_WARNINGS} )
90- set (GGML_FATAL_WARNINGS ${LLAMA_FATAL_WARNINGS} )
86+ set (GGML_ALL_WARNINGS ${LLAMA_ALL_WARNINGS} )
87+ set (GGML_FATAL_WARNINGS ${LLAMA_FATAL_WARNINGS} )
9188
9289# change the default for these ggml options
9390if (NOT DEFINED GGML_LLAMAFILE)
@@ -117,16 +114,62 @@ llama_option_depr(WARNING LLAMA_SYCL GGML_SYCL)
117114llama_option_depr(WARNING LLAMA_SYCL_F16 GGML_SYCL_F16)
118115llama_option_depr(WARNING LLAMA_CANN GGML_CANN)
119116
117+ if (NOT MSVC )
118+ if (LLAMA_SANITIZE_THREAD)
119+ message (STATUS "Using -fsanitize=thread" )
120+
121+ add_compile_options (-fsanitize=thread)
122+ link_libraries (-fsanitize=thread)
123+ endif ()
124+
125+ if (LLAMA_SANITIZE_ADDRESS)
126+ message (STATUS "Using -fsanitize=address" )
127+
128+ add_compile_options (-fsanitize=address -fno-omit-frame-pointer)
129+ link_libraries (-fsanitize=address)
130+ endif ()
131+
132+ if (LLAMA_SANITIZE_UNDEFINED)
133+ message (STATUS "Using -fsanitize=undefined" )
134+
135+ add_compile_options (-fsanitize=undefined)
136+ link_libraries (-fsanitize=undefined)
137+ endif ()
138+ endif ()
139+
120140#
121- # build the library
141+ # 3rd-party
122142#
123143
124144if (NOT TARGET ggml)
125145 add_subdirectory (ggml)
126146 # ... otherwise assume ggml is added by a parent CMakeLists.txt
127147endif ()
148+
149+ #
150+ # build the library
151+ #
152+
128153add_subdirectory (src)
129154
155+ #
156+ # utils, programs, examples and tests
157+ #
158+
159+ if (LLAMA_BUILD_COMMON)
160+ add_subdirectory (common)
161+ endif ()
162+
163+ if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
164+ include (CTest)
165+ add_subdirectory (tests)
166+ endif ()
167+
168+ if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_EXAMPLES)
169+ add_subdirectory (examples)
170+ add_subdirectory (pocs)
171+ endif ()
172+
130173#
131174# install
132175#
@@ -200,21 +243,3 @@ configure_file(cmake/llama.pc.in
200243
201244install (FILES "${CMAKE_CURRENT_BINARY_DIR} /llama.pc"
202245 DESTINATION lib/pkgconfig)
203-
204- #
205- # utils, programs, examples and tests
206- #
207-
208- if (LLAMA_BUILD_COMMON)
209- add_subdirectory (common)
210- endif ()
211-
212- if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
213- include (CTest)
214- add_subdirectory (tests)
215- endif ()
216-
217- if (LLAMA_BUILD_COMMON AND LLAMA_BUILD_EXAMPLES)
218- add_subdirectory (examples)
219- add_subdirectory (pocs)
220- endif ()
0 commit comments