Commit Graph

78 Commits

Author SHA1 Message Date
Eike Ziller
b213c87cf4 Merge remote-tracking branch 'origin/4.15'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp

Change-Id: I722a94f37bdd1d78625cfae503ba6d02ff083c63
2021-03-25 11:06:59 +01:00
Cristian Adam
9d2fab7c17 CMakePM: Clear CMake configuration to remove backup files
Also remove the CMakeCache.txt.prev, .cmake/api/v1/reply, and
.cmake/api/v1/reply.prev which might cause problems in
case of CMake configuration failure.

Change-Id: I24f049e5e0338b78393b68ab3680276388ffc6bf
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-23 10:51:11 +00:00
Eike Ziller
863260f1fd Merge remote-tracking branch 'origin/4.15'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
	src/plugins/debugger/gdb/gdboptionspage.cpp

Change-Id: I4149e860b6842ea63bff3a7eb9632b7a6c2919d8
2021-03-22 09:52:14 +01:00
Cristian Adam
637d45c66a CMakePM: Make "Build type" aspect visible
For single configuration projects if you change the build type
aspect you will change the CMAKE_BUILD_TYPE variable.

When switching the build directory the existing CMAKE_BUILD_TYPE
will be set as build type aspect.

Fixes: QTCREATORBUG-25451
Change-Id: I13519e95c316c556cc1348fba6121637d2fd4275
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-19 13:38:18 +00:00
Erik Verbruggen
5ad724a3ac Support for QML module mapping
QUL uses module mapping for theming of QtQuick.Controls: during
code-generation the compiler is pointed to the Controls implementation
it should use. This is done by rewriting any import of QtQuick.Controls
with the given module name. The CMake build scripts will write a file
for each target to the directory "qml_module_mappings" in the build dir,
and those files will contain the mappings used.

Fixes: QTCREATORBUG-25356
Change-Id: I3f74897836dde7717b03bd6dffa46dcc0689ffdd
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-03-19 10:43:23 +00:00
Erik Verbruggen
2361f26732 Support merged QML import paths with header paths
QUL does not have separate QML import paths, but (re-)uses the include
paths for this purpose. Support this behavior by adding all include
paths to the QML import paths before handing the project information off
to the QML code model.

Change-Id: Ic2e39ab69ac27776f5070b7b8b7c66d53a83210b
Reviewed-by: <christiaan.janssen@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-03-18 14:33:55 +00:00
Eike Ziller
bce64778c5 Merge remote-tracking branch 'origin/4.15'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qtcreator_ide_branding.pri

Change-Id: I009308451e1c6276692412f498125d79a8f12a07
2021-03-11 14:10:14 +01:00
Eike Ziller
8ac091abf8 CMake: Improve layout of "Apply configuration changes" dialog
Show the CMake parameters that would be passed in a mono space font, one
option per line.

Change-Id: I462792736960b33fea669b5b753c89d21cd087fd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-03-11 07:47:01 +00:00
Erik Verbruggen
9d90efee8b Add QML import path supplied by the kit
Although QUL has merged the QML import paths and the include paths, the
convention for C/C++ is to have the headers for a project under a
subdirectory of the include path, and do imports relative to the include
path. For example:
  #include <qul/SomeHeader.h>

The QML code model doesn't know about this convention, so for the kit
has to supply an extra QML import path for this case.

Change-Id: I82d4375dd8a1f510180f81b011a715dee8c10d60
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-03-10 14:33:06 +00:00
Jarek Kobus
675a72e296 Fix a deadlock when closing Creator while loading a project
Replace the call to SynchronousProcess::run() by asynchronous
call that invokes a process.

This change may be tested by applying the additional patch
mentioned in QTCREATORBUG-25385 description.

Don't call the SynchronousProcess::run() from the main thread when
the Quit event was already scheduled for qApp, since the Quit event
will get removed from the awaiting queue by a call to
QEventLoop::exec().

Fixes: QTCREATORBUG-25385
Change-Id: I8af39552443bfa9b3af6e31ddce85a01b91bbbd8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-09 11:13:01 +00:00
Cristian Adam
8f2db9fcbe CMakePM: Ask for configuration save if the user has changed variables
If the use has forgotten to click "Apply Configuration Changes"
button in project settings but it tries to build or run the
project, then the "Apply Configuration Changes" dialog box pops
as a reminder.

Change-Id: I26728ee3c79af72125be3bede759620c2cf3d7a1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-02 14:18:53 +00:00
Cristian Adam
3c3e9a97fd CMakeProjectManager: Write cmake configuration into qtcsettings.cmake
The parameters sent to CMake are also saved as qtcsettings.cmake,
this allows Android Multi-ABI CMake projects apply the settings
for all ABIs.

