diff --git a/package/git/README.md b/package/git/README.md new file mode 100644 index 0000000..d40d459 --- /dev/null +++ b/package/git/README.md @@ -0,0 +1,12 @@ +This dir is used by `src/*/CMakeLists.txt` to run `git describe --match "v*"`. +Because, if it would be run in that directory, on Windows the `--match "v*"` +would get expanded to the `version.h.cmake` file there, causing Git to +obviously not find any such tag. The reason is probably that on Windows the +wildcard expansion is done on the application side and not by the shell, thus +being performed even though CMake docs say `execute_process()` doesn't involve +a shell. This directory is thus dedicated for that operation, *guaranteed* to +never contain any file starting with `v` (or `V` for that matter because, +again, HELLO WINDOWS). + +No matter what you do, DON'T put any files starting with `v` or `V` here, or +hell breaks loose again. diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 20bc8ca..d0b0f65 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -37,10 +37,20 @@ if(Git_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v*" --long OUTPUT_VARIABLE MAGNUMBINDINGS_VERSION_STRING RESULT_VARIABLE _MAGNUMBINDINGS_VERSION_RESULT + ERROR_VARIABLE _MAGNUMBINDINGS_VERSION_ERROR # 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) + # a totally different Git working copy. But that's not enough, if it + # would be run in ${CMAKE_CURRENT_SOURCE_DIR}, on Windows the + # `--match "v*"` would get expanded to the `versionBindings.h.cmake` + # file, causing Git to obviously not find any such tag. The reason is + # probably that on Windows the wildcard expansion is done on the + # application side and not by the shell, thus being performed even + # though CMake docs say `execute_process()` doesn't involve a shell. + # The package/git directory is thus dedicated for that operation, + # *guaranteed* to never contain any file starting with `v` (or `V` for + # that matter because, again, HELLO WINDOWS). + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/package/git + OUTPUT_STRIP_TRAILING_WHITESPACE) if(MAGNUMBINDINGS_VERSION_STRING MATCHES "^v([0-9][0-9][0-9][0-9])\\.0?([0-9][0-9]?)-([0-9]+)-g([a-f0-9]+)$") set(MAGNUMBINDINGS_VERSION_YEAR ${CMAKE_MATCH_1}) set(MAGNUMBINDINGS_VERSION_MONTH ${CMAKE_MATCH_2}) @@ -50,6 +60,8 @@ if(Git_FOUND) set(MAGNUMBINDINGS_VERSION_HASH ${CMAKE_MATCH_4}) elseif(_MAGNUMBINDINGS_VERSION_RESULT EQUAL 0) message(WARNING "Can't match Git version from ${MAGNUMBINDINGS_VERSION_STRING}") + else() + message(WARNING "Can't match Git version: ${_MAGNUMBINDINGS_VERSION_ERROR}") endif() endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/versionBindings.h.cmake