Commit 1c0fb00c authored by Lotrado's avatar Lotrado
Browse files

Workaround for .res-files from a static library not being properly linked into...

Workaround for .res-files from a static library not being properly linked into an executable linking against the library.
parent 8a104813
......@@ -6,7 +6,7 @@ macro(mirrage_embed_asset target src_files)
set(ID "mirrage_embedded_asset_${target}")
if(MSVC)
set(EMBED_SRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.rc")
set(EMBED_SRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets_${target}.rc")
set(EMBED_MODE "MSVC")
elseif(APPLE)
set(EMBED_SRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.s")
......@@ -17,7 +17,7 @@ macro(mirrage_embed_asset target src_files)
endif()
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} -P ${MIRRAGE_ROOT_DIR}/embed_recursive_into_asm.cmake
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}
VERBATIM
)
......@@ -64,9 +64,15 @@ void ref_embedded_assets_${target}() {
}
")
target_sources(${target} PRIVATE ${EMBED_SRC_FILE})
if(NOT MSVC)
target_sources(${target} PRIVATE ${EMBED_SRC_FILE})
endif()
target_sources(${target} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.cpp")
add_custom_target(mirrage_embedded_assets_${target} DEPENDS ${EMBED_SRC_FILE})
add_dependencies(${target} mirrage_embedded_assets_${target})
if(MSVC)
add_library(mirrage_embedded_assets_obj_${target} OBJECT "${EMBED_SRC_FILE}")
target_link_libraries(${target} PUBLIC $<TARGET_OBJECTS:mirrage_embedded_assets_obj_${target}>)
endif()
endmacro()
......@@ -33,8 +33,8 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${DST_DIR}/embedded_asset
if("${EMBED_MODE} " STREQUAL "MSVC ")
string(TOUPPER "${ID}" RES_ID)
configure_file(${MIRRAGE_ROOT_DIR}/embedded_assets.rc.in "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.rc")
execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.rc" OUTPUT_QUIET)
configure_file(${MIRRAGE_ROOT_DIR}/embedded_assets.rc.in "${EMBED_SRC_FILE}")
execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${EMBED_SRC_FILE}" OUTPUT_QUIET)
else()
if("${EMBED_MODE} " STREQUAL "APPLE ")
set(SECTION ".const_data")
......
Markdown is supported
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