From b16d91287d6124f1b5d38c2ff552781dcd60e7e1 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 22 Dec 2018 00:40:38 +0100 Subject: [PATCH] Track dependencies of Windows resource file So changing the icon will cause the resource file to be recompiled. --- cmake/modules/WindowsResources.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/modules/WindowsResources.cmake b/cmake/modules/WindowsResources.cmake index a9dfbc8..e07e64f 100644 --- a/cmake/modules/WindowsResources.cmake +++ b/cmake/modules/WindowsResources.cmake @@ -13,9 +13,10 @@ if(NOT MINGW OR NOT WINDOWS_RESOURCES_ENABLED) return() endif() -# find rc template +# find rc template, define path of output rc file include(TemplateFinder) find_template_file("windows.rc" CPP_UTILITIES RC_TEMPLATE_FILE) +set(WINDOWS_RC_FILE "${CMAKE_CURRENT_BINARY_DIR}/resources/windows.rc") # create Windows icon from png with ffmpeg if available unset(WINDOWS_ICON_PATH) @@ -39,6 +40,10 @@ if(WINDOWS_ICON_ENABLED) add_custom_command( OUTPUT "${WINDOWS_ICON_PATH}" COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=${PNG_ICON_CROP},scale=64:64 "${WINDOWS_ICON_PATH}" + DEPENDS "${PNG_ICON_PATH}" + ) + set_source_files_properties("${WINDOWS_RC_FILE}" + PROPERTIES OBJECT_DEPENDS "${WINDOWS_ICON_PATH}" ) message(STATUS "Generating Windows icon from \"${PNG_ICON_PATH}\" via ${FFMPEG_BIN}.") elseif(NOT USING_DEFAULT_PNG_ICON_PATH) @@ -51,10 +56,11 @@ endif() # create Windows rc file from template configure_file( "${RC_TEMPLATE_FILE}" - "${CMAKE_CURRENT_BINARY_DIR}/resources/windows.rc" + "${WINDOWS_RC_FILE}" ) + # set windres as resource compiler -list(APPEND RES_FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/windows.rc") +list(APPEND RES_FILES "${WINDOWS_RC_FILE}") set(CMAKE_RC_COMPILER_INIT windres) set(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") enable_language(RC)