Commit Graph

70 Commits

Author SHA1 Message Date
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Cristian Adam
ee4c998ff3 CMakePM: Add supprot for CMakePresets version 3
This includes Condition and toolchainFile

https://cmake.org/cmake/help/v3.21/manual/cmake-presets.7.html

Task-number: QTCREATORBUG-24555
Change-Id: I1026390af67b2be1aa0c3b02b654fc19442d3c89
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-09-30 08:34:07 +00:00
Cristian Adam
45a275e054 CMakePM: Use architecture and toolset for project import
This fixes issues with Visual C++ generator, which needs the right
parameters to pinpoint the right compilers.

Also use CMAKE_TOOLCHAIN_FILE for qmake detection.

Change-Id: I6edc84c7ed1a892fbc5545ff61dc06ac20720f0a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-09-30 08:34:00 +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
hjk
21c5d3499b CMakeProjectManager: Compile fix
Amends bcadea228.

Change-Id: I4f85780ffa6c7c79c70c096b457065f95e96355f
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 16:15:11 +00:00
hjk
985c8b1a43 ProjectManager: Return FilePaths from ProjectImporter::importCandidates
Proliferates FilePath use a bit further. Actual changes to the
individual importers are left for further patches.

Change-Id: Ie7c6b2e3f4ac7d0eca6d2f56d30fb23354bb404b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-09-26 16:02:55 +00:00
hjk
bcadea2285 CMake: FilePath-ify CMakeProjectImporter
Change-Id: Ifffd3328afae60a4015d88e36b3e60b4ee492c3b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-09-26 15:16:36 +00:00
Cristian Adam
5a156395c4 CMakePM: configure presets review fixes
Amends 2ab1e76ca9

Change-Id: Id10f0d4da6a60223d68af3cea6c5263f7c8c62f2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 12:04:37 +00:00
Cristian Adam
2ab1e76ca9 CMakePM: Add support for configure CMake presets
This patchset will add support for version 1 of the CMakePresets
feature that has been implemented in CMake 3.19

https://cmake.org/cmake/help/v3.19/manual/cmake-presets.7.html

The tests/manual/cmakepresets contains a manual test example for this
feature.

Task-number: QTCREATORBUG-24555
Change-Id: I93aba1ab4f090613d0b21d970b5b651d12c922af
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-09-14 11:50:49 +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
Alessandro Portale
afe0b5a42d Utils: Use FilePaths alias instead of QList<FilePath>
Change-Id: I2eb0956377e46a34e73208b301eb662704a25e8b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-07-21 16:05:38 +00:00
Cristian Adam
8d99df9a7c CMakePM: remove unused headers, enforce sorting of headers
Used clangd hints.

Change-Id: Iade4de67c1d2e5fdd1a880c5603b31203170ebbe
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-11 08:43:09 +00:00
Cristian Adam
5edbf915a4 CMakePM: Fix registering CMake as version 0.0.0
When importing a CMake build, the CMake version that's used in the build
could be registered as "CMake 0.0.0". This is obviously wrong.

Fixes: QTCREATORBUG-26999
Change-Id: I1401106806c4356516e8235a3767d9615e4d428d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-29 12:41:34 +00:00
Eike Ziller
a760d5ad81 CMake: Make QML debugging state reflect build system state
After parsing the CMake response, we make the configuration variables
table reflect the actual configuration in the build directory. It is one
of our "promises" that we do not break an existing build configuration,
to avoid unexpected rebuilds.

This was not quite true for the "QML debugging and profiling" setting.
When that setting and the actual build directory disagreed, the user
would get a dialog asking for running CMake with additional parameters,
and when running CMake via the button in projects mode or the menu, it
would just change these configuration parameters, potentially leading to
an unexpected complete rebuild of the application.

So, after parsing check if the actual CMake configuration matches our
QML debugging setting, and if not, change the setting to "Leave at
Default", to ensure that we don't mess with the build.

Fix the "Run CMake" button state (in the "Current Configuration") when
changing the QML debugging option, which should become bold, if the
CMake parameters change.

Amends 2577ce8ba1 and fixes the drawback
mentioned there, i.e. setting the build directory of a "Debug" build
configuration to an existing build directory with QML debugging
disabled, will now simply set the QML debugging option to "Leave at
Default" instead of forcing it to "Enabled".

