JUCE_ENABLE_MODULE_SOURCE_GROUPS doesn't work since commit on 20th Jan

This commit claims to have improved the module source grouping so I assume it’s something I’m doing wrong in my CMakeLists.txt.

I have a plugin project with the following (simplified) CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)

project(demo-plugin
    VERSION 0.1.0
)

set_property(GLOBAL PROPERTY USE_FOLDERS YES)
set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON CACHE BOOL "" FORCE)
add_subdirectory(../JUCE JUCE)

juce_add_plugin(demo-plugin
    PLUGIN_MANUFACTURER_CODE Me
    PLUGIN_CODE Demo
    FORMATS AU VST3 Standalone
)

target_compile_definitions(demo-plugin
PRIVATE
    JUCE_WEB_BROWSER=0
    JUCE_USE_CURL=0
    JUCE_VST3_CAN_REPLACE_VST2=0
)

target_link_libraries(demo-plugin
    PRIVATE
        juce::juce_audio_utils
    PUBLIC
        juce::juce_recommended_config_flags
        juce::juce_recommended_lto_flags
        juce::juce_recommended_warning_flags
)

juce_generate_juce_header(demo-plugin)

As you can see I’m calling JUCE_ENABLE_MODULE_SOURCE_GROUPS before adding JUCE as a subdirectory. On commit 308757b of master (the commit before the one linked above), the Modules folder shows up in Visual Studio Solution Explorer as expected. Checking out commit 7c88dec and running cmake -B build causes the Modules folder to disappear.

I’m fairly new to CMake so I’m sure there’s some silly mistake I’ve made…?

Quoting docs/CMake API.md:

If you enable this, you should probably also add set_property(GLOBAL PROPERTY USE_FOLDERS YES) to your top level CMakeLists as this is required for source grouping to work.

Thanks, I’d missed that but sadly adding it still doesn’t work for me!

I just tried on Mac with Xcode and still no luck - take the AudioPlugin example from the CMake examples in JUCE and copy it to be next to the top-level JUCE directory, replace the CMakeLists.txt in that folder with the one I pasted above (plus the line @McMartin suggested) and run cmake -B build -G Xcode. No Modules folder is added to the Xcode project.

edit: Updated my CMakeLists above to add the line suggested.

Are you only checking out that commit or the latest develop/master? I believe that issue was updated several times after that date.

I tried out the steps you mentioned:

  • Copied the AudioPlugin example folder to another location

  • Modified the add_subdirectory(JUCE) line to point to the location of JUCE on my system

  • Added these lines to enable source grouping:

    set_property(GLOBAL PROPERTY USE_FOLDERS YES)
    set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON CACHE BOOL "" FORCE)
    

This is the layout I see in Xcode.

Please ensure that you’re using the latest master or develop branch.

2 Likes

Ahh, that’s not where I expected the folder to be! In the past the Modules folder used to in the top-level under AUDIO_PLUGIN_EXAMPLE. It’s now moved (and been renamed). Turns out it was working all along and I just wasn’t looking in the right place! :upside_down_face:

Maybe you could add a comment to the CMake docs to explain where to find the JUCE Modules folder after setting that option?

Either way, thanks for your help!