2023-11-16 11:15:29 +01:00
|
|
|
# ! generate_cmake_variable_header : Generates a header CmakeVariables.h that contains defines for the variables specified in
|
|
|
|
# CmakeVariables.h.in!
|
2023-02-18 14:30:06 +01:00
|
|
|
#
|
|
|
|
# The generated CmakeVariables.h header can then be used to access e.g. the PROJECT_NAME define in C++ code.
|
|
|
|
#
|
2023-11-16 11:15:29 +01:00
|
|
|
# Example generate_cmake_variable_header(${PROJECT_NAME})
|
2023-02-18 14:30:06 +01:00
|
|
|
#
|
|
|
|
function(generate_cmake_variable_header TARGET)
|
2023-11-23 11:37:50 +01:00
|
|
|
# ⚠️ Also add to CMakeVariables.h.in ⚠️
|
|
|
|
|
2023-11-09 10:32:28 +01:00
|
|
|
set(SCREENPLAY_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
2023-11-23 11:37:50 +01:00
|
|
|
# Like v4.2-beta3 or v5.0.1-stable
|
2023-09-28 15:55:11 +02:00
|
|
|
set(SCREENPLAY_GODOT_VERSION ${GODOT_VERSION})
|
2023-11-23 11:37:50 +01:00
|
|
|
# Only single numbers
|
|
|
|
set(SCREENPLAY_GODOT_VERSION_MAJOR ${GODOT_VERSION_MAJOR})
|
|
|
|
set(SCREENPLAY_GODOT_VERSION_MINOR ${GODOT_VERSION_MINOR})
|
|
|
|
# stable, rc1 or beta5
|
2023-11-02 12:50:29 +01:00
|
|
|
set(SCREENPLAY_GODOT_RELEASE_TYPE ${GODOT_RELEASE_TYPE})
|
2023-11-09 10:32:28 +01:00
|
|
|
set(SCREENPLAY_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
|
|
|
set(SCREENPLAY_BUILD_DATE "${BUILD_DATE}")
|
2023-11-16 11:15:29 +01:00
|
|
|
set(SCREENPLAY_VERSION "${SCREENPLAY_VERSION}")
|
2023-11-09 10:32:28 +01:00
|
|
|
set(SCREENPLAY_GIT_BRANCH_NAME "${GIT_BRANCH_NAME}")
|
|
|
|
set(SCREENPLAY_GIT_COMMIT_HASH "${GIT_COMMIT_HASH}")
|
|
|
|
|
|
|
|
set(SCREENPLAY_DEPLOY_VERSION 0)
|
|
|
|
if(${SCREENPLAY_DEPLOY})
|
|
|
|
set(SCREENPLAY_DEPLOY_VERSION 1)
|
|
|
|
endif()
|
2023-11-16 11:15:29 +01:00
|
|
|
|
2023-11-09 10:32:28 +01:00
|
|
|
set(SCREENPLAY_STEAM_VERSION 0)
|
|
|
|
if(${SCREENPLAY_STEAM})
|
|
|
|
set(SCREENPLAY_STEAM_VERSION 1)
|
|
|
|
endif()
|
2023-02-18 14:30:06 +01:00
|
|
|
|
|
|
|
# Specify the configuration file from which the header file will be generated
|
|
|
|
configure_file(${CMAKE_SOURCE_DIR}/CMake/CMakeVariables.h.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/CMakeVariables.h @ONLY)
|
2023-11-16 11:15:29 +01:00
|
|
|
message(
|
|
|
|
STATUS "GENERATE: ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/CMakeVariables.h and add ${TARGET} to ${CMAKE_CURRENT_BINARY_DIR}")
|
2023-11-02 12:50:29 +01:00
|
|
|
|
2023-02-18 14:30:06 +01:00
|
|
|
# Add the directory containing the generated header
|
|
|
|
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
endfunction()
|