A possible edge case bug in definition of juce_add_bundle_resources_directory?

Hello, I’ve hit what I believe is an edge case bug in juce_add_bundle_resources_directory (or more likely, an issue with my usage of CMake).

Thanks to contribution of sample projects from @eyalamir, I’ve been able to create targets for a standalone audio application initially done with Projucer, the issue I’m facing is that the assets folder in that project is called “Resources”, and the CMake build ended up putting the data under “Resources/Resources”.

I’ve made a hack in the function in case folder is called “Resources” to deal with the issue but wondered if others faced this?

Here is the redefinition if it is helpful to anyone here:

# gauthier: rewrite it because bug when folder name = Resources?
function(juce_add_bundle_resources_directory target folder)

    if(NOT EXISTS "${folder}")
        message(FATAL_ERROR "Could not find resource folder ${folder}")

    get_filename_component(folder_parent_path "${folder}" DIRECTORY)
    file(GLOB_RECURSE resources RELATIVE "${folder_parent_path}" "${folder}/*")
#    message("folder parent path: " ${folder_parent_path})
    foreach(file IN LISTS resources)
#       message(${file})
        target_sources(${target} PRIVATE "${folder_parent_path}/${file}")
        get_filename_component(resource_parent_path "${file}" DIRECTORY)
#        message("resource parent path: " ${resource_parent_path} "eee")

        # gauthier: edge case when file is at root of a folder and folder is named Resources.
        if("Resources" STREQUAL ${resource_parent_path})
            set(resource_parent_path "")
        set_source_files_properties("${folder_parent_path}/${file}" PROPERTIES
                HEADER_FILE_ONLY TRUE
                MACOSX_PACKAGE_LOCATION "Resources/${resource_parent_path}")

Let me know if this sounds like a bug and I’ll file the issue on the github if this can be fixed upstream.

If I’m doing something wrong, is there any opensource repository which exhibits usage of resource files which happen to be placed under “Resources” folder?

This is not a bug, it’s expected behavior. From CMake API.md:

juce_add_bundle_resources_directory(<target> <folder>)

Copy the entire directory at the location <folder> into an Apple bundle’s resource directory, i.e.
the Resources directory for a macOS bundle, and the top-level directory of an iOS bundle.

So if <folder> is named “Resources”, you indeed get <app>.app/Contents/Resources/Resources.

However, juce_add_bundle_resources_directory is only a convenience function, you don’t have to use it. You can instead call

target_sources(${target} PRIVATE ${resource_file})
set_source_files_properties(${resource_file} PROPERTIES

on each file you want to place under <app>.app/Contents/Resources.