diff --git a/CMakeLists.txt b/CMakeLists.txt index fe80330b82..7b6f7c92ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,16 @@ set_property(GLOBAL PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD ${JUCE_COPY_PLUGIN_AFT set(CMAKE_CXX_EXTENSIONS FALSE) +# This option controls whether dummy targets are added to the build which contain all of the source +# files for each JUCE module. If you're planning to use an IDE and want to be able to browse all of +# JUCE's source files, this may be useful. However, it will increase the size of generated IDE +# projects and might slow down configuration a bit. If you enable this, you should probably also add +# `set_property(GLOBAL PROPERTY USE_FOLDERS YES)` to your top level CMakeLists, otherwise the module +# sources will be added directly to the top level of the project, instead of in a nice 'Modules' +# subfolder. + +option(JUCE_ENABLE_MODULE_SOURCE_GROUPS "Show all module sources in IDE projects" OFF) + add_subdirectory(modules) add_subdirectory(extras/Build) diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index 30b8d7d460..f3b5e6b3d1 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -612,6 +612,13 @@ function(juce_add_module module_path) if(JUCE_ARG_ALIAS_NAMESPACE) add_library(${JUCE_ARG_ALIAS_NAMESPACE}::${module_name} ALIAS ${module_name}) endif() + + if(JUCE_ENABLE_MODULE_SOURCE_GROUPS) + file(GLOB_RECURSE extra_files LIST_DIRECTORIES FALSE "${module_path}/*") + add_custom_target(${module_name}_sources SOURCES ${extra_files}) + set_target_properties(${module_name}_sources PROPERTIES FOLDER Modules) + source_group(TREE "${module_path}" FILES ${extra_files}) + endif() endfunction() function(juce_add_modules) @@ -1958,13 +1965,6 @@ function(_juce_initialise_target target) _juce_write_generate_time_info(${target}) _juce_link_optional_libraries(${target}) - - file(GLOB juce_module_folders RELATIVE "${JUCE_MODULES_DIR}" "${JUCE_MODULES_DIR}/*") - - foreach(module_folder IN LISTS juce_module_folders) - file(GLOB_RECURSE juce_module_files "${JUCE_MODULES_DIR}/${module_folder}/*") - source_group(TREE "${JUCE_MODULES_DIR}" PREFIX "Modules" FILES ${juce_module_files}) - endforeach() endfunction() # ==================================================================================================