Commit Graph

107 Commits

Author SHA1 Message Date
Eike Ziller
1c4de485da Merge remote-tracking branch 'origin/12.0'
Change-Id: Ib09af70f157a6c7d6cbda4e3de678fd2bbceb229
2023-11-20 09:48:43 +01:00
Cristian Adam
7affb80fc3 CMakePM: Do not show source/group/path twice
For the cases of:
  source_group(TREE ${CMAKE_SOURCE_DIR} FILES my/subdir/file.cpp)

Treat the "my\\subdir" part in the project view as part of the source
group name.

Fixes: QTCREATORBUG-29799
Change-Id: I92bf581be25d085783bcdadd8a418b849a29c708
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-11-16 16:39:38 +00:00
hjk
6685f0255d Utils/all: Move mime constants into a central place
They are reasonably standardized, and generally usable cross-plugin,
so this can help to avoid a few cross-plugin compiletime dependencies.

Change-Id: Icb2b010c3e12dee69df54ab16f6f8e90d9cffba6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-11-08 09:59:26 +00:00
Cristian Adam
973e9dcf90 CMakePM: Treat all sourceGroups as sourcesOrHeaders project nodes
Previously only "Source Files" and "Header Files" were treated as
sourceOrHeaders project nodes.

But source_group can introduce a new source group which needs to be also
treated as sourcesOrHeaders project node.

Fixes: QTCREATORBUG-29799
Change-Id: I833d80155fba3fb0269aeab149ea74b0d2edd271
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-31 15:52:31 +00:00
Cristian Adam
4a220ab20a CMakePM: Fix coverity PASS_BY_VALUE warnings
Coverity-Id: 1569153 Performance inefficiencies  (PASS_BY_VALUE)
Change-Id: I03663b09ac3cbbaf3dec87dc9389c2015c16fafd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-31 14:38:43 +00:00
Cristian Adam
3581d1c5dd CMakePM: Fix C/C++ code model preparation
Only set the compiler flags for the active language.
Select source and header files accordingly to the active language.

Fixes: QTCREATORBUG-29707
Change-Id: Ieeaa56f85ccc937f31253ac047538fa19ae4166f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-10-30 12:26:17 +00:00
Cristian Adam
423315178a CMakePM: Fix display of header / source files
Qt Creator will display the header / source files based on the
sourceDirectory of the target as base directory.

The source_group(TREE <dir>) will result CMake in making a source group
named "TREE" which should not be displayed in the project view.

Amends 9280f7f757

Fixes: QTCREATORBUG-23942
Fixes: QTCREATORBUG-29105
Change-Id: Ib71ffcc559376ea1596a5b21cb7e7fa779bd8d79
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-20 17:15:43 +00:00
hjk
fe129cc0c4 CMake: Reduce number of FilePath conversions in fileapidataextractor.cpp
Change-Id: If143843782b0bfdbdd68ab1a387d0feabfb60a33
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-20 10:27:57 +00:00
hjk
0e77cdcc2e CMake: save a few cycles
Cheaper checks first.

Change-Id: I7487862abf409ef0a885d6ac9511066a6f814039
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-18 08:08:00 +00:00
hjk
53b3255256 CMake: De-noise fileapidataextractor.cpp a bit
Change-Id: I1ed8b18e394246cbfd14394c7f9b79fd90f680d2
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-17 15:22:02 +00:00
hjk
8845a7f896 CMakeProjectManager: Use a few FilePath::path() instead of toString()
... when appropriate.

Change-Id: I2c23e4688ec69f78b0ce873e578139d5c4e89c35
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-17 15:04:57 +00:00
hjk
b38c7a452e CMakeProjectManager: Fix path construction of pch files
This triggered soft asserts in FileUtils::copyIfDifferent() when
opening top-level qt.

Amends 246f33c20d which introduced a unwanted extra .parentDir() call
which removed part of the path.

Change-Id: Id0475a74a589372d37b7ec65d33d3faf6194013c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-17 14:52:35 +00:00
Cristian Adam
52fa2c369e CMakePM: Remove compiler group for all generated sources
Change-Id: Ie30bb63c96438d3582a7d2b753b9677a4a95fe9b
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-13 13:30:46 +00:00
Jarek Kobus
ee48dba19e FileApiReader: Make shutdown faster
Check more often for canceled future.

Make more functions static.

