Commit Graph

53 Commits

Author SHA1 Message Date
David Schulz
0057c73080 CMake: use FilePaths to parse source and build dir
Change-Id: I59523a525fd07402e3ade6cd6b7eaee69aa5abe0
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2021-09-13 12:59:46 +00:00
David Schulz
ed8b87d4f6 CMake: correctly track remote cmake files
Change-Id: I6685ed7ba77282d9d5154ba4192841f5bd093783
Reviewed-by: hjk <hjk@qt.io>
2021-09-13 12:59:33 +00:00
hjk
bdefc13eba Utils: Rename FilePath::absolutePath(FilePath) to resolvePath
There was already a similar function taking a QString.

After that, the remaining no-argument version of absolutePath()
can be deprecated.

Change-Id: I5b9ad8c8b68a5723891b0aa9f5a37e90db0fe09e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-09 05:42:30 +00:00
Cristian Adam
27f0dd134f CMakePM: Do not treat generated files as project files
This would trigger an infinite loop.

Fixes: QTCREATORBUG-26207
Fixes: QTCREATORBUG-26204
Fixes: QTCREATORBUG-25346
Fixes: QTCREATORBUG-25995
Fixes: QTCREATORBUG-25183
Fixes: QTCREATORBUG-25512
Change-Id: Iaf081a00dcf318a0ec2708e839e0ab6535e0ef4d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-09-02 08:04:17 +00:00
Cristian Adam
c1c70d339d CMakePM: Fix build library search path with CMake 3.20+
CMake 3.20 has changed the relative path to dependent libraries
from current binary directory to main binary directory.

See https://gitlab.kitware.com/cmake/cmake/-/issues/22556

Fixes: QTCREATORBUG-26110
Change-Id: I39c1d6b2998ebb079e7017e8d349881752d80354
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-20 13:58:15 +00:00
Cristian Adam
f8a77287bf CMakePM: Add support for qtc_runnable feature
This will allow for the Qt Creator's CMake build only qtcreator
target to be selected as runnable.

Similar to qmake's qtc_runnable or Qbs's qtcRunnable features.

Fixes: QTCREATORBUG-25908
Change-Id: I6416873d0ad9cfec4960d98fc4b289ec98cc58b1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-25 14:24:41 +00:00
Eike Ziller
0bcab32657 Avoid expanding QRC nodes in main thread
For CMake and Qbs projects and users of TreeScanner, where the tree is
already created in a separate thread.

Expanding the QRC nodes means reading and parsing the QRC files, which
can take up a considerable time (second(s)) if there are hundreds of
them in a larger project like Qt Creator.

Task-number: QTCREATORBUG-25783
Change-Id: I5ca818b9f75ea6e8ef23f837cc9e15df7e6630e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-06-23 14:27:44 +00:00
hjk
e35235ea72 CMake: Collect also remote filenames from generateBuildTargets()
QDir::cleanPath(...) doesn't do the right thing on stringified
Utils::FilePaths. Use FilePath functions instead.

Change-Id: Ied66f38dd30a15694bce12ed57d37411bb87f680
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-14 08:43:45 +00:00
Jarek Kobus
6ee33dfd40 Fix a copy-paste typo
Amends 4aee38e04c

Change-Id: I8d5be6c3329a43dbca417eb257544258c827b241
Reviewed-by: hjk <hjk@qt.io>
2021-06-09 12:19:01 +00:00
hjk
f2f40efa03 Utils: Move process arguments class out of QtcProcess
The main QtcProcess interface is nowadays a CommandLine, with no
explicit references left to QtcProcess::Arguments and related static
helper functions, so it only clutters the QtcProcess class interface

So move these items out of QtcProcess, later potentially to a separate
file pair.

Change-Id: I45c300b656f5b30e2e2717232c855fdd97c2d1d7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-11 09:45:24 +00:00
Eike Ziller
bce81fd992 Projects: Create QIcons in the UI thread
Creating QIcons elsewhere is not safe because of image reader plugin
loading and the pixmap cache.

Fixes: QTCREATORBUG-25301
Change-Id: Ia22a0cd571f808d7f5c639353fdf2e548743f8ca
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-04-09 13:34:55 +00:00
Eike Ziller
5e1f40a3af CMake: Don't add standard Linux paths to LD_LIBRARY_PATH
If a project specifically links to a library in a standard path (like
/usr/lib/...), we do not need to add that path to LD_LIBRARY_PATH.
Actually adding it can be harmful if the build needs to link against
some other library in a different version than is available in the system
path.

Common case is linking the application against a Qt version from the
online installer. If /usr/lib/... ends up in the LD_LIBRARY_PATH before
the path to the Qt from the online installer, the system Qt is picked up
at runtime instead of the Qt from the online installer.

