From 68a727fa19182fdc7f3daf836e69eb90d46cc08b Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 7 Oct 2021 14:21:37 +0100 Subject: [PATCH] CMake: Factor source-grouping fixup into a separate function --- extras/Build/CMake/JUCEModuleSupport.cmake | 15 +++++++++++++++ extras/Build/CMake/JUCEUtils.cmake | 13 +------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/extras/Build/CMake/JUCEModuleSupport.cmake b/extras/Build/CMake/JUCEModuleSupport.cmake index 17abb65b20..785c6fcbe7 100644 --- a/extras/Build/CMake/JUCEModuleSupport.cmake +++ b/extras/Build/CMake/JUCEModuleSupport.cmake @@ -590,3 +590,18 @@ function(juce_add_modules) endforeach() endfunction() +# When source groups are enabled, this function sets the HEADER_FILE_ONLY property on any module +# source files that should not be built. This is called automatically by the juce_add_* functions. +function(_juce_fixup_module_source_groups) + if(JUCE_ENABLE_MODULE_SOURCE_GROUPS) + get_property(all_modules GLOBAL PROPERTY _juce_module_names) + + foreach(module_name IN LISTS all_modules) + get_target_property(path ${module_name} INTERFACE_JUCE_MODULE_PATH) + get_target_property(header_files ${module_name} INTERFACE_JUCE_MODULE_HEADERS) + get_target_property(source_files ${module_name} INTERFACE_JUCE_MODULE_SOURCES) + source_group(TREE ${path} PREFIX "JUCE Modules" FILES ${header_files} ${source_files}) + set_source_files_properties(${header_files} PROPERTIES HEADER_FILE_ONLY TRUE) + endforeach() + endif() +endfunction() diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index 7f3480e516..a734f2dae1 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -1611,18 +1611,7 @@ function(_juce_initialise_target target) _juce_write_generate_time_info(${target}) _juce_link_optional_libraries(${target}) - - if(JUCE_ENABLE_MODULE_SOURCE_GROUPS) - get_property(all_modules GLOBAL PROPERTY _juce_module_names) - - foreach(module_name IN LISTS all_modules) - get_target_property(path ${module_name} INTERFACE_JUCE_MODULE_PATH) - get_target_property(header_files ${module_name} INTERFACE_JUCE_MODULE_HEADERS) - get_target_property(source_files ${module_name} INTERFACE_JUCE_MODULE_SOURCES) - source_group(TREE ${path} PREFIX "JUCE Modules" FILES ${header_files} ${source_files}) - set_source_files_properties(${header_files} PROPERTIES HEADER_FILE_ONLY TRUE) - endforeach() - endif() + _juce_fixup_module_source_groups() endfunction() # ==================================================================================================