Fixes: QTCREATORBUG-27729
Change-Id: I8dd787acea6343008c7515fb6a4fdfde50b37aee
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-06 15:37:12 +00:00
Marcus Tillmanns
34fdac0d84 CMake: Improve remote parsing speed
To improve the speed of parsing the result of a remote
cmake call, we move the file fetching and parsing into a
mapped concurrent call.

We also first uniquify the list of files to remove duplicates.

Fixes: QTCREATORBUG-29618
Change-Id: I18108928ba3b5f4f8ec3d5610b216c5ccf060877
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-04 13:40:36 +00:00
Cristian Adam
78f89fc777 CMakePM: Proper support for Unity builds
A Unity build can be enabled by specifying CMAKE_UNITY_BUILD set to ON
globally or per target bases via the UNITY_BUILD property.

CMake would then add unity_NN_[cxx|c].[cxx|c] sources files that would
include the existing project files.

The existing project files would then be added as "headers" to the
project and exported via the CMake file-api.

This patch makes sure that these new "headers" are added to the Qt
Creator's code model and have proper syntax highlighting, be available
to plugins (e.g. Todo) and so on.

Fixes: QTCREATORBUG-23635
Fixes: QTCREATORBUG-26822
Fixes: QTCREATORBUG-29080
Change-Id: Ie8dd542504f632c01f91691f8736e51be8b19a01
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-09-14 18:10:27 +00:00
hjk
67212a31ee Utils: Cache theme icon access
These trigger over 120k file exist check on my machine on startup,
just for a handful icons.

Change-Id: Ic73f0783142ed329c2f8c8b852f622e69fc306da
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-01 14:03:33 +00:00
Cristian Adam
246f33c20d CMakePM: Replace QDir with FilePath in fileapiextractor
This allows remote support.

Change-Id: I5ac46b1c2ed0e7e1fcc559522f1fcd902f83b8c0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-08-31 13:06:30 +00:00
Eike Ziller
c9fd5465eb Merge remote-tracking branch 'origin/11.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs

Change-Id: I0b0394dd68cf89b2579d623af897f55dc01aeea5
2023-08-25 11:50:14 +02:00
Eike Ziller
f2da62fd22 Fix exclusion of system directories from (DY)LD_LIBRARY_PATH
We should not only exclude children of system directories, but also the
directories themselves.

Fixes: QTCREATORBUG-29478
Change-Id: I1aa18b2faa03d241b8cc43eb157b5fa49285a12b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-08-25 07:16:35 +00:00
Jarek Kobus
8dd46d0399 Various Plugins: Simplify return FilePath statements
Change-Id: Ia9efb86f722caca1492b577d51442f1f23b804b4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-08-02 08:19:23 +00:00
hjk
3e155919eb CMake: Use current pattern to access main settings page
Change-Id: I95c556bebe1d583879b6702f727d9a859b9a4bcb
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-07-07 12:57:27 +00:00
Eike Ziller
04bb8c7b02 Remove some unused variables & includes
They are set and modified, but never read.

Change-Id: I6f21ae325e21513678f1534cd05e1a2470b9627b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-06-28 12:11:15 +00:00
Cristian Adam
dc18d4b9ee CMakePM: Display presets as part of the project outline
Fixes: QTCREATORBUG-28966
Change-Id: Iae0f77956bf6f4682ea8a25e08d05de3331c7420
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-05-12 10:21:53 +00:00
Jarek Kobus
a0f6e8dc04 Utils: Rename qtcprocess.{cpp,h} -> process.{cpp,h}
Follows QtcProcess -> Process rename.

Change-Id: I97235a9a40cb7fd52944515b7ab878d96528f919
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-04 05:52:26 +00:00
Eike Ziller
c9696fbabb Merge remote-tracking branch 'origin/10.0'
Change-Id: I8b36c1812b61dbe08fe3e7930f950e6b8e8a7079
2023-04-24 08:52:35 +02:00
Cristian Adam
ea94891f6b CMakePM: Only parse CMake files with the CMake parser
Change-Id: Ifc962a54ec9bf6ba0db4ec7813cb81d7c81a7d2c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-04-20 14:03:08 +00:00
Cristian Adam
d8be2491a5 CMakePM: Add new / existing source files to project
This will add the new added source files (.cpp, .h, .qrc, .ui) to the
corresponding CMake source file as last arguments for known CMake
functions like add_executable, add_library as well for the Qt
counterprarts qt_add_executable or qt_add_library.

For custom functions the code will insert a target_sources() call.
Subsequent calls will add the files to the last target_sources.

The previous copy to clipboard mechanism and settings have been removed.