Change-Id: Ie6d4875d59319687d94e44e459ca76038e5813c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-06-13 10:03:38 +00:00
Eike Ziller
948f0070fa macOS: Fix importing command line builds with CMake
When configuring a CMake project on the command line, CMake will
(correctly) find and use the compiler from the current developer
directory, usually somewhere in
/Applications/Xcode.app/Contents/Developer

But Qt Creator auto-detects and sets up the compiler /usr/bin/clang(++)
for desktop kits. This leads to a compiler mismatch between kits and the
imported build, and to new kits registered in Qt Creator for the import.

Since /usr/bin/clang(++) is just a thin wrapper that resolves to the
compiler in the current developer directory, resolve that in Qt Creator
with "xcrun -f <command>" too (caching the result), and include that
when comparing toolchains for importing builds.

Fixes: QTCREATORBUG-27591
Change-Id: I301e2a4e267450b488b49d0c32d4ce89001bb5ec
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-06-13 10:03:16 +00:00
Eike Ziller
2577ce8ba1 CMake: Add 'Profile' configuration
Get rid of the hardcoded QML Debugging for Debug & RelWithDebInfo from
the project template, because RelWithDebInfo is actually a good
configuration for doing releases (we use it for Qt Creator), and
enabling QML debugging for releases is a bad idea.

Instead enable QML Debugging in Qt Creator for the Debug configuration,
and add a 'Profile' configuration that is 'RelWithDebInfo + QML
Debugging'.

When importing a build, we only set the "QML debugging" option of the
build configuration, if it is enabled in the imported build, even if it
uses CMAKE_BUILD_TYPE=Debug .

One drawback: When not importing a build, but just setting the build
directory of a "Profile" or "Debug" configuration to an existing build,
Qt Creator asks if it should apply "-DCMAKE_CXX_FLAGS=-DQT_QML_DEBUG".
The user can choose not to, but then is asked the next time again, and
it is not obvious that the "QML debugging" option is responsible for
this.

That is somewhat orthogonal to this change though: Even without this
change, if the user changes the QML debugging option from "Leave at
Default" to "Enable", the same happens, and it is also not clear to the
user how to get rid of it. The user might not even have realized that
they changed the option (e.g. on platforms where the mouse wheel cycles
combo box values).

I think the correct solution is to 1. make clearer where the CMake flags
came from in that dialog, 2. allow the user to cancel a build from that
dialog, 3. allow the user to discard these changes (by changing the
setting) from that dialog. But that is for another patch.

Amends 3300182d40
Amends 77fed0b0fd

Change-Id: I95de59473b67c5afd6a53ea7f49838dbaef770d4
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-05-24 13:34:29 +00:00
Artem Sokolovskii
c23aa1c656 CmakeProjectManager: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464
Change-Id: Iabe3a621efa56282bf1511f540c98fdf5d8da270
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-20 12:55:20 +00:00
hjk
ba97c741c8 CMake: Replace parseCMakeCacheDotTxt() function
... by direct use of  CMakeConfig::fromFile(). It was only duplicating
checks that are done on the user side already.

Change-Id: Iaf5e89c924c2b0a9080db9fe160970bbf6e33154
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-05-05 16:12:41 +00:00
Jarek Kobus
8e0ae8ba96 QtcProcess: Limit the inclusion of qtcprocess.h
Move the rest of QtcProcess enums to processenums.h.
Move ExitCodeInterpreter into processenums.h.
Remove superfluous Utils:: prefix.

Change-Id: Iaa596f353d33d6930085a621b114cc15a35caa80
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-02 13:30:39 +00:00
hjk
1fc83d2a56 Utils: Wrap various file system iteration flags and filters
... into a single class.

This makes passing them around as a whole easier, and opens a path
to have "generic" filters in form of a lambda or such.

Change-Id: Ibf644b2fedcf0f1a35258030710afff8f5873f88
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-26 13:13:41 +00:00
David Schulz
22f4e9497d CMake: Fix build dir scan filter
Fixes: QTCREATORBUG-26846
Change-Id: I54f0249410cf0dd5cc6703767cea187a2d843868
Reviewed-by: hjk <hjk@qt.io>
2022-01-17 12:25:52 +00:00
Cristian Adam
06410dcb80 CMakePM: Fix importing of Qt projects
Amends ca04d9afcd