Fixes: QTCREATORBUG-25292
Change-Id: Ib080e41f5893fb68e9d65cc9c9f11d1a9a60f485
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-03-05 14:53:41 +00:00
Christian Kandeler
7a6aa75032 Fix various warnings about unused variables and functions
Change-Id: I430b87ab0afa8bf32115d44e8acb94271988d229
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-26 09:53:17 +00:00
Cristian Adam
6cbdae8070 CMakeProjectManager: Support for multi-config generators
CMake has multi-config generators like:

  * Visual Studio
  * Xcode
  * Ninja Multi-Config

The first two have different special targets for "all", "install",
"package", "test" namely: "ALL_BUILD", "INSTALL", "PACKAGE",
"RUN_TESTS".

All of them need to get the build type passed via "--config <build-
type>" and not via "CMAKE_BUILD_TYPE".

The multi-config generators will use only one build directory.

Fixes: QTCREATORBUG-24984
Change-Id: I8aa7ff73ce2af1e163b21a6504d26fcf95530edf
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-21 09:31:30 +00:00
Cristian Adam
98b92ed03e CMakeProjectManager: Fix issues with precompiled headers
Clang code model can break if CMake project uses precompiled headers.

QtCreator will make a copy of the precompiled header, this way it
will not conflict with the build system one.

Ammends 888ea6bbbb

Fixes: QTCREATORBUG-24945
Fixes: QTCREATORBUG-25213
Change-Id: I149fc416cd047683d095758a024de47c7baf681c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-14 08:08:40 +00:00
Christian Kandeler
9c2ad087da Fix some warnings about unused parameters
Change-Id: I4cd941beec8a8b2d35a5b1fce48dd12facae7154
Reviewed-by: hjk <hjk@qt.io>
2020-12-14 09:23:58 +00:00
Eike Ziller
8245523653 Merge remote-tracking branch 'origin/4.14'
Conflicts:
	src/plugins/designer/cpp/formclasswizard.h
	src/plugins/designer/cpp/formclasswizarddialog.h

Change-Id: I9f9d166e1a9249022305503f9cbe571136c2a2b1
2020-11-25 11:25:34 +01:00
Jarek Kobus
6b588d7227 Remove unused variables
Mark some of them with Q_UNUSED, since it looks like
sometimes the copy is done on purpose, to force detach
or used for some hack with memory management.
In one case make unused variable used again.

Change-Id: I3825cd3399fa63bf6e12173c64509287d4a125e5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2020-11-20 13:58:46 +00:00
Christian Stenger
617a8aee2b CMakePM: Start integrating ctest
Gather some more information of a CMake based project to be
able to provide this later on to the AutoTest plugin.

Task-number: QTCREATORBUG-23332
Change-Id: I2beaf0a6456d57871dcf65832f0a79f37fe5fddc
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-11-09 11:02:37 +00:00
Dmitriy Purgin
53115259ba CMakeProjectManager: Add File System virtual folder
If a CMake project cannot be parsed by CMake, it is practically unusable in
Qt Creator. According to discussion in QTCREATORBUG-24677, a virtual
folder with the project's file system view is added to the project
manager as a convenience feature.

Fixes: QTCREATORBUG-24677
Change-Id: I48775bb89c704d3f7e5bb21ec6481bd5cc0f4b6c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-09 10:48:14 +00:00
Aaron Barany
e5d9cb3779 CMake: Fix nested source groups
Sometimes source groups would start from the root directory rather than
having the correct folder specified in CMake. This was because the
incorrect path was being used to find the relative path. Forward
baseDirectory to the overrideBaseDir parameter of addNestedNodes() to
guarantee the proper directory is used as the base.

Fixes: QTCREATORBUG-23896
Change-Id: I213c02a3fff3c10e4b6a58211600dd16ac257bbc
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-06-24 07:29:18 +00:00
Christian Kandeler
48be20cf48 Fix clang warnings about copies in range-for constructs
Change-Id: If50553964483626e72a816b1d23fa81b45ed9ca7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-06-15 12:38:17 +00:00
Eike Ziller
8b8ecfa28f Merge remote-tracking branch 'origin/4.12'
Conflicts:
	src/plugins/cmakeprojectmanager/fileapiparser.cpp

Change-Id: I39f8c2be859be043f506bef77de9bb5b42d38165
2020-06-15 11:30:34 +02:00
Tobias Hunger
182c460a2b CMake: Do not treat project with the empty string as a name as invalid
CMake will happily accept the empty string as a project name, so do not
treat that is invalid in Creator. Apparently the empty project name will
get generated by CMake itself if no project() command is found in the
top level CMakeLists.txt file.