Fixes: QTCREATORBUG-26006
Fixes: QTCREATORBUG-27213
Fixes: QTCREATORBUG-28493
Fixes: QTCREATORBUG-29006
Change-Id: Ia6e075e4e5718e4106c1236673d469139611a677
Reviewed-by: hjk <hjk@qt.io>
2023-04-20 12:43:33 +00:00
Cristian Adam
a37b0f0e6c CMakePM: Add .h header files to .c source files
Utils::mimeTypesForFileName would only return "text/x-c++hdr" for .h
files.  This is perfectly fine for C++ source files.

The ancestor "text/x-chdr" is required for C source files though.

Fixes: QTCREATORBUG-28991
Change-Id: I21f038787e48e88b5e4b9e8ca386b3af80d098ea
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-04-19 09:40:04 +00:00
hjk
d8de6c88e9 Avoid creation of temporary lists of ProjectNodes
Change-Id: Iac84f7f95291fb3b12a071a066d358aaab309c52
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-04-17 11:05:39 +00:00
Christian Stenger
2abe6bbe2c CMakePM: Fix passing library search paths
Amends 305ccfe259.

Change-Id: Icd08697720224e84cb4ad282d21191f80728865e
Reviewed-by: hjk <hjk@qt.io>
2023-04-17 07:50:40 +00:00
hjk
305ccfe259 Utils: Replace FilePath::onDevice() by new FilePath::withMappedPath()
Basically a.onDevice(b) == b.withNewMappedPath(a), matching the order
of b.withNewPath(a).

Whether the (curretly docker-specific) path mapping is useful /there/, and
whether some of the calls are needed at all is dubious. I added some
FIXME and changed a few cases directly.

Change-Id: I7514736ce922f632f1f737bc496f6783389a42b6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-04-04 06:56:55 +00:00
Christian Kandeler
65814b124c CMakeProjectManager: Add lib and app binaries to project tree
Task-number: QTCREATORBUG-28815
Change-Id: I58ebcd2a6935eb4b6746b5fd58e6ab8b97fdef43
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-03-21 13:59:46 +00:00
hjk
5d21da74f9 Utils: More explicit host os use to make it stand out
Quite a few of the uses are actually wrong, but are better visible
now and therefore more likely to be fixed.

Change-Id: Ia51f7d6eb1b2d3a9c9f73d67dabacfd227c44b15
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-03-07 15:53:18 +00:00
hjk
87c3f08e52 CMake: Move settings storage closer to class implementation
Simpler in use.

Change-Id: I8cc929001035974b9b73566b206410bfd77f73a6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-23 14:49:45 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
hjk
7e9d50a2c9 Remove a few now-unnecessary cleanPath in conjunction with resolvePath
Change-Id: I05ee0116183a30e907fbd8e0b4faae9e6e58723d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-30 13:32:05 +00:00
hjk
e9ed3d6d05 RemoteLinux: Allow adding Qt to LD_LIBRARY_PATH
When running on the remote build device. And make it work with CMake.

Change-Id: If25bef8ab836c1d59a586116b3c3447a29c4e7e8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-18 11:24:15 +00:00
Jarek Kobus
5ab100a2b9 CMakeProjectManager: Limit the usage of std::make_pair
Make the code less verbose.

Change-Id: I8dc194f0cb4ed38c4c117482a7011019444edc40
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-09-30 15:12:34 +00:00
hjk
ab4c9b9679 CMake: Move to Tr::tr
Change-Id: I169da93b5184351cb915d4c198fd33318fcfe06f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-09-30 06:56:21 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Marcus Tillmanns
6431932569 cmake: Add option to disable subfolders
An option is added to change the default behavior that
would create subfolders inside source groups for files
based on their location on disk.

When disabling the option, files will be added directly
under their respective source group.

The virtual folders <build-folder> and <other-files>
is also omitted when the option is disabled.

Fixes: QTCREATORBUG-27432
Change-Id: Id78e178011c5299d4f7257bf855a5d791eebf91c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-07-04 08:48:57 +00:00
Cristian Adam
498418bbc9 CMakePM: Treat .h files as compile group language header types
CMake splits sources files into groups "Source Files" and "Header
Files".

CMake also has compiler groups when source files are compiled
differently.

Qt Creator is mapping the compiler groups as RawProjectParts.

In order to get the header files as part of a RawProjectPart the target
sources (which contains all sources) is mapping the header files that
match the mime type of the compiler group language type.

.h header files were considered ambigous headers, and in this
commit we treat them as the compile group language header.

