Skip to content

Commit e908ace

Browse files
committed
cmake : enable warnings in llama
ggml-ci
1 parent 47f931c commit e908ace

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ option(LLAMA_CURL "llama: use libcurl to download model from an URL" OFF)
8282

8383
# Required for relocatable CMake package
8484
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake)
85+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
8586

8687
# override ggml options
8788
set(GGML_SANITIZE_THREAD ${LLAMA_SANITIZE_THREAD})

cmake/common.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function(llama_add_compile_flags)
2+
if (LLAMA_ALL_WARNINGS)
3+
if (NOT MSVC)
4+
list(APPEND C_FLAGS -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes
5+
-Werror=implicit-int -Werror=implicit-function-declaration)
6+
7+
list(APPEND CXX_FLAGS -Wmissing-declarations -Wmissing-noreturn)
8+
9+
list(APPEND WARNING_FLAGS -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function)
10+
11+
list(APPEND C_FLAGS ${WARNING_FLAGS})
12+
list(APPEND CXX_FLAGS ${WARNING_FLAGS})
13+
14+
get_flags(${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})
15+
16+
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${C_FLAGS};${GF_C_FLAGS}>"
17+
"$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS};${GF_CXX_FLAGS}>")
18+
else()
19+
# todo : msvc
20+
set(C_FLAGS "" PARENT_SCOPE)
21+
set(CXX_FLAGS "" PARENT_SCOPE)
22+
endif()
23+
endif()
24+
endfunction()

common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
find_package(Threads REQUIRED)
44

5+
llama_add_compile_flags()
6+
57
# Build info header
68
#
79

examples/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ find_package(Threads REQUIRED)
66

77
# ...
88

9+
# flags
10+
11+
llama_add_compile_flags()
12+
913
# examples
1014

1115
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ if (WIN32)
55
endif()
66
endif()
77

8+
llama_add_compile_flags()
9+
810
#
911
# libraries
1012
#

0 commit comments

Comments
 (0)