Make sure to set a sensible name if the top-level project has no name,
using the directory name of the source directory instead.

Change-Id: I3b861daa13c1d0fec31c294ef0ac15338310020d
Fixes: QTCREATORBUG-24044
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-11 12:34:25 +00:00
Tobias Hunger
443f2bae50 CMake: Filter out non-directories from LD_LIBRARY_PATH/PATH
Task-number: QTCREATORBUG-23997
Change-Id: I4b92cd484305614b30c70bbdbd8815b0d85b7d98
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-10 09:42:45 +00:00
Eike Ziller
4fcfb7aea6 Merge remote-tracking branch 'origin/4.12'
Change-Id: I97e4fe727ca9560f2a1f4b93abcfb9fda091364e
2020-04-21 09:26:50 +02:00
Tobias Hunger
5350288e45 CMake: Fix includes all over the CMake plugin
Keep internals internal, remove some unnecessary includes, add
some that should have been there.

This reduces the number of files that get rebuild when working
on CMake internals from over 1000 to about 200.

This patch also moves some code around that ended up being
in the wrong file.

Change-Id: Icd7366ac760dc85031040720418fbb16336dce9b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-04-20 10:05:24 +00:00
Tobias Hunger
d0e0ffd2d2 Revert "CMake: Pass on extra files to code model"
This reverts commit 4d3eea6884.

Reason for revert: QTCREATORBUG-23876

Change-Id: I1b438d13cbdf64870e7cc9f7432665d773f58369
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-04-20 10:05:08 +00:00
Tobias Hunger
74a07f906f CMake: Rename some constants
Rename some constants to get a bit more consistency into the
naming scheme. I am so tiered of missing a constant due to it
not having _ in the expected places!

Change-Id: Ibb5e82ea4e25ccb559352839b96c8a64394f3085
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-04-17 13:24:43 +00:00
Tobias Hunger
4d3eea6884 CMake: Pass on extra files to code model
Pass on extra files that are not compiled according to CMake
(== headers) to the code model, so that it has the information
which build system these files are associated with.

This helps a bit with the AutoTest plugin, which wants to scan
files (incl. headers) for tests and needs information on which
build system target will build that test.

This patch fixes e.g. Google Test detection for CMake projects --
but *only* if the header files are actually listed in
CMakeLists.txt. If that is not the case, then the CMake plugin
has no way of knowing which target will build tests.

Task-number: QTCREATORBUG-23843
Change-Id: I1117c63dd052ec29a3bce6cce24c3389eedb2df7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-04-16 09:56:01 +00:00
Cristian Adam
a1e61fd4b9 CMakeProjectManager: (re)Fix clang code model when CMake PCHs are used
CMake gives the path to the cmake_pch.h[xx] file as relative path
to source directory. Making it absolute fixes the code model.

Fixes: QTCREATORBUG-22888
Change-Id: Ia969ead16bb99a05c955ae96f03596ef25db63ba
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-04-09 10:16:18 +00:00
Tobias Hunger
2da7d205d4 CMake: Add LD_LIBRARY support
Extract all the information necessary for the "Add build library search path
to LD_LIBRARY_PATH" from fileapi and enable the relevant UI in the
desktop run configuration.

This allows to remove a workaround introduced for QTCREATORBUG-19354.

Note that this is only supported by fileapi at this time.

Task-number: QTCREATORBUG-23464
Change-Id: I390d26ed8cd559bd7ff8c2701cd3b1cb8e764339
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-22 12:23:22 +00:00
Tobias Hunger
c9a1be7fe4 CMake: Support nested source_groups
Support nesting of source groups based on the source group name, split
at "\\" strings.

Change-Id: I6c0e5c64b2b4ee84cd07cde1ff5accc5c3b853df
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-14 15:40:54 +00:00
Tobias Hunger
9280f7f757 CMake: Improve handling of source_groups
* Use a special icon for source groups, so that those can get
  destinguished from folders
* Simplify folder structure below source groups to not include
  common paths elements

Task-number: QTCREATORBUG-23372
Change-Id: Ifcb35af9b35805a6272f27b0801c2fe7dfce95ae
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-14 15:39:48 +00:00
Eike Ziller
92546d0983 Merge remote-tracking branch 'origin/4.11'
Change-Id: I0657cee6b87eea7b3178548bebed85d5ac824519
2020-01-03 08:57:33 +01:00
Tobias Hunger
32018623a4 CMake: Nest nodes below SourceGroups in Project tree
Task-number: QTCREATORBUG-23372
Change-Id: I8eccc7b9ce812b3abc9bf3e0057aa9d572f4faf8
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-12-20 15:46:11 +00:00
Tobias Hunger
0dbe6f8e3c CMake: Add heuristics to set "Run in Terminal" flag
For CMake file-api, flag all applications not linking to "QtXGui"
as "Run in Terminal".

