Skip to content

Commit 631fc42

Browse files
fix: add CMake policy version minimum and remove trailing whitespace
- Add cmake_policy(VERSION 3.5) to handle older CMake versions on MSYS2/macOS - Remove trailing whitespace from test files to fix editorconfig failures - Addresses Windows MSYS2 and macOS build failures with yaml-cpp compatibility Co-Authored-By: Jake Cosme <[email protected]>
1 parent 22a350b commit 631fc42

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ if(WIN32 AND (CMAKE_GENERATOR MATCHES "MSYS Makefiles" OR MSYS))
102102
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW CACHE STRING "Use NEW policy for option() behavior")
103103
endif()
104104

105+
# Add CMake policy version minimum to handle older CMake versions
106+
if(CMAKE_VERSION VERSION_LESS "3.5")
107+
cmake_policy(VERSION 3.5)
108+
endif()
109+
105110
# Disable yaml-cpp tests and tools to avoid build issues
106111
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Disable yaml-cpp tests")
107112
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Disable yaml-cpp tools")

common/arg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,15 +1524,15 @@ bool common_params_parse(int argc, char ** argv, common_params & params, llama_e
15241524
if (has_config) {
15251525
std::vector<char*> filtered_argv;
15261526
filtered_argv.push_back(argv[0]); // Keep program name
1527-
1527+
15281528
for (int i = 1; i < argc; i++) {
15291529
if (strcmp(argv[i], "--config") == 0 && i + 1 < argc) {
15301530
i++; // Skip both --config and filename
15311531
} else {
15321532
filtered_argv.push_back(argv[i]);
15331533
}
15341534
}
1535-
1535+
15361536
if (!common_params_parse_ex(filtered_argv.size(), filtered_argv.data(), ctx_arg)) {
15371537
ctx_arg.params = params_org;
15381538
return false;

tests/test-yaml-backward-compat.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ prompt: "Test prompt"
7676

7777
common_params cli_params;
7878
const char* cli_argv[] = {
79-
"test",
79+
"test",
8080
"-n", "100",
81-
"-c", "2048",
81+
"-c", "2048",
8282
"-b", "512",
8383
"-p", "Test prompt",
8484
"-s", "42",
@@ -88,7 +88,7 @@ prompt: "Test prompt"
8888
"--repeat-penalty", "1.1"
8989
};
9090
const int cli_argc = sizeof(cli_argv) / sizeof(cli_argv[0]);
91-
91+
9292
bool cli_result = common_params_parse(cli_argc, const_cast<char**>(cli_argv), cli_params, LLAMA_EXAMPLE_COMMON);
9393

9494
assert(yaml_result == true);
@@ -104,8 +104,7 @@ prompt: "Test prompt"
104104
assert(yaml_params.sampling.temp == cli_params.sampling.temp);
105105
assert(yaml_params.sampling.top_k == cli_params.sampling.top_k);
106106
assert(yaml_params.sampling.top_p == cli_params.sampling.top_p);
107-
108-
107+
109108
const float epsilon = 1e-6f;
110109
assert(std::abs(yaml_params.sampling.penalty_repeat - cli_params.sampling.penalty_repeat) < epsilon);
111110

tests/test-yaml-config.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,29 @@ prompt: "Hello, world!"
5353

5454
static void test_cli_override_yaml() {
5555
std::cout << "Testing CLI override of YAML values..." << std::endl;
56-
56+
5757
const std::string yaml_content = R"(
5858
n_predict: 100
5959
n_ctx: 2048
6060
prompt: "YAML prompt"
6161
sampling:
6262
temp: 0.7
6363
)";
64-
64+
6565
write_test_yaml("test_override.yaml", yaml_content);
66-
66+
6767
common_params params;
6868
const char* argv[] = {"test", "--config", "test_override.yaml", "-n", "200", "-p", "CLI prompt"};
6969
int argc = 7;
70-
70+
7171
bool result = common_params_parse(argc, const_cast<char**>(argv), params, LLAMA_EXAMPLE_COMMON);
7272
assert(result == true);
73-
(void)result; // Suppress unused variable warning
74-
assert(params.n_predict == 200); // CLI should override YAML
75-
assert(params.n_ctx == 2048); // YAML value should remain
76-
assert(params.prompt == "CLI prompt"); // CLI should override YAML
77-
assert(params.sampling.temp == 0.7f); // YAML value should remain
78-
73+
(void)result;
74+
assert(params.n_predict == 200);
75+
assert(params.n_ctx == 2048);
76+
assert(params.prompt == "CLI prompt");
77+
assert(params.sampling.temp == 0.7f);
78+
7979
std::filesystem::remove("test_override.yaml");
8080
std::cout << "CLI override test passed!" << std::endl;
8181
}

0 commit comments

Comments
 (0)