My team has a fairly large application that has recently run in to the windows command line character limit issue when compiling with CMake. It is fairly trivial to resolve with response files for clang and ninja, but CMake’s wrapper for the windows RC compiler doesn’t support this feature. Juce’s generated .rc file currently gets all the project files passed in as a dependency even though it isn’t required. The best solution I was able to to come up with requires a modification to JUCEUtils.cmake, but if anyone has a more elegant way to solve it please let me know.
function(_juce_add_resources_rc source_target dest_target)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
return()
endif()
get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
set(input_info_file "$<TARGET_PROPERTY:${source_target},JUCE_INFO_FILE>")
get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
set(dependency)
if(generated_icon)
set(dependency DEPENDS "${generated_icon}")
endif()
set(resource_rc_file "${juce_library_code}/resources.rc")
add_custom_command(OUTPUT "${resource_rc_file}"
COMMAND juce::juceaide rcfile "${input_info_file}" "${resource_rc_file}"
${dependency}
VERBATIM)
###################################################################################################################
# Modified by minimal audio to fix standalone windows builds. The RC compiler does not support response files so
# we put the resource file in it's own library with no additional includes to avoid the win cmd character limit
if (NOT TARGET ${source_target}_rc_lib)
add_library(${source_target}_rc_lib OBJECT ${resource_rc_file})
set_target_properties(${source_target}_rc_lib PROPERTIES INCLUDE_DIRECTORIES "")
endif ()
target_link_libraries(${dest_target} PRIVATE ${source_target}_rc_lib)
###################################################################################################################
endfunction()