Fixes: QTCREATORBUG-27117
Change-Id: If68e847846cc270f06fc2231ec44a29ea6a987c1
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-19 09:45:05 +00:00
Eike Ziller
ca480ec601 Merge remote-tracking branch 'origin/7.0'
Change-Id: I9a7a9a5579f1f4e277e7927eefb1bab9ca60ad4a
2022-04-07 09:51:40 +02:00
Eike Ziller
06703e17d4 CMake: Add paths from target_link_directories to ((DY)LD_LIBRARY_)PATH
So far we only looked at a target and added all paths of actually linked
libraries to the ((DY)LD_LIBRARY_)PATH, if the "Add build library search
path" option is on (the default).
That often is fine, but

- if the library to link to is only given as a library name, not a path
and not a CMake target, then CMake file-api doesn't give us a path to
the library either
- on Windows, where the .lib is needed for compiletime linking, but the
.dll is needed for runtime linking this only helps if the .dll was in
the same directory as the .lib

We already have a hack on Windows, if the directory ends in /lib, that
we also add /lib/../bin, but that again only helps for that specific
layout.

Instead actually add the "build library search path", by adding the
directories from target_link_directories, even if no libraries are
linked from there. This fixes the "linked only by name" issue, and
allows users to add a build library search path to the .dll too, and
have that used by Qt Creator for running the application.

Fixes: QTCREATORBUG-27201
Change-Id: I7b9210b791b4dae3a6d1747ff36e4b82235db2f9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-04-04 13:44:24 +00:00
Eike Ziller
f562ebf239 Mimetypes: Make implementation switchable between new and old
- configure with QTC_USE_NEW_MIMEDATABASE to switch to the new one in
  utils/mimetypes2/
- added utils/mimeutils.h header for the Qt Creator specific static
  wrappers, that also includes the "public" headers for MimeType et al
  from the new or old implementation, depending on configuration
- change all utils/mimetypes/ includes to utils/mimeutils.h
- move the implementation for the wrappers to
  utils/mimetypes(2)/mimeutils.cpp
- also move the MimeDatabase declaration in the "old" implementation
  back to utils/mimetypes/mimedatabase.h

Change-Id: Ie8de229c035d6cd9a5e4739dc0fa78d9c17228e3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-25 07:19:58 +00:00
Jarek Kobus
2948d282ce Don't call DocumentManager::addDocument() from non-main thread
Detect that constructor of ResourceTopLevelNode is being
run from non-main thread and omit creation of ResourceFileWatcher
in this case. The construction of ResourceFileWatcher
will be postponed until the node tree returns back
to the main thread. This happens later inside
Project::setRootProjectNode() when ProjectTree::applyTreeManager()
is called for the second time - this time it's done from the main
thread. In order to setup the lacking resource file watchers
we install an additional folder node visitor only in case when
the handler is called from main thread. The visitor
sets up the lacking resource watchers if that's still needed.

Amends: 0bcab32657

Fixes: QTCREATORBUG-26417
Change-Id: Ia1bfb7f284afb833b6b4291accc4d0a91bd0d6c5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-10-20 12:35:22 +00:00
Cristian Adam
fded7e4edd CMakePM: Add headers only on compiler groups without PCH sources
The change that treats header files as projects added all sources for a
certain language for every compiler group.

This meant that for the target that has precompiled headers, the source
files would be added multiple times.

This change reverts to adding only the source files from a compiler
group and the header files for a language type, but only for non PCH
compiler group.

Fixes: QTCREATORBUG-26383
Change-Id: Ib328e0a0331e0f373d5a5981489bc17c58b8eed6
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-11 14:17:30 +00:00
Jarek Kobus
dfb5ab475e Optimize addTargets() method
Don't lookup for matching targetDetails on every iteration.
Before we start a loop we prepare the appropriate hash and
use it on every iteration instead.

This shortens the total time spent on findOrDefault
from about 2 seconds to about 10 miliseconds now.

Change-Id: I89bb3f472bc9071a54f9900fa057f87b57d4742d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-08 16:27:02 +00:00
Jarek Kobus
de3e33a76b Optimize setupLocationInfoForTargets()
Don't search for each target separately in the node tree,
but do a one search for all targets at once.

This makes searching for nodes much faster, as in case
of loading a Qt6 project (5 main modules only) with debug build
of Creator, the searching time went down from 36 seconds into
30 miliseconds (just 1000 times faster). The number of targets
in this case was more than 5000.

Change-Id: I015f6fd2a2d5e613307cc7b65746c01a5b14c6dc
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-10-08 12:09:20 +00:00