myx-cmake/MyxCMake/functions/MyxCMakeGenerateGitInfoHeader.cmake

20 lines
759 B
CMake

function(myx_cmake_generate_git_info_header)
set(output_file ${CMAKE_BINARY_DIR}/include/myx_cmake_git_info.hpp)
if(MYX_CMAKE_GENERATED_HEADERS_PATH)
set(output_file ${MYX_CMAKE_GENERATED_HEADERS_PATH}/myx_cmake_git_info.hpp)
elseif(ARGV0)
set(output_file ${ARGV0})
endif()
# cmake-format: off
if(NOT TARGET myx-cmake-git-info-header)
add_custom_target(myx-cmake-git-info-header ALL
${CMAKE_COMMAND} -DMYX_CMAKE_PROJECT_NAME_UPPER=${MYX_CMAKE_PROJECT_NAME_UPPER}
-DMYX_CMAKE_FUNCTIONS_DIR=${MYX_CMAKE_FUNCTIONS_DIR}
-DMYX_CMAKE_GIT_INFO_FILE=${output_file} -P ${MYX_CMAKE_FUNCTIONS_DIR}/MyxCMakeGitInfo.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
# cmake-format: on
endfunction()