From 3e2a8a0885bf1c49321172e6e6e437339bbd9eec Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 27 Jun 2024 06:38:48 +0100 Subject: [PATCH] tests : add _CRT_SECURE_NO_WARNINGS for WIN32 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. --- tests/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cfa70731534862..7a04c5f9bad825 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)