summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2024-03-26 10:03:31 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-04-14 04:03:19 +0000
commit2939e225701c4044c413e6e301727df0755efdb5 (patch)
treea4c1db5524880443b43752e136eb587fab186ca1 /cmake
parent35450cde8205974920fdb658fd0aaa0eac6d689d (diff)
cmake: add _extra_files IDE target from heuristics
Lots of files in the repos are not included into the generated IDE projects. Therefore we add utility targets (custom targets), which are populated by glob patterns, which should fit most files that are found in qt's subprojects. Change-Id: I1b731e65f8db319d3cec817eea5c23a1eeaefb22 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 003a19115279e44bf8af96e0f588f5cc34725353) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildRepoHelpers.cmake57
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake
index f3307647fa..28fba12d6e 100644
--- a/cmake/QtBuildRepoHelpers.cmake
+++ b/cmake/QtBuildRepoHelpers.cmake
@@ -350,6 +350,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()
@@ -375,6 +377,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