This was part of 196b0da08a

Task-number: QTCREATORBUG-25183
Change-Id: I6d4f210247d5377cab855a1a051cf7aa815192c7
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2021-03-02 08:15:37 +00:00
Cristian Adam
fc411cd0d1 CMakeProjectManager: Make backup of CMake configuration before starting CMake
CMake's fileapi functionality will save the project structure in json
files in the .cmake/api/v1/reply directory.

When issuing a cmake command with -D variables CMake will update its
CMakeCache.txt file even if cmake will fail.

This commit will rename .cmake/api/v1/reply as .cmake/api/v1/reply.prev
and make a copy of CMakeCache.txt before starting CMake, and if
something fails, replace the existing files with the previous values.

Also make sure the changed values are not dissappearing when the
old .cmake/api/v1/reply gets parsed.

Fixes: QTCREATORBUG-24593
Change-Id: I82141786fea7068699e0f761a8978ba1f3203e47
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-18 13:21:11 +00:00
Alessandro Portale
ae5255cebd Android: Fix android-*-deployment-settings.json detection
Qt 6.0 + CMake: The name for the Android deployment settings file needs
to be determined by using the build key of the current run configuration
rather than by using the display name of the project root node.

Since in contrast to qmake/Qbs, CMake does not supply us with the file
name and we have to contruct it ourselves. Therefore, it makes sense to
move the value into the Android plugin.

This change adds AndroidQtVersion::androidDeploymentSettings which lets
qmake and Qbs still provide the value as before while handling the CMake
fallback.

Fixes: QTCREATORBUG-25209
Change-Id: I12314d06a45d6e045cb654d9140f9d2ed4602f67
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-02-18 09:34:48 +00:00
Alessandro Portale
72d91dc94a Use qAsConst with non-const Qt containers in range-loops
... in various places

Change-Id: Ic6c0c1b9437a1ed402105c7a14a1f5f9454a68d4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-17 14:43:29 +00:00
Alessandro Portale
9e2c6fbfca Android: Deduplicate string literals and use constants instead
Improves findability of identical string in code (via code model).
Reduces risk of typos.

Change-Id: I0e9d9af8eed5cd9b66bf303cfee99c53513bf314
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-02-10 10:32:15 +00:00
Mitch Curtis
b5ff180f8c cmakeprojectmanager: save files before build
This code path (CMakeBuildSystem::buildCMakeTarget) is taken
when building a specific target, such as when activating
Build > Build for Run Configuration. Building via e.g. Ctrl+B
takes a different code path, so this shouldn't be called more
than necessary.

Fixes: QTCREATORBUG-25276
Change-Id: I362bafda43460eaeac9cbf0f053bf457a76702f1
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-02-04 13:34:40 +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
Christian Stenger
1e2e3f8e48 CMakeProjectManager: Fix initial ctest call
CMake settings can avoid to create the build directory
automatically. If this is the case the ctest call fails
due to missing information that is present inside the
build directory.
In this case we need to use the temporary directory that
is used before the build directory is created.

Change-Id: Ie6581e53a671c3e5ad71474d9706285d29bd37a8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-13 05:27:32 +00:00
Eike Ziller
3f0e7bcbe1 Merge remote-tracking branch 'origin/4.14'
Change-Id: I9d1931b7862f4541ac7a064ff987128afd835cbe
2020-12-07 12:29:44 +01:00
Eike Ziller
eeea1e6c32 CMake: Apply configuration changes to fresh build directories
Fixes opening a new project without existing build folder, changing
some configuration values, and pressing apply or choosing Run CMake.

extraCMakeArguments contains the arguments needed to apply any changes
done in e.g. the CMake configuration list in projects mode.
When pressing Apply, the build directory gets created, and CMake run
with REPARSE_FORCE_INITIAL_CONFIGURATION. But we may not remove
REPARSE_FORCE_EXTRA_CONFIGURATION which might even just have been added
a few lines above after asking the user via mustApplyExtraArguments().

Amends af4e74a972

Task-number: QTCREATORBUG-24936
Change-Id: I5e5547611262490ebdebb30dc1bfc690f1cdedde
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-12-03 10:59:14 +00:00
Eike Ziller
d02afbe6b4 Merge remote-tracking branch 'origin/4.14'
Conflicts:
	src/plugins/projectexplorer/gcctoolchain.cpp