Fixes: QTCREATORBUG-25767
Change-Id: I099662a52bbae40541698edb80ba0576eda70884
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-11-04 17:26:49 +00:00
David Schulz
66b97761b6 CMake: use filePaths to scan for build directories
Change-Id: I34ccf91d9ca2b8e0b1927ad8b73e2ce2b54ecf0e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-09 09:47:18 +00:00
hjk
3aa324ef1f CMake: Make CMakeConfig a proper class
Looks a bit more "object oriented" in my book.

Change-Id: I6a3b1b4691ec1c7465f652608678e8f31e7e52a7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-07-21 13:25:30 +00:00
hjk
3b779fb8dd CMakeProjectManager: Use "cooked types" in DirectoryData
Less conversions cycles at the price of a few more temporary bytes.

Change-Id: Ibda82e02d7b83944f5db38ac7cf75c4bae4f55ec
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-07-21 06:25:06 +00:00
hjk
a58dd22f2d Utils: Use FilePath in TemporaryDirectory API
This helps to lower impedance in the using code.

Even though TemporaryDirectory will very likely always stay on the local
host, this is one of the entry points into path related string
manipulation
that we want to base on FilePath nowadays.

Change-Id: I302016b8d65e54df94296659a54a93935d9e4627
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-02 05:05:12 +00:00
hjk
430e81facd All: Replace most SynchronousProcess by QtcProcess
Change-Id: I0bf22fef2cd4a7297ef5a1e9aa9c3e2b9348ba42
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-23 07:55:31 +00:00
hjk
77d7b24326 Utils: Make Environment::setEnglishOutput a proper member function
The previous indirection was useful as long as they were overloads
for QProcessEnvironment and QStringList, but these are gone now.

Change-Id: I5066bd2e72fd06948a5cc7bbac6dda9006db96ed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-21 15:07:34 +00:00
hjk
90ad902486 Utils: Remove CommandLine argument from QtcProcess::run{,Blocking}
Makes run() more similar to what start() looks like.

Also add some asserts to make sure run() and related functions are
only called on SyncronousProcesses, as these are currently the only
ones where this works.

Change-Id: Idee6076c3f40a484db5c17f5bb348698cc83d220
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-19 13:01:51 +00:00
hjk
c262f40b67 Utils: Re-do Replace SynchronousCommand::flags by a named bool
The potential extensibility was never used, and a similar use case
in QtcProcess (setLowPriority()) used a named setter.

Change-Id: I87d84ea2206995d5069265f8df78f40cf2ba8a36
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-05-07 14:09:56 +00:00
hjk
635993fbdc Revert "Utils: Replace SynchronousCommand::flags by a named bool"
This reverts commit c617632e4d9291f1b50ec0c7e1a914a6a689284e.

To early, dependencies missing.

Change-Id: I91433aebbaf2c04cbb212585deb3cde5f3208974
Reviewed-by: hjk <hjk@qt.io>
2021-05-07 08:35:58 +00:00
hjk
9a7a0098a3 Utils: Replace SynchronousCommand::flags by a named bool
The potential extensibility was never used, and a similar use case
in QtcProcess (setLowPriority()) used a named setter.

Change-Id: I77d84ea2206995d5069265f8df78f40cf2ba8a36
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-05-07 08:24:18 +00:00
hjk
c69eb63767 Utils: Remove SynchronousProcess::{setP,p}rocessEnvironment
Change-Id: I761c04a08bc7e52b2d57d90cb8aa93ec9f3db724
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-05-05 12:25:57 +00:00
Christian Stenger
ca04d9afcd CMakePM: Fix compile for gcc 7
Due to a compiler bug the content of the raw string is
handled inside the preprocessor and the cmake comments
end up as being noticed as unknown preprocessor directives.

Change-Id: I3f235cfdd0799a6bb94743e2910663d9b0d3385d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-04-28 09:53:09 +00:00
Alessandro Portale
b2b6c64e6a Don't detach temporary containers
Change-Id: I736cfc61c81995a81b056b3e3e5703ded5912525
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-24 08:27:10 +00:00
Cristian Adam
ad2155d793 CMakeProjectManager: Add compiler for Visual Studio / Xcode imports
Visual Studio / Xcode generators are not setting the CMAKE_C|XX_COMPILER
variables, and when importing such a build the generated kit will have
no
compilers and won't be much of a use.

