Commit 275b18bb authored by Lotrado's avatar Lotrado
Browse files

Changed mirrage_embed_asset to keyword-based parameters to support an option...

Changed mirrage_embed_asset to keyword-based parameters to support an option EXPORT parameter, specifying the export set that is required to install the object library containing the generated .res file on MSVC.
parent 5108ae5b
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
#optional: generated files to depend on
macro(mirrage_embed_asset target src_files)
string (REPLACE ";" "$<SEMICOLON>" src_files_str "${src_files}")
macro(mirrage_embed_asset)
set(options)
set(oneValueArgs TARGET EXPORT)
set(multiValueArgs SOURCES DEPENDS)
cmake_parse_arguments(EMBED_ASSET "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(target ${EMBED_ASSET_TARGET})
string (REPLACE ";" "$<SEMICOLON>" src_files_str "${EMBED_ASSET_SOURCES}")
set(ID "mirrage_embedded_asset_${target}")
if(MSVC)
......@@ -18,7 +23,7 @@ macro(mirrage_embed_asset target src_files)
add_custom_command(OUTPUT ${EMBED_SRC_FILE}
COMMAND ${CMAKE_COMMAND} -DMIRRAGE_ROOT_DIR=${MIRRAGE_ROOT_DIR} -DEMBED_MODE=${EMBED_MODE} -DID=${ID} -DSRC_FILES=${src_files_str} -DDST_DIR=${CMAKE_CURRENT_BINARY_DIR} -DEMBED_SRC_FILE=${EMBED_SRC_FILE} -P ${MIRRAGE_ROOT_DIR}/embed_recursive_into_asm.cmake
DEPENDS ${ARGN}
DEPENDS ${EMBED_ASSET_SOURCES} ${EMBED_ASSET_DEPENDS}
VERBATIM
)
......@@ -79,6 +84,11 @@ void ref_embedded_assets_${target}() {
add_library(mirrage_embedded_assets_obj_${target} OBJECT "${EMBED_SRC_FILE}")
target_link_libraries(${target} INTERFACE $<TARGET_OBJECTS:mirrage_embedded_assets_obj_${target}>)
add_dependencies(mirrage_embedded_assets_obj_${target} mirrage_embedded_assets_${target})
if(EMBED_ASSET_EXPORT)
install(TARGETS mirrage_embedded_assets_obj_${target}
EXPORT ${EMBED_ASSET_EXPORT}
OBJECTS DESTINATION lib)
endif()
endif()
endmacro()
......@@ -32,7 +32,7 @@ cfg:gui = settings/gui.json
loc: = loc/
pl_cache: = pipeline_caches
")
mirrage_embed_asset(mirrage "${CMAKE_CURRENT_BINARY_DIR}/assets_mirrage_core.map")
mirrage_embed_asset(TARGET mirrage EXPORT mirrage_targets SOURCES "${CMAKE_CURRENT_BINARY_DIR}/assets_mirrage_core.map")
set(MIRRAGE_DEFAULT_COMPILER_ARGS ${MIRRAGE_DEFAULT_COMPILER_ARGS})
target_compile_options(mirrage PRIVATE ${MIRRAGE_DEFAULT_COMPILER_ARGS})
......
......@@ -25,8 +25,13 @@ cfg:console_history = console_history.txt
font: = fonts/
font:default_font = fonts/default_font.ttf
")
mirrage_embed_asset(mirrage_gui "${CMAKE_CURRENT_BINARY_DIR}/assets_mirrage_gui.map;${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts"
"${CMAKE_CURRENT_BINARY_DIR}/assets_mirrage_gui.map")
mirrage_embed_asset(TARGET mirrage_gui
EXPORT mirrage_gui_targets
SOURCES
"${CMAKE_CURRENT_BINARY_DIR}/assets_mirrage_gui.map"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts"
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/assets_mirrage_gui.map")
set(MIRRAGE_DEFAULT_COMPILER_ARGS ${MIRRAGE_DEFAULT_COMPILER_ARGS})
target_compile_options(mirrage_gui PRIVATE ${MIRRAGE_DEFAULT_COMPILER_ARGS})
......
......@@ -75,13 +75,15 @@ add_library(mirrage_renderer STATIC
add_library(mirrage::renderer ALIAS mirrage_renderer)
target_compile_features(mirrage_renderer PUBLIC cxx_std_17)
set(EMBEDDED_ASSETS
"${CMAKE_CURRENT_BINARY_DIR}/shader"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/textures"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_mirrage_renderer_shader.map"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_mirrage_renderer_textures.map"
)
mirrage_embed_asset(mirrage_renderer "${EMBEDDED_ASSETS}" ${SPIRV_BINARY_FILES})
mirrage_embed_asset(TARGET mirrage_renderer
EXPORT mirrage_renderer_targets
SOURCES
"${CMAKE_CURRENT_BINARY_DIR}/shader"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/textures"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_mirrage_renderer_shader.map"
"${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_mirrage_renderer_textures.map"
DEPENDS
${SPIRV_BINARY_FILES})
option(MIRRAGE_HISTOGRAM_DEBUG_VIEW "Enable debug view for tone mapping pass" OFF)
if(MIRRAGE_HISTOGRAM_DEBUG_VIEW)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment