I think it is a good idea to document CMake cache variables VERSION_OUT_DIR and VERSION_SOURCE_DIR in README, for projects where CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR can't be used as their values.
One example is incorporating external library which uses Version.cmake into project based on Zephyr RTOS, using their tool west.
As CMake is invoked in the Zephyr RTOS project, CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR refer to the zephyr project and git commands are invoked on incorrect project.
This can be circumvented, for example, if VERSION_OUT_DIR and VERSION_SOURCE_DIR are set to CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR respectively, before invoking find_package(Version.cmake) in the external library CMakeLists.txt.
I think it is a good idea to document CMake cache variables
VERSION_OUT_DIRandVERSION_SOURCE_DIRinREADME, for projects whereCMAKE_BINARY_DIRandCMAKE_SOURCE_DIRcan't be used as their values.One example is incorporating external library which uses
Version.cmakeinto project based on Zephyr RTOS, using their tool west.As CMake is invoked in the Zephyr RTOS project,
CMAKE_SOURCE_DIRandCMAKE_BINARY_DIRrefer to the zephyr project andgitcommands are invoked on incorrect project.This can be circumvented, for example, if
VERSION_OUT_DIRandVERSION_SOURCE_DIRare set toCMAKE_CURRENT_BINARY_DIRandCMAKE_CURRENT_SOURCE_DIRrespectively, before invokingfind_package(Version.cmake)in the external libraryCMakeLists.txt.