I’ve been converting my projects to use the JUCE CMake functions and have noticed there is no Resource.rc file added to the Windows plugin targets or console apps. Only the standalone plugin target and the GUI app target have a Resource.rc file.
In my project I want to include resources in the same way for every target and in console apps for automated tests.
I’m not sure about Projucer, but I’ve previously been using FRUT which I believe does add a Windows RC file to every target.
Would it be possible to add this same behaviour to the JUCE CMake functions?
For now I have some workaround functions - but it’s obviously not ideal to be calling the “private” juce functions.
#------------------------------------------------------------------------------
# When a JUCE console app is created it will not have a resource file on Windows.
# Call this for any JUCE console app that requires embedded resources.
#------------------------------------------------------------------------------
function (add_windows_resource_file_to_juce_console_app targetName)
if (NOT WIN32)
return()
endif()
# A JUCE console app will not have a configuration info file.
# We need to create this first so it can be used in the
# _juce_add_resources_rc function.
_juce_write_configure_time_info (${targetName})
_juce_add_resources_rc (${targetName} ${targetName})
endfunction()
#------------------------------------------------------------------------------
# When a JUCE plugin app is created it only add a resource file for the
# Standalone target. This function will add a resource file to all other plugin
# formats.
# Call this for any JUCE plugin app that requires embedded resources.
#------------------------------------------------------------------------------
function (add_windows_resource_file_to_juce_plugin_app pluginName)
if (NOT WIN32)
return()
endif()
get_target_property (juce_library_code ${pluginName} JUCE_GENERATED_SOURCES_DIRECTORY)
set (resource_rc_file "${juce_library_code}/resources.rc")
# If there's no standalone target a resource file build rule won't have been
# created.
# The plugin's shared library doesn't need to include the resource file but
# it's more convenience to create resource file build rule using the shared
# library target.
if (NOT TARGET ${pluginName}_Standalone)
_juce_add_resources_rc (${pluginName} ${pluginName})
endif()
# We only need one resource file per plug in. Here we add it as a source to
# each plugin format.
foreach (format VST3 AAX)
if (TARGET ${pluginName}_${format})
target_sources (${pluginName}_${format} PRIVATE "${resource_rc_file}")
endif()
endforeach()
endfunction()