Skip to content

Commit 86b351f

Browse files
authored
ggml : replace compile definitions with version.h.in (ggml-org#28364)
This commit adds a cmake version configuration file to replace the current compile definition solution for the version. The motivation for this change is that I made a mistake and did not take into consideration that the compile definition means that this will become a compiler flag for all sources in the target. This means that when a version update happens that will recompile all sources in the target even if they have not changed. Refs: ggml-org#28278
1 parent d509cb1 commit 86b351f

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎ggml/CMakeLists.txt‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,6 @@ write_basic_package_version_file(
404404
VERSION ${GGML_INSTALL_VERSION}
405405
COMPATIBILITY SameMajorVersion)
406406

407-
target_compile_definitions(ggml-base PRIVATE
408-
GGML_VERSION="${GGML_INSTALL_VERSION}"
409-
GGML_COMMIT="${GGML_BUILD_COMMIT}"
410-
)
411407
message(STATUS "ggml version: ${GGML_INSTALL_VERSION}")
412408
message(STATUS "ggml commit: ${GGML_BUILD_COMMIT}")
413409

‎ggml/src/CMakeLists.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ set_target_properties(ggml-base PROPERTIES
213213
SOVERSION ${GGML_VERSION_MAJOR}
214214
)
215215

216-
target_include_directories(ggml-base PRIVATE .)
216+
configure_file(ggml-version.h.in ${CMAKE_CURRENT_BINARY_DIR}/ggml-version.h @ONLY)
217+
218+
target_include_directories(ggml-base PRIVATE . ${CMAKE_CURRENT_BINARY_DIR})
217219
if (GGML_BACKEND_DL)
218220
target_compile_definitions(ggml-base PUBLIC GGML_BACKEND_DL)
219221
endif()

‎ggml/src/ggml-version.h.in‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
3+
#define GGML_VERSION "@GGML_VERSION@"
4+
#define GGML_COMMIT "@GGML_BUILD_COMMIT@"

‎ggml/src/ggml.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define _CRT_SECURE_NO_DEPRECATE // Disables "unsafe" warnings on Windows
22
#define _USE_MATH_DEFINES // For M_PI on MSVC
33

4+
#include "ggml-version.h"
45
#include "ggml-backend.h"
56
#include "ggml-impl.h"
67
#include "ggml-threading.h"

0 commit comments

Comments
 (0)