2022-10-03 12:06:53 +00:00
|
|
|
|
#[=======================================================================[.rst:
|
|
|
|
|
myx_generate_git_info_header
|
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
|
|
|
Вспомогательная функция для автоматической генерации заголовочного
|
|
|
|
|
файла, содержащего информацию о текущем состоянии репозитория git::
|
|
|
|
|
|
|
|
|
|
myx_generate_git_info_header(TARGET BASE_FILENAME
|
|
|
|
|
[ PREFIX prefix ] )
|
|
|
|
|
|
|
|
|
|
Обязательные параметры: `TARGET` - имя цели, с которой связан заголовочный файл,
|
|
|
|
|
и `BASE_FILENAME` - имя генерируемого заголовочного файла. Дополнительный аргумент
|
|
|
|
|
`PREFIX` добавляет префикс к генерируемым именам переменных.
|
|
|
|
|
|
|
|
|
|
#]=======================================================================]
|
|
|
|
|
|
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
|
|
|
|
|
|
function(myx_generate_git_info_header target base_filename)
|
|
|
|
|
set(options)
|
|
|
|
|
set(oneValueArgs PREFIX)
|
|
|
|
|
set(multiValueArgs)
|
|
|
|
|
|
|
|
|
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
|
|
|
|
|
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}")
|
|
|
|
|
|
2022-10-04 19:53:44 +00:00
|
|
|
|
set(PREFIX "")
|
|
|
|
|
if(ARG_PREFIX)
|
|
|
|
|
string(APPEND ARG_PREFIX "_")
|
|
|
|
|
string(REPLACE "-" "_" PREFIX ${ARG_PREFIX})
|
2022-10-03 12:06:53 +00:00
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# cmake-format: off
|
|
|
|
|
if(NOT TARGET ${target}-git-info-header)
|
|
|
|
|
add_custom_target(${target}-git-info-header ALL
|
2022-10-04 19:53:44 +00:00
|
|
|
|
${CMAKE_COMMAND} -DGIT_INFO_FILE=${filename} -DPREFIX=${PREFIX}
|
2022-10-05 07:01:02 +00:00
|
|
|
|
-P ${MYX_CMAKE_LIB_DIR}/generators/GitInfo.cmake
|
2022-10-04 11:52:45 +00:00
|
|
|
|
BYPRODUCTS ${filename}
|
2022-10-05 07:01:02 +00:00
|
|
|
|
WORKING_DIRECTORY ${MYX_CMAKE_LIB_DIR}/generators)
|
2022-10-03 12:06:53 +00:00
|
|
|
|
endif()
|
|
|
|
|
# cmake-format: on
|
|
|
|
|
|
|
|
|
|
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
|
|
|
|
|
target_sources(${target} PRIVATE ${filename})
|
|
|
|
|
endfunction()
|