Task-number: QTCREATORBUG-21451
Change-Id: I29f086c546d3d8a9f56257e423602f787db42ccd
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-12 14:55:17 +00:00
Cristian Adam
8ee22dd597 CMakeProjectManager: Fix clang code model when CMake PCHs are used
CMake gives the path to the cmake_pch.h[xx] file as relative path
to build directory. Making it absolute fixes the code model.

Fixes: QTCREATORBUG-22888
Change-Id: I2fdc080be779f22b737788be2074254290994aaa
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-10-22 08:12:26 +00:00
Tobias Hunger
a33cb335f7 CMake: Fileapi: Make ids unique per compile group
Make sure to generate unique ids for each project part to unconfuse the
code model.

This was never triggered so far since before PCH support all my test projects
ended up with exactly one compile group per target:-)

Change-Id: Ida34f71f77cdf679fea7007f13ac19713175d916
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-09-19 09:53:52 +00:00
Tobias Hunger
454261aaa2 CMake: Support pre-compiled headers in CMake fileapi reader
Adding this to other readers makes no sense: PCH support in cmake
is younger than fileapi.

Change-Id: I4cd88882764ab8a8f81316a17098878c8e3699eb
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-09-19 09:52:53 +00:00
Eike Ziller
9cc45fe1fb CppTools: Move RawProjectPart to ProjectExplorer
Doesn't have any dependencies into CppTools anymore, therefore moving it
reduces the dependencies of the project managers to CppTools as well.

Change-Id: Ibe728abe59eb88a8877943dca1f48a85163e27ac
Reviewed-by: hjk <hjk@qt.io>
2019-09-11 06:22:12 +00:00
Eike Ziller
8452264a18 CppTools: Move QtVersion and BuildTargetType
QtVersion to utils/cpplanguage_details.h which already contains similar
flags.

BuildTargetType to ProjectExplorer, next to BuildTargetInfo (but not in the
same header to not pull that in everywhere).

Removes dependency on ProjectPart from RawProjectPart.

Change-Id: I5791065e4266f20c2657ee4b1b594df04b238a1c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-10 07:31:21 +00:00
Tobias Hunger
4aee38e04c CMake: Extract and show more CMake location information for targets
Report more cmake file locations that are relevant to a target in
the "Open..." menu entry in the target's context menu.

This information is extracted from the backtrace information that
is provided by fileapi.

Change-Id: I01659a6cc7254cd0ef6b533a0785d2f15d31c3c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2019-07-29 08:46:53 +00:00
Tobias Hunger
9ae4510e27 ProjectNodes: Use QVector instead of QList for LocationInfo
Change-Id: I5bad9e1849b9d752de24626013c9102242d11a0a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-29 08:45:08 +00:00
Tobias Hunger
4daba5a9fa CMake: Fix working directory for targets in fileapi mode
Prepend the full path to the build directory.

Change-Id: I55111b656fd4b99ee68517c09117f142e88947b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-26 11:49:01 +00:00
Tobias Hunger
ec92784778 CMake: Report absolute paths to executables in fileapi mode
Task-number: QTCREATORBUG-22610
Change-Id: Ib6abf1ce6d94abd9dc063f4f559f02f2d4ea8798
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-25 13:19:11 +00:00
Tobias Hunger
69b3d90683 CMake: Remember file location of CMake target definitions
Make fileapi remember where CMake targets were defined in the
CMakeBuildTarget struct. The other readers will just guess at
the location based on the source directory of the target.

Change-Id: Ia8fa226c548800992ccea64b1d5981d2f3013408
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-24 14:57:47 +00:00
hjk
5efa84b91f Replace remaining Utils::FileName occurrences by Utils::FilePath
Change-Id: Ic3120f18b4fbe90219de9128dba53d7453630b03
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 13:40:22 +00:00
Tobias Hunger
18eb0b39c5 CMake: Do not treat "Source Files" source file group special
The idea was to make the project tree a bit simpler by removing the
auto-generated "Source Files" group that CMake adds. But this left out
"Header Files", which is also auto-generated by CMake and might
surprise users.

So let's remove this special case again.

Change-Id: If87bf9f89e1ff0be855c2e9b915d64d77d51d2be
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-21 09:37:36 +00:00
Nikolai Kosjar
b6a9f0245b CMake: Fix warning about unsigned expression
warning: comparison of unsigned expression >= 0 is always true

Change-Id: I0a794bd7aa27a8a23094db4d95c676080b6a63b6
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-06-21 07:18:01 +00:00