mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-25 05:48:47 +01:00
cmake : fix build-info.h on MSVC (#3309)
This commit is contained in:
parent
1726f9626f
commit
99115f3fa6
@ -118,7 +118,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
|||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h"
|
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build-info.h"
|
||||||
COMMENT "Generating build details from Git"
|
COMMENT "Generating build details from Git"
|
||||||
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake"
|
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=${CMAKE_C_COMPILER} -P "${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DEPENDS "${GIT_DIR}/index"
|
DEPENDS "${GIT_DIR}/index"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
@ -8,16 +8,12 @@ set(BUILD_TARGET "unknown")
|
|||||||
# Look for git
|
# Look for git
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
if(NOT Git_FOUND)
|
if(NOT Git_FOUND)
|
||||||
execute_process(
|
find_program(GIT_EXECUTABLE NAMES git git.exe)
|
||||||
COMMAND which git
|
if(GIT_EXECUTABLE)
|
||||||
OUTPUT_VARIABLE GIT_EXECUTABLE
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
if(NOT GIT_EXECUTABLE STREQUAL "")
|
|
||||||
set(Git_FOUND TRUE)
|
set(Git_FOUND TRUE)
|
||||||
message(STATUS "Found Git using 'which': ${GIT_EXECUTABLE}")
|
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
||||||
else()
|
else()
|
||||||
message(WARNING "Git not found using 'find_package' or 'which'. Build info will not be accurate. Consider installing Git or ensuring it is in the PATH.")
|
message(WARNING "Git not found. Build info will not be accurate.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -28,43 +24,32 @@ if(Git_FOUND)
|
|||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE HEAD
|
OUTPUT_VARIABLE HEAD
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE GIT_HEAD_RESULT
|
|
||||||
)
|
)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
|
COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE COUNT
|
OUTPUT_VARIABLE COUNT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE GIT_COUNT_RESULT
|
|
||||||
)
|
)
|
||||||
if(GIT_HEAD_RESULT EQUAL 0 AND GIT_COUNT_RESULT EQUAL 0)
|
|
||||||
set(BUILD_COMMIT ${HEAD})
|
|
||||||
set(BUILD_NUMBER ${COUNT})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(GIT_HEAD_RESULT EQUAL 0 AND GIT_COUNT_RESULT EQUAL 0)
|
|
||||||
set(BUILD_COMMIT ${HEAD})
|
set(BUILD_COMMIT ${HEAD})
|
||||||
set(BUILD_NUMBER ${COUNT})
|
set(BUILD_NUMBER ${COUNT})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(
|
if(MSVC)
|
||||||
|
set(BUILD_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
|
||||||
|
set(BUILD_TARGET ${CMAKE_VS_PLATFORM_NAME})
|
||||||
|
else()
|
||||||
|
execute_process(
|
||||||
COMMAND sh -c "$@ --version | head -1" _ ${CMAKE_C_COMPILER}
|
COMMAND sh -c "$@ --version | head -1" _ ${CMAKE_C_COMPILER}
|
||||||
OUTPUT_VARIABLE OUT
|
OUTPUT_VARIABLE OUT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE RES
|
)
|
||||||
)
|
|
||||||
if (RES EQUAL 0)
|
|
||||||
set(BUILD_COMPILER ${OUT})
|
set(BUILD_COMPILER ${OUT})
|
||||||
endif()
|
execute_process(
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
|
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
|
||||||
OUTPUT_VARIABLE OUT
|
OUTPUT_VARIABLE OUT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
RESULT_VARIABLE RES
|
)
|
||||||
)
|
|
||||||
if (RES EQUAL 0)
|
|
||||||
set(BUILD_TARGET ${OUT})
|
set(BUILD_TARGET ${OUT})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user