Commit Graph

34 Commits

Author SHA1 Message Date
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
Tobias Hunger
5bcd59c94f CMake: Simplify buildkey generation
Just use the target name as buildkey. This is unique in cmake projects, so
there is no need to mangle the source directory into the whole thing.

This is a problem since different readers might report different source
directories. That will then result in RunConfigurations getting duplicated
after switching the reader types.

Task-number: QTCREATORBUG-22129
Change-Id: I849ab68f221d732341e98faa9a4e757d3a495b2a
Reviewed-by: hjk <hjk@qt.io>
2019-06-20 14:41:04 +00:00
Tobias Hunger
add60c0148 CMake: Avoid a bit of useless processing when updating the project tree
Do not pass around a list of filenodes with all the known header files.
That list gets converted into a QSet<FilePath> and then that is used.

Just generate the QSet<FilePath> directly and avoid that conversion.

Change-Id: I2444a2a6b4a1600fe476e66673a1a2e9c8900764
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2019-06-20 14:40:55 +00:00
Tobias Hunger
a95eb53d3b CMake: Add initial fileapireader class
Change-Id: I620cba7cc1c2a5ac56789fa9770dce573c6b19cd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-20 12:25:36 +00:00