From b05a7ce3b77eee7d7dd9cb4b8192e2cefd6bf48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 27 Jul 2020 17:26:16 +0200 Subject: [PATCH] Fix generation of the version.h header when inside a Git submodule. --- doc/changelog.dox | 2 ++ src/Magnum/CMakeLists.txt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index 3a44ef10a..6fc5ad32d 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -89,6 +89,8 @@ See also: assumed macOS is always desktop GL (see [mosra/magnum#452](https://github.com/mosra/magnum/issues/452)) - Avoiding conflicts of Magnum's own GL headers with `GLES3/gl32.h` (see [mosra/magnum#460](https://github.com/mosra/magnum/issues/460)) +- The `version.h` header now gets populated from Git correctly also when + inside a CMake subproject @subsection changelog-latest-bugfixes Bug fixes diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index f38bf29d2..177f5a226 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -37,6 +37,9 @@ if(Git_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v*" --long OUTPUT_VARIABLE MAGNUM_VERSION_STRING RESULT_VARIABLE _MAGNUM_VERSION_RESULT + # Otherwise this gets executed in the build dir, which might be inside + # a totally different Git working copy + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if(MAGNUM_VERSION_STRING MATCHES "^v([0-9][0-9][0-9][0-9])\\.0?([0-9][0-9]?)-([0-9]+)-g([a-f0-9]+)$") set(MAGNUM_VERSION_YEAR ${CMAKE_MATCH_1})