Why does install() raise an error when RESOURCE is given a directory but CMake happily builds the app bundle?

One of the items I add to the RESOURCE property for my macOS app bundle is a directory. CMake happily creates the bundle with that directory and its hierarchy in the “Resources” directory. The app works fine.

However when I add an install command for this app. bundle CMake raises an error

 install RESOURCE given directory

This is the install command:

        install(TARGETS vkloadtests
            BUNDLE
                DESTINATION ${CMAKE_INSTALL_PREFIX}/Applications
                COMPONENT VkLoadTestApp
        )

Am I doing the installation wrong? (The documentation on installing a BUNDLE is virtually non-existent.) Is it a bug in CMake? install() has no need to be separately installing the resources here. All it needs to do is copy the already built bundle to the DESTINATION.

Only the macOS bundle needs the directory in resources. I can’t change it because it is needed by a third-party dylib included in the bundle. install is probably set up so a single command can be used for multiple platforms so is checking the RESOURCE property even though the specific command, which is also macOS only, does not reference RESOURCE.

Is there a way to explicitly tell it to ignore RESOURCE?

I thought about using install(DIRECTORY ...) instead but I don’t know how to tie that to the installation of a particular target.

I found a workaround. If I use

    set_source_files_properties( ${DIRECTORY}
        PROPERTIES
        MACOSX_PACKAGE_LOCATION Resources
    )

instead of adding the directory to the RESOURCE property, the hierarchy is copied to the bundle during build and install does not complain. You have to, of course, have added the directory to the target’s sources. A drawback is that In some uses of directories in Resources, you may not want the files in the source list.

I think install supporting directories in RESOURCE would be a very useful feature.