diff --git a/CMakeLists.txt b/CMakeLists.txt index e1632961..21c6352f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,15 +148,17 @@ if(APPLE) set(CMAKE_MACOSX_RPATH 1) endif() +set(GIT_BRANCH_NAME "--unknown--") +set(GIT_TAG_INFO "--unknown--") find_package (Git) -if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git/HEAD") +if (GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git/HEAD") execute_process( COMMAND ${GIT_EXECUTABLE} describe --tags --always - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE GIT_TAG_INFO) string(REGEX REPLACE "\n$" "" GIT_TAG_INFO "${GIT_TAG_INFO}") - file(READ ".git/HEAD" GIT_HEAD_REF_INFO) + file(READ "${CMAKE_CURRENT_LIST_DIR}/.git/HEAD" GIT_HEAD_REF_INFO) if (GIT_HEAD_REF_INFO) string(REGEX MATCH "ref: refs/heads/(.*)" _ ${GIT_HEAD_REF_INFO}) if (CMAKE_MATCH_1) @@ -165,12 +167,7 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git/HEAD") set(GIT_BRANCH_NAME ${GIT_HEAD_REF_INFO}) endif() string(REGEX REPLACE "\n$" "" GIT_BRANCH_NAME "${GIT_BRANCH_NAME}") - else() - set(GIT_BRANCH_NAME "--unknown--") endif() -else() - set(GIT_BRANCH_NAME "--unknown--") - set(GIT_TAG_INFO "--unknown--") endif() if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) @@ -341,7 +338,7 @@ endif() # DEBUG enables runtime loader ICD verification # Add git branch and tag info in debug mode -target_compile_definitions(loader_common_options INTERFACE $<$:DEBUG;GIT_BRANCH_NAME=${GIT_BRANCH_NAME};GIT_TAG_INFO=${GIT_TAG_INFO}>) +target_compile_definitions(loader_common_options INTERFACE $<$:DEBUG;GIT_BRANCH_NAME="${GIT_BRANCH_NAME}";GIT_TAG_INFO="${GIT_TAG_INFO}">) # Check for the existance of the secure_getenv or __secure_getenv commands include(CheckFunctionExists) diff --git a/loader/loader.c b/loader/loader.c index 9dac71f6..c7cd3ece 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -1544,11 +1544,7 @@ void loader_initialize(void) { loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "Vulkan Loader Version %d.%d.%d", version.major, version.minor, version.patch); #if defined(GIT_BRANCH_NAME) && defined(GIT_TAG_INFO) -#define LOADER_GIT_STRINGIFY(x) #x -#define LOADER_GIT_TOSTRING(x) LOADER_GIT_STRINGIFY(x) - const char git_branch_name[] = LOADER_GIT_TOSTRING(GIT_BRANCH_NAME); - const char git_tag_info[] = LOADER_GIT_TOSTRING(GIT_TAG_INFO); - loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "[Git - Tag: %s, Branch/Commit: %s]", git_tag_info, git_branch_name); + loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "[Vulkan Loader Git - Tag: " GIT_BRANCH_NAME ", Branch/Commit: " GIT_TAG_INFO "]"); #endif }