mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-24 10:24:35 +00:00
cmake : fix issue with version info not getting baked into LlamaConfig.cmake (#3970)
* Split CPP generation from build-info query * Remove blank lines * Add BUILD_SHARED_LIBS option
This commit is contained in:
parent
0dab8cd7cc
commit
b38a16dfcf
@ -43,6 +43,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# general
|
# general
|
||||||
|
option(BUILD_SHARED_LIBS "build shared libraries" OFF)
|
||||||
option(LLAMA_STATIC "llama: static link libraries" OFF)
|
option(LLAMA_STATIC "llama: static link libraries" OFF)
|
||||||
option(LLAMA_NATIVE "llama: enable -march=native flag" ON)
|
option(LLAMA_NATIVE "llama: enable -march=native flag" ON)
|
||||||
option(LLAMA_LTO "llama: enable link time optimization" OFF)
|
option(LLAMA_LTO "llama: enable link time optimization" OFF)
|
||||||
@ -100,6 +101,9 @@ option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALO
|
|||||||
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
|
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
|
||||||
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
|
option(LLAMA_BUILD_SERVER "llama: build server example" ON)
|
||||||
|
|
||||||
|
# Required for relocatable CMake package
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compile flags
|
# Compile flags
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ add_custom_command(
|
|||||||
COMMENT "Generating build details from Git"
|
COMMENT "Generating build details from Git"
|
||||||
COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}
|
COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}
|
||||||
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_VS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME}
|
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_VS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME}
|
||||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -P "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/build-info.cmake"
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -P "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/gen-build-info-cpp.cmake"
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.."
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build-info.cpp.in" ${GIT_INDEX}
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build-info.cpp.in" ${GIT_INDEX}
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/common/build-info.cpp.in")
|
|
||||||
set(OUTPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/common/build-info.cpp")
|
|
||||||
set(BUILD_NUMBER 0)
|
set(BUILD_NUMBER 0)
|
||||||
set(BUILD_COMMIT "unknown")
|
set(BUILD_COMMIT "unknown")
|
||||||
set(BUILD_COMPILER "unknown")
|
set(BUILD_COMPILER "unknown")
|
||||||
@ -58,23 +56,3 @@ else()
|
|||||||
)
|
)
|
||||||
set(BUILD_TARGET ${OUT})
|
set(BUILD_TARGET ${OUT})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Only write the build info if it changed
|
|
||||||
if(EXISTS ${OUTPUT_FILE})
|
|
||||||
file(READ ${OUTPUT_FILE} CONTENTS)
|
|
||||||
string(REGEX MATCH "LLAMA_COMMIT = \"([^\"]*)\";" _ ${CONTENTS})
|
|
||||||
set(OLD_COMMIT ${CMAKE_MATCH_1})
|
|
||||||
string(REGEX MATCH "LLAMA_COMPILER = \"([^\"]*)\";" _ ${CONTENTS})
|
|
||||||
set(OLD_COMPILER ${CMAKE_MATCH_1})
|
|
||||||
string(REGEX MATCH "LLAMA_BUILD_TARGET = \"([^\"]*)\";" _ ${CONTENTS})
|
|
||||||
set(OLD_TARGET ${CMAKE_MATCH_1})
|
|
||||||
if (
|
|
||||||
NOT OLD_COMMIT STREQUAL BUILD_COMMIT OR
|
|
||||||
NOT OLD_COMPILER STREQUAL BUILD_COMPILER OR
|
|
||||||
NOT OLD_TARGET STREQUAL BUILD_TARGET
|
|
||||||
)
|
|
||||||
configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
|
|
||||||
endif()
|
|
||||||
|
24
scripts/gen-build-info-cpp.cmake
Normal file
24
scripts/gen-build-info-cpp.cmake
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
|
||||||
|
|
||||||
|
set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/common/build-info.cpp.in")
|
||||||
|
set(OUTPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/common/build-info.cpp")
|
||||||
|
|
||||||
|
# Only write the build info if it changed
|
||||||
|
if(EXISTS ${OUTPUT_FILE})
|
||||||
|
file(READ ${OUTPUT_FILE} CONTENTS)
|
||||||
|
string(REGEX MATCH "LLAMA_COMMIT = \"([^\"]*)\";" _ ${CONTENTS})
|
||||||
|
set(OLD_COMMIT ${CMAKE_MATCH_1})
|
||||||
|
string(REGEX MATCH "LLAMA_COMPILER = \"([^\"]*)\";" _ ${CONTENTS})
|
||||||
|
set(OLD_COMPILER ${CMAKE_MATCH_1})
|
||||||
|
string(REGEX MATCH "LLAMA_BUILD_TARGET = \"([^\"]*)\";" _ ${CONTENTS})
|
||||||
|
set(OLD_TARGET ${CMAKE_MATCH_1})
|
||||||
|
if (
|
||||||
|
NOT OLD_COMMIT STREQUAL BUILD_COMMIT OR
|
||||||
|
NOT OLD_COMPILER STREQUAL BUILD_COMPILER OR
|
||||||
|
NOT OLD_TARGET STREQUAL BUILD_TARGET
|
||||||
|
)
|
||||||
|
configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
|
||||||
|
endif()
|
Loading…
Reference in New Issue
Block a user