Change-Id: I2136ba89d3aa3c4c2a0e7a4f9d8ba9cec32924ce
2020-11-30 16:14:32 +01:00
Eike Ziller
af4e74a972 CMake: Create build directory when user changes configuration
When opening and configuring a project, Qt Creator first tries to
configure the project in a temporary directory (if the build directory
doesn't exist anyhow). This is nice if you just open a project for
browsing, and the initial arguments are set up correctly for parsing a
project.

But if the user starts changing the configuration, either by changing
variables and applying the change, or by choosing a "QML debugging and
profiling" option, we should create the actual build directory and do
the configuration there.
Otherwise we have issues with redoing the correct configuration in the
actual build directory later on.

Fixes: QTCREATORBUG-24936
Change-Id: I54013a14f68eb7785e866cc2a9c09bbc43b44233
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-26 11:30:54 +00:00
Eike Ziller
6172fc8a9d Merge remote-tracking branch 'origin/4.14'
Change-Id: I8543d87779c0da6a876caa046f6852737c9ae680
2020-11-26 10:53:34 +01:00
Eike Ziller
3ef279450b CMake: Don't overwrite existing builds when changing build dir
When changing a build configuration's build directory to a directory
with an existing build (i.e. CMakeCache.txt), do not overwrite it, but
just parse it (running CMake as needed to generate the fileapi
response). Do not ask funny questions in that case.

This solves the pattern that you want to use some preconfigured build
but configured the right kit already with the default parameters.
Switching to a different build directory should simply never "kill"
an existing build in any case (and running CMake with the
"initial arguments" basically kills the existing build in the
not-so-uncommon case).

Change-Id: I54ca1f14d72a11a3bfe5b09ce340b28be321f80e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-26 06:48:42 +00:00
Eike Ziller
b243a794aa CMake: Fix missing run of CMake after saving sub-CMakeLists.txt
If you have a project with subdirs, changing and saving on of the
subdirs CMakeLists.txt would just "reparse" the existing project
data again.
Instead run CMake first, so the change actually takes effect.

Change-Id: Ia2b0f8b5681f10d426229470fdc420b3234eccec
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-25 16:19:38 +00:00
Eike Ziller
5ca70bdcb3 Merge remote-tracking branch 'origin/4.14'
Change-Id: Iea84f23cf394de13e99a9ed777c8c113e4eff473
2020-11-19 15:38:13 +01:00
Eike Ziller
bdc74ea2a0 cmake: Show errors for unsupported CMake versions
Show an error icon in the CMake settings, and instead running CMake with
unsupported parameters show an error in the Issues pane.

Arguably it should not be possible to select an unsupported CMake
version in the kit settings at all (neither manually nor automatically
when setting up kits), but this is the less intrusive change for now.

Fixes: QTCREATORBUG-24553
Change-Id: I32caa2ce93d28cbd9db90e2004d60da93d32c68c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-11-19 09:51:27 +00:00
Alessandro Portale
b2a766a79a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Change-Id: I71f54244f1e091315dac2943d9e1bfad6efa56a9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-19 08:42:14 +00:00
Christian Stenger
564fa06399 CMakePM: Fix missing include
Change-Id: I7ed4045aa5b6b85fbf6a332161a3ad0e94bff348
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-09 12:27:35 +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
Nikolai Kosjar
888ea6bbbb CppTools: Take "-include" files into account
Fixes: QTCREATORBUG-20602
Change-Id: Ibfc518fc64ed75f93265db800558ec1d2e424bb4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-05 08:49:24 +00:00
Assam Boudjelthia
df52de2828 Android: get correct value for ANDROID_DEPLOYMENT_SETTINGS_FILE for Qt 6
CMake with Qt 6 which uses android-${target}-deployment-settings.json
file name, we use substitute ${target} with the root node target name
to get the correct file name.

Task-number: QTCREATORBUG-24678
Change-Id: Ib0c82b947b3217b6b763191b22d91ab9674fedce
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-10-02 07:13:08 +00:00
hjk
61bfd32438 ProjectExplorer: Introduce a ProjectConfiguration::kit() function
For convenience, and use it in some places.

Change-Id: I8f7cb502b37b2fbf4cf2d17cac9c6299558332dc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-09-09 06:27:21 +00:00
Christian Kandeler
a7305a60e0 CMake: Parse project on initial load
When opening a project for the first time, the project has already been
added to the session when the BuildSystem object is created, whereas the
code expected a different order.

Fixes: QTCREATORBUG-24318
Change-Id: I8ccfeab7da4e566670f61bfe677a293033bdfe44
Reviewed-by: hjk <hjk@qt.io>
2020-08-12 09:13:33 +00:00
Artur Shepilko
5b53ac9661 Fix compiler warnings about several unused variables
Change-Id: Ic236efdfdfd997719187eec1c19ad2b7f6c044df
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-25 15:23:25 +00:00
Tobias Hunger
1bc3e2f0ba CMake: Be more paranoid about running several cmakes at the same time
Try to be more paranoid about having several cmake binaries run for the
same project at the same time.

Change-Id: I6ceca456e515c0beeff46e6912d15b2dd87283a2
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-06-15 10:34:01 +00:00
Tobias Hunger
82555df811 CMake: Add some debug output
Change-Id: I2ae817c5c810b3c97fef2784fe1b5f25cab3c439
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-06-15 10:33:15 +00:00
Tobias Hunger
01b0d4f8f5 CMake: Remove magic configuration from CMake
Get rid of magic configuration handling in the CMakeProjectManager.

* Use CMakeCache.txt as the sole source of truth, do not keep
  a shadow copy of configuration in the .user file
* Have initial CMake arguments that are easy to edit in batch
  (Fixes: QTCREATORBUG-18179) used whenever no CMakeCache.txt
  file is in the build directory. These allow for any thing that
  can be passed to CMake on the command line.
  (Fixes: QTCREATORBUG-16296)
* Ask when changes to CMake configuration were not applied
  (Fixes: QTCREATORBUG-18504)
* Run cmake with arguments effecting its configuration only when
  the CMake settings are changed in the UI, run CMake without any
  special arguments in all other cases.
* Get rid of the confusing dialog used to keep settings in sync between
  what is in CMakeCache.txt and Creator (Fixes: QTCREATORBUG-23218)

Change-Id: I26d55be7df733f084f5691ecf7d7b4352f58b8e7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-09 16:34:00 +00:00
Tobias Hunger
28c22ff57e CMake: Inject special build targets into list of extracted targets
Inject special targets like all, test and install into the list of
targets that get reported by CMake. This makes those available in
the locator again.

Task-number: QTCREATORBUG-24064
Change-Id: I08f1232d243afbe0800c1dc308a00917c98ccf8a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-06-03 09:46:45 +00:00
Eike Ziller
5b364de168 Use dialogParent() instead of mainWindow()
There are very few reasons to use mainWindow() directly.
Especially for modal dialogs, using dialogParent() is important, since
that guarantees the stacking order in case of other dialogs currently
being open.

Change-Id: I7ad2c23c5034b43195eb35cfe405932a7ea003e6
Reviewed-by: hjk <hjk@qt.io>
2020-06-02 11:44:53 +00:00
Tobias Hunger
59473389b9 CMake: Remove BuildDirManager
The BuildDirManager was used to switch between different
BuildDirReaders. Now that only the FileApiReader is left, that
infrastructure is no longer needed.

Change-Id: I2d339a3407bb633cff6a8f7502b7b09094f63fef
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-04-30 12:08:08 +00:00
Tobias Hunger
0b9513f273 CMake: Simplify CMake Build System states a bit
Merge handleParsingSucceeded and handleParsingSuccess as well as
handleParsingFailed and handleParsingError.

Change-Id: If4f84bdfa2f59cfa0037a941372a1929996be3bd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-04-30 08:06:39 +00:00
Tobias Hunger
5bb5c7b904 CMake: Make sure a CMakeBuildConfiguration always has a CMakeBuildSystem
For this to work, we need to make sure no parsing is triggered before
the project is fully set up. Otherwise it would be QTCREATORBUG-23816
again...

Change-Id: If81f4c6b9c82283abdaa8a635f93ebe0bcaf8159
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-04-22 12:09:14 +00: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
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
Eike Ziller
deb0eaf795 Merge remote-tracking branch 'origin/4.12'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp

Change-Id: I34c3d1fd5be90537e37d15e00b1a0d455d1bf81d
2020-04-14 09:47:38 +02:00
Tobias Hunger
a53308cde6 CMake: Do not create .cmake directories in source dir
Only initialize the CMakeBuildSystem after the
CMakeBuildConfiguration has been fully set up. The "builddirectory"
was still pointing to the source directory, so creater configured
cmake in the source directory, leading to a useless directory being
left in the source tree that does not belong there.

Fixes: QTCREATORBUG-23816
Change-Id: I7c9b6ae1f8d999043e700cd9f2d56418c22f2abf
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-04-09 12:22:32 +00:00
Tobias Hunger
10e79cebc9 BuildSystem: Add buildConfiguration() method
Add a buildConfiguration method that returns the saved
BuildConfiguration or the active BuildConfiguration if none is
set.

Change-Id: I8af25aa1037f59a0091900bac7eb84fed9e5fbb0
Reviewed-by: hjk <hjk@qt.io>
2020-03-23 13:16:15 +00:00