46 lines
1.8 KiB
CMake
46 lines
1.8 KiB
CMake
#[=======================================================================[.rst:
|
||
myx_generate_private_config_header
|
||
----------------------------------
|
||
|
||
Вспомогательная функция для автоматической генерации заголовочного
|
||
файла, содержащего информацию о проекте::
|
||
|
||
myx_generate_private_config_header(TARGET BASE_FILENAME)
|
||
|
||
Обязательные параметры: `TARGET` - имя цели, с которой связан заголовочный файл,
|
||
и `BASE_FILENAME` - имя генерируемого заголовочного файла.
|
||
|
||
#]=======================================================================]
|
||
|
||
include_guard(GLOBAL)
|
||
|
||
function(myx_generate_private_config_header target base_filename)
|
||
set(BUILD_DATE ${MYX_TODAY})
|
||
myx_project_version_int()
|
||
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
|
||
|
||
set(filename "${PROJECT_BINARY_DIR}/include/${base_filename}")
|
||
|
||
set(private_config_hpp_in
|
||
"#pragma once
|
||
|
||
#define PROJECT_VERSION_STR \"@PROJECT_VERSION@\"
|
||
#define PROJECT_VERSION_INT @PROJECT_VERSION_INT@
|
||
|
||
#cmakedefine PROJECT_NAME \"@PROJECT_NAME@\"
|
||
#cmakedefine AUTHOR_NAME \"@AUTHOR_NAME@\"
|
||
#cmakedefine AUTHOR_EMAIL \"@AUTHOR_EMAIL@\"
|
||
#cmakedefine DESCRIPTION \"@PROJECT_DESCRIPTION@\"
|
||
#cmakedefine BUILD_TYPE \"@CMAKE_BUILD_TYPE@\"
|
||
#cmakedefine BUILD_DATE \"@MYX_TODAY@\"
|
||
")
|
||
|
||
set(private_config_hpp_in_path "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target}_config_p.hpp.in")
|
||
file(WRITE ${private_config_hpp_in_path} ${private_config_hpp_in})
|
||
|
||
configure_file(${private_config_hpp_in_path} ${filename})
|
||
|
||
set_property(TARGET ${target} APPEND PROPERTY PRIVATE_HEADER_FILES ${filename})
|
||
target_sources(${target} PRIVATE ${filename})
|
||
endfunction()
|