diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c1061c5bb5..fc7d350f87b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,4 +27,6 @@ project(QtBase LANGUAGES CXX C ASM ) +set(QT_BUILD_EXTRA_IDE_FILE_PATTERNS bin/* libexec/*) + qt_internal_qtbase_build_repo() diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake index fec2445ca5e..bf35c847e03 100644 --- a/cmake/QtBuildRepoHelpers.cmake +++ b/cmake/QtBuildRepoHelpers.cmake @@ -351,6 +351,8 @@ macro(qt_build_repo_end) qt_build_internals_add_toplevel_targets(${qt_repo_targets_name}) + qt_internal_show_extra_ide_sources() + if(NOT QT_SUPERBUILD) qt_print_build_instructions() endif() @@ -376,6 +378,61 @@ macro(qt_build_repo_end) list(POP_BACK CMAKE_MESSAGE_CONTEXT) endmacro() +function(qt_internal_show_extra_ide_sources) + if(CMAKE_VERSION VERSION_LESS 3.20) + set(ide_sources_default OFF) + else() + set(ide_sources_default ON) + endif() + + option(QT_SHOW_EXTRA_IDE_SOURCES "Generate CMake targets exposing non-source files to IDEs" ${ide_sources_default}) + if(CMAKE_VERSION VERSION_LESS 3.20 AND QT_SHOW_EXTRA_IDE_SOURCES) + message(WARNING "QT_SHOW_EXTRA_IDE_SOURCES requires cmake-3.20") + return() + endif() + + if(NOT QT_SHOW_EXTRA_IDE_SOURCES) + return() + endif() + + set(target_name ${qt_repo_targets_name}_extra_files) + add_custom_target(${target_name}) + + set(recursive_glob_patterns + coin/* + LICENSES/* + cmake/* + config.tests/* + dist/* + configure.cmake + qt_cmdline.cmake + .cmake.conf + *.cmake + *.cmake.in + ${QT_BUILD_EXTRA_IDE_FILE_RECURSIVE_PATTERNS} + ) + set(simple_glob_patterns + .gitattributes + .gitignore + .tag + config_help.txt + ${QT_BUILD_EXTRA_IDE_FILE_PATTERNS} + ) + + file(GLOB_RECURSE files LIST_DIRECTORIES false FOLLOW_SYMLINKS ${recursive_glob_patterns}) + if(files) + source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${files}) + target_sources(${target_name} PRIVATE ${files}) + endif() + + file(GLOB files LIST_DIRECTORIES false ${simple_glob_patterns}) + if(files) + source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${files}) + target_sources(${target_name} PRIVATE ${files}) + endif() +endfunction() + + # Function called either at the end of per-repo configuration, or at the end of configuration of # a super build. # At the moment it is called before examples are configured in a per-repo build. We might want