Skip to content

Commit

Permalink
tests : add _CRT_SECURE_NO_WARNINGS for WIN32
Browse files Browse the repository at this point in the history
This commit adds the compile definition `_CRT_SECURE_NO_WARNINGS`
to the `tests` cmake subproject.

The motivation for this is that currently the following warnings are
displayed when compiling tests:
```console
test-llama-grammar.cpp
C:\llama.cpp\src\.\llama.cpp(1406,77): warning C4996: 'strerror':
This function or variable may be unsafe. Consider using strerror_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See
online help for details.
[C:\llama.cpp\build\tests\test-llama-grammar.vcxproj]
...
```

This compile definition is set for the `src` subproject and one option
could be to push this up to the root CMakeLists.txt file to have it
applied to both/all subprojects.
  • Loading branch information
danbev committed Jun 27, 2024
1 parent ac14662 commit 3e2a8a0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ function(llama_target_and_test source)
set_property(TEST ${TEST_TARGET} PROPERTY LABELS ${LLAMA_TEST_LABEL})
endfunction()

if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()

# build test-tokenizer-0 target once and add many tests
add_executable(test-tokenizer-0 test-tokenizer-0.cpp)
target_link_libraries(test-tokenizer-0 PRIVATE common)
Expand Down

0 comments on commit 3e2a8a0

Please sign in to comment.