From dbb49019405712d69b49704251252e6ddbdd8e87 Mon Sep 17 00:00:00 2001 From: daleclack Date: Sun, 24 Oct 2021 11:32:04 +0800 Subject: [PATCH] CompileGResources: Respect SOURCE_DIR option for input resource files It is actually respected and passed down to the glic-compile-resources tool, however, the generated Makefiles won't find those resource files because they are always assumed to be at CMAKE_CURRENT_SOURCE_DIR. Fixes https://github.com/Makman2/GCR_CMake/issues/20 --- macros/CompileGResources.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/macros/CompileGResources.cmake b/macros/CompileGResources.cmake index 6c54dc7..b5c5dff 100644 --- a/macros/CompileGResources.cmake +++ b/macros/CompileGResources.cmake @@ -135,13 +135,18 @@ function(COMPILE_GRESOURCES output xml_out) message(FATAL_ERROR ${CG_ERRMSG}) endif() + # If source directory is not set, default to working directory. + if (NOT CG_ARG_SOURCE_DIR) + set(CG_ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + # Extract all dependencies for targets from resource list. foreach(res ${CG_ARG_RESOURCES}) if (NOT(("${res}" STREQUAL "COMPRESS") OR ("${res}" STREQUAL "STRIPBLANKS") OR ("${res}" STREQUAL "TOPIXDATA"))) - list(APPEND CG_RESOURCES_DEPENDENCIES "${res}") + list(APPEND CG_RESOURCES_DEPENDENCIES "${CG_ARG_SOURCE_DIR}/${res}") endif() endforeach() @@ -202,11 +207,6 @@ function(COMPILE_GRESOURCES output xml_out) set(CG_ARG_TARGET "${CG_ARG_TARGET}.${CG_TARGET_FILE_ENDING}") endif() - # Create source directory automatically if not set. - if (NOT CG_ARG_SOURCE_DIR) - set(CG_ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - endif() - # Add compilation target for resources. add_custom_command(OUTPUT ${CG_ARG_TARGET} COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE}