summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2024-03-26 10:03:31 +0800
committerTim Blechmann <tim@klingt.org>2024-04-12 08:36:01 +0800
commit003a19115279e44bf8af96e0f588f5cc34725353 (patch)
tree79d5c6794b23342669fd6d69be8c678a197f590a
parent6209079c7a34c4656e6e110ae5194feb19f6134a (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. Pick-to: 6.7 Change-Id: I1b731e65f8db319d3cec817eea5c23a1eeaefb22 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/QtBuildRepoHelpers.cmake57
2 files changed, 59 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c1061c5bb..fc7d350f87 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 fec2445ca5..bf35c847e0 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