Luckily CMAKE_LINKER has the path to link.exe / ld, which is the same
path for the compiler cl.exe / clang.

Change-Id: Id21bb0ec2d5aa6ab5a185e03992477c433ac4798
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-11 17:38:50 +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
707a3cfaf3 CMakeProjectManager: Use CMAKE_HOME_DIRECTORY as source directory
The CMakeCache.txt file has CMAKE_HOME_DIRECTORY pointing to the
project source directory used to configure the project.

When importing a cmake build the CMAKE_HOME_DIRECTORY from
CMakeCache.txt might not point to the same CMakeLists.txt that was
opened as a project.

qt-cmake-standalone-test from Qt6 uses a CMake template project which
does a add_subdirectory with the test source directory, which will not
work if opened standalone.

Normally this is a user error though, so ask the user if this was
intended, before actually importing the build.

Task-number: QTBUG-88776
Change-Id: Ifdd5e1d1cb8a1ef9955d22493eba3a1a55dc689f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-01-08 16:25:24 +00:00
Cristian Adam
d3595110f1 CMakeProjectManager: Fix importing Qt6 projects
The code that detected the qmake path for the project stopped
working with Qt 6.0.

The new code will run a small CMake project that will output
the path of qmake from the CMake world, and not something that
Qt Creator does from outside.

Fixes: QTCREATORBUG-25100
Change-Id: I9071648c2e60eb89d0dc8f08aed793167b42a365
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-06 17:10:13 +00:00
hjk
c427a0d281 CMakeProjectManager: Code cosmetics
Change-Id: I102f0c6104a36b0637e7e713ab4b06b2b97984fc
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-01-04 12:55:12 +00:00
Cristian Adam
4ae5516453 CMakeProjectManager: Use canonical paths for compiler match import
On Linux (Ubuntu 20.04) Qt Creator would use /usr/bin/g++ as
compiler for C++. CMake would pick /usr/bin/c++ as C++ compiler.
Both of them are symlinks to /usr/bin/x86_64-linux-gnu-g++-9

There is no need to create imported kits for something which
is the same compiler.

Fixes: QTCREATORBUG-25069
Change-Id: I90e0f7b1977ace3f7995ce09f4b3fcfa64d02b72
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-12-11 16:17:30 +00:00
Cristian Adam
5b1cff753a CMakeProjectManager: Match only on Cxx and C languages on import
This way Qt Creator won't be creating imported kits on every import.

On Windows the language "RC" is not part of the kit languages and
would always discard valid matching kits.

Fixes: QTCREATORBUG-25069
Change-Id: Ib4ec323ebf514c82e5036f7d0123100a75f3ea10
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-12-10 08:20:53 +00:00
Eike Ziller
2a05186194 Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
	CMakeLists.txt

Change-Id: I799060da2cb299bb0c49a3da3530fad18427a23c
2020-08-21 10:08:55 +02:00
Wojciech Smigaj
795ccfbffc CMake: Register CMake tools detected while scanning build directories
Fixes: QTCREATORBUG-24502
Change-Id: Idf96e666e783edbf8b0fbe4216affb80b0464104
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-20 21:11:33 +00:00
Eike Ziller
9df06af9bd CMake: Fix comparison of source paths when importing
We need to check canonical paths with canonical paths.
Otherwise we get a mismatch when using e.g. a linked directory for the
source path on the command line and then try to import the build in Qt
Creator.

Change-Id: I153be74b6cfdf5070e023780604ce64c92df0e6d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-08-18 12:24:15 +00:00
hjk
e1c88116b3 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
(cherry picked from commit 430a33dcd9)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-06 11:15:18 +00:00
hjk
430a33dcd9 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-06 06:07:13 +00:00
Tobias Hunger
b321f54186 CMake: Update log output of CMake Project Importer
Change-Id: I18c6890ecad58d6e078492af30c5509d9db766f9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-18 14:13:56 +00:00
Tobias Hunger
054f5617f8 CMake: Make import of build directories using Qt 6 work
Make import of build directories using Qt 6 work. This assumes that
Qt 6 will use the same layout as Qt 5 and that there is qmake (which
is assumed everywhere in Creator right now).

Change-Id: I37194b186127befb3df32ebacf86c032c71ef18a
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-18 14:13:43 +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