31 lines
1.2 KiB
CMake
31 lines
1.2 KiB
CMake
# Copyright (c) 2025 Dominic Msters
|
|
#
|
|
# This software is released under the MIT License.
|
|
# https://opensource.org/licenses/MIT
|
|
|
|
# Function that adds an asset to be compiled
|
|
function(add_asset ASSET_TYPE ASSET_PATH)
|
|
set(FULL_ASSET_PATH "${CMAKE_CURRENT_LIST_DIR}/${ASSET_PATH}")
|
|
string(JOIN "%" ASSETS_ARGS ${ARGN})
|
|
list(APPEND DUSK_ASSETS
|
|
"${ASSET_TYPE}#${FULL_ASSET_PATH}#${ASSETS_ARGS}"
|
|
)
|
|
set(DUSK_ASSETS ${DUSK_ASSETS} CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
endfunction()
|
|
|
|
function(add_defs INPUT_PATH OUTPUT_NAME_RELATIVE)
|
|
set(INPUT_FULL_PATH "${CMAKE_CURRENT_LIST_DIR}/${INPUT_PATH}")
|
|
set(OUTPUT_FULL_PATH "${DUSK_GENERATED_HEADERS_DIR}/${OUTPUT_NAME_RELATIVE}")
|
|
|
|
add_custom_command(
|
|
OUTPUT ${OUTPUT_FULL_PATH}
|
|
COMMAND ${CMAKE_COMMAND}
|
|
-DENV_FILE=${INPUT_FULL_PATH}
|
|
-DOUT_HEADER=${OUTPUT_FULL_PATH}
|
|
-P ${CMAKE_SOURCE_DIR}/cmake/modules/envtoh.cmake
|
|
DEPENDS ${INPUT_FULL_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules/envtoh.cmake
|
|
COMMENT "Generating ${OUTPUT_NAME_RELATIVE}"
|
|
)
|
|
add_custom_target(${OUTPUT_NAME_RELATIVE}_header DEPENDS ${OUTPUT_FULL_PATH})
|
|
add_dependencies(${DUSK_TARGET_NAME} ${OUTPUT_NAME_RELATIVE}_header)
|
|
endfunction() |