Commit Graph

191 Commits

Author SHA1 Message Date
Orkun Tokdemir
5380ad9d58 Tests: Add test for AUTOMOC_MOC_OPTIONS
Fixes: #23894
2023-05-31 12:59:20 -04:00
Orkun Tokdemir
08d49cfee6 Autogen: Add AUTOMOC test /w file(Generate)
Fixes: #20382
2023-05-19 16:28:51 +02:00
Orkun Tokdemir
033dc7ee2f Autogen: Add AUTOGEN_USE_SYSTEM_INCLUDE target property
`AUTOGEN_USE_SYSTEM_INCLUDE` was added. `AUTOGEN_USE_SYSTEM_INCLUDE`
is a boolean property that can be set on a target to indicate that the
autogen target include directory should be added as a system include
directory or normal include directory to the target.
2023-05-03 09:03:46 -04:00
Orkun Tokdemir
315b13432c Autogen: Update test comments about Qt versions 2023-04-26 18:12:12 +02:00
Orkun Tokdemir
64b44b362b Autogen: Add AUTORCC test /w AUTOGEN_BUILD_DIR 2023-04-26 18:07:04 +02:00
Orkun Tokdemir
c5c3aff1f5 Autogen: Add INTERFACE_AUTOMOC_MACRO_NAMES target property
Add this target property to specify macro names that propagate to
dependents as `AUTOMOC_MACRO_NAMES`.  The dependents will automatically
generate MOC files for source files that contain the inherited macro
names.

Co-Authored-By: Craig Scott <craig.scott@crascit.com>
Fixes: #19679
2023-04-09 20:51:15 +10:00
Orkun Tokdemir
b3d1797508 Autogen: Add CMAKE_AUTO*_EXECUTABLE variables
Add the `CMAKE_AUTOMOC_EXECUTABLE`, `CMAKE_AUTOUIC_EXECUTABLE`, and
`CMAKE_AUTORCC_EXECUTABLE` variables to initialize the corresponding
`AUTO{MOC,UIC,RCC}_EXECUTABLE` target properties.

Fixes: #20071
2023-03-22 07:31:56 -04:00
Kitware Robot
33abef7416 Revise C++ coding style using clang-format-15
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 15.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Fixes: #24315
2023-01-18 16:20:47 -05:00
Brad King
1d3a98456d Tests: Fix Qt*Autogen.MocIncludeSymlink test on Windows
This test runs the `Tests/QtAutogen/MocInclude` test inside symlinked
directories.  The `MocInclude` test previously relied on
`get_filename_component(... REALPATH)` to get the real source tree
location and compute the path to `AutogenCoreTest.cmake` from it.
However, this does not work on Windows due to issue #17206.  The
test has been passing on Windows only on machines where symlinks
cannot be created and the main part of the test is skipped.  On
machines where symlinks can be created, the test failed with that
approach.  Fix it by explicitly passing the path to the helper
script in as a cache entry.  Avoid relying on `REALPATH`.
2022-02-25 11:32:04 -05:00
Craig Scott
a742088472 Tests: Add support for testing Qt6
The minimum CMake version for Qt6 is 3.16, so all the calls to
cmake_minimum_required() are updated here to enforce that
minimum. This will avoid any CMake version-related warnings
from Qt.

Avoid hard-coding Qt5 where the tests could now be using
Qt5 or Qt6.

Fixes: #22188
2021-10-04 22:10:57 +11:00
Brad King
d2a6e160aa AUTOUIC: Revert "Fix generating of dependency rules for UI header files"
Revert commit e5ec0e52f4 (AUTOUIC: Fix generating of dependency rules
for UI header files, 2021-07-22, v3.21.1~8^2) because it caused
regressions.  For example, changing one C++ source can now cause many
others to rebuild.  Revert the change pending further investigation.

Fixes: #22531
Issue: #16776
2021-08-19 12:23:16 -04:00
Alexey Edelev
283e8d8d04 AUTOUIC: Add test for cyclic dependency between UI headers and timestamp
Follow up test for the commit 9cebdbec.
2021-07-28 18:43:18 +02:00
Alexey Edelev
e5ec0e52f4 AUTOUIC: Fix generating of dependency rules for UI header files
We could not rely on .ui files when generating the ninja rules
for the generated UI header files. .ui files might be added to the
target sources but never processed by AUTOUIC afterward, since UI
header files are never included in a source code. Instead of adding
dependency rules based on the .ui files, this approach scans
non-generated source files for includes of the UI header files,
as AUTOUIC does. This gives the consistent set of UI header files
at configure time, that could be used to generate byproducts rules
for the AUTOUIC. Also, the path to the generated UI header file depends
not on the .ui file location but on the include line is used in source
files.

Fixes: #16776
2021-07-23 15:37:31 +02:00
Brad King
e69a328725 Merge topic 'autogen-moc-version'
5b0ea5874a AutoGen: Retrieve Qt version from moc as fallback

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6027
2021-04-26 11:31:54 -04:00
Joerg Bornemann
5b0ea5874a AutoGen: Retrieve Qt version from moc as fallback
Consider the case where the find_package call for QtCore is wrapped in a
function call. Then AutoGen cannot determine the Qt version, because it
only looks at variables and directory properties. The former don't leave
the function scope and the latter are not set by default.

As a fallback, locate the moc executable via its target and call it with
the --version argument to determine the Qt version.

Issue: #22028
2021-04-23 10:49:07 +02:00
Brad King
5a8b37e53b Merge topic 'autogen-clear-early-source-cache'
b84f1e6159 Autogen: Restore mocs_compilation in OBJECT libraries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6024
2021-04-21 10:42:17 -04:00
Brad King
b84f1e6159 Autogen: Restore mocs_compilation in OBJECT libraries
Since commit f65f20938c (Autogen: Avoid processing CSharp targets,
2020-11-12, v3.20.0-rc1~301^2) we collect all sources for a target
earlier than previously.  Clear the sources cache so that it will be
re-computed later after AUTOGEN processing.

Fixes: #22085
2021-04-20 16:04:08 -04:00
Adriaan de Groot
44ad3f0b7f ctest: Support multiple -L and -LE options to mean "AND"
Fixes: #21087
2021-03-28 12:04:05 +11:00
Alexey Edelev
1265c65b33 AUTOUIC: Collect ui header files for Ninja generator
The '<user target>_autogen/timestamp' target supposed to
generate ui header files using the 'uic'. Ninja must have
information about these header files as a result of generating.

The fix collects .ui files of the user target and generates
a list of the ui headers that need to be added to the generating
results of the '<user target>_autogen/timestamp' target.

The case when the .ui files are not specified and collected by
AUTOUIC from the include directives of the project source files
is not covered in this patch.

Fixes: #16776
2021-02-23 13:46:40 +01:00
Joerg Bornemann
fefba42e37 Add a failing test case for #21620
Extend Qt(4|5)Autogen.RerunMocBasic to check the following situation:

Class MyObject3 is a QObject-derived class without Q_OBJECT macro.
It's declared in myobject3.h that is not included by any file that is
input of AutoMoc (this is why we had to add PlainObject).

If myobject3.h were included by main.cpp, then AutoMoc would already
track this dependency, because main.cpp has a Q_OBJECT macro.

After the initial build(s), the Q_OBJECT macro is added to myobject3.h,
and an incremental build is run. With Qt >= 5.15 and Ninja, the build
fails, because AutoMoc is not run due to the missing dependency to
myobject3.h.
2021-01-06 20:16:36 +01:00
Joerg Bornemann
2999c40dd9 Extend QtAutogen/RerunMoc
Test that removing / adding a Q_OBJECT macro doesn't break incremental
builds.

This was initially done to test the fix for #21620, but the test passes
without the fix. The reason is that test1.h is included by main.cpp, which
contains a Q_OBJECT macro, meaning that test1.h is in AutoMoc's
dependencies transitively.
2021-01-06 20:16:36 +01:00
Joerg Bornemann
f623664e87 Do not use try_compile in RerunMocBasic test
In a subsequent patch we want to extend RerunMocBasic to test the
removal and addition of Q_OBJECT macros works when building
incrementally.

For that, properly generated dependencies are necessary. Currently, the
MocBasic test project is configured using try_compile, and that turns
off the generation of depfiles.

Replace the try_compile call with execute_command calls that first
configure and then build the test project.
2021-01-06 20:16:36 +01:00
Brad King
92d7b456e5 Autogen: Add support for per-config sources
Fixes: #20682
2020-12-16 14:04:30 -05:00
Brad King
3ffebbaefb Tests/QtAutogen: Forward build configuration in multi-config generators 2020-12-16 10:09:09 -05:00
Brad King
1c3d2d0951 Tests: Skip Qt*Autogen.MocSkipSource case for Xcode "new build system"
This test case enables AUTOMOC on the same sources in two separate targets.
This causes the `moc_*.cpp` generation custom commands to be added to multiple
`_autogen` targets, which is not allowed by the Xcode "new build system".
Skip the part of the test that triggers this problem for now.

Issue: #21205
2020-09-18 13:46:39 -04:00
Brad King
5a15fcf597 Tests: Avoid duplicate custom commands in QtAutogen.AutogenOriginDependsOff 2020-09-18 12:49:09 -04:00
Joerg Bornemann
9ac3503d30 AutoMoc: Re-run moc if a dependency is missing
AutoMoc uses the moc-emitted dependency file of Qt 5.15 to track
dependencies. Such a dependency may well live outside the project and
can vanish, for example when installing a new compiler version.

This situation was detected before, but merely a warning was issued.
Now, we're considering a generated file as out of date if a dependency
is missing and re-generate it.

We also have to remove the missing dependency from the ParseCache.
Otherwise the AUTOMOC target for all generators other than Ninja will
always be out of date.

The ParseCacheChanged flag had to be made atomic, because we're
potentially accessing it from multiple threads. The dependencies vector
itself is not vulnerable in this regard, because there's one vector per
file, and we're accessing exactly one ParseCacheT::FileHandleT per thread.

Fixes: #21136
2020-09-09 12:51:28 +02:00
Brad King
776059ef0f Merge branch 'backport-3.17-automoc-depend-project-file' 2020-08-31 13:10:31 -04:00
Joerg Bornemann
6b20bbd2dd AutoMoc: Restore support for re-running after project file changes
For Qt >= 5.15.0 and Ninja generators AutoMoc creates a depfile to let
Ninja decide when to run AutoMoc.  This was introduced by commit aebfbcaa46
(AutoGen: Use depfiles for the XXX_autogen ninja targets, 2020-01-14,
v3.17.0-rc1~58^2).

However, AutoMoc was not triggered after adding a new moc-able file to
the project. This patch adds the project file (and potentially included
files) to the dependencies in the depfile.

Now, a re-run of AutoMoc is triggered if the project file changes.

Fixes: #21127
2020-08-31 13:07:23 -04:00
Brad King
db659e18bc Merge branch 'backport-3.17-automoc-path-prefix-off' 2020-08-10 10:49:18 -04:00
Brad King
e503fbe38a Merge branch 'backport-3.16-automoc-path-prefix-off' 2020-08-10 10:41:06 -04:00
Joerg Bornemann
4c33b305a0 Autogen: Turn off moc path prefix generation by default
Change the default value of `CMAKE_AUTOMOC_PATH_PREFIX` to `OFF` to
restore compatibility with behavior of CMake 3.15 and below.

C++ source files that are generated by Qt's meta object compiler (moc)
include the header file that was passed as input argument to moc. This
is usually a path relative to the source directory, for example

    #include "../../source/dir/myobject.h"

That is problematic for reproducible builds as described in #18815.
To cope with that, the target property AUTOMOC_PATH_PREFIX was
introduced in CMake 3.16 by commit d018d27c10 (Autogen: Add moc path
prefix generation (AUTOMOC_PATH_PREFIX), 2019-09-13, v3.16.0-rc1~94^2~4).
The property is default-initialized from the variable
`CMAKE_AUTOMOC_PATH_PREFIX`, which defaults to `ON`.

If this property is ON, and myobject.h is located in an include
directory of the target, moc-generated C++ files include the file
without the "path prefix":

    #include "myobject.h"

This behavior, however, can break projects that have equally named
header files in different include directories.  As "not breaking
existing projects" trumps "have reproducible builds by default" we
change the default of `CMAKE_AUTOMOC_PATH_PREFIX` to `OFF`.

Also, it is now possible to pass `-DCMAKE_AUTOMOC_PATH_PREFIX=ON` on the
CMake command line.  Before, it was overridden in `CMakeGenericSystem`.

Fixes: #20598
Issue: #18815
2020-08-10 10:36:17 -04:00
Cristian Adam
7051250a6c Unity Builds: Do not set SKIP_AUTOGEN to source files
Fixes: #21028
2020-07-29 17:57:50 +02:00
Brad King
eb705b9531 Update links to gitlab.kitware.com repos to add -/
GitLab now uses a `/-/` component between the `group/project` part of
the URL and the `{issues,merge_requests,tree}` part so that it can
support `group/subgroup/project` with arbitrary depth.
2020-05-26 11:38:01 -04:00
Robert Maynard
cd9c3c000f Tests: Update QtAutogen codeeditor test only include headers needed 2020-05-21 11:32:01 -04:00
Joerg Bornemann
f765fdea03 AutoGen: Use moc's feature to output dependencies
In Qt version 5.15.0 moc learned to output the dependencies
of the generated file.

This commit enhances JobCompileMocT to read the dependency file
written by moc. The dependencies are stored in the same cache that's
used for the dependencies determined by dependency filters.

The dependency filter functionality is turned off if moc's dependency
output feature is used.

Fixes: #17750
Fixes: #19058
2020-01-28 11:16:11 -05:00
Sebastian Holtermann
9eab3cad6a Tests: Add AUTOGEN policy CMP0100 test
Add a test for policy CMP0100 that configures whether or not
AUTOMOC and AUTOUIC should process .hh header files.
2020-01-04 11:33:05 +01:00
Sebastian Holtermann
8c2be3ae94 Tests: Restore Autogen/SameName .hh header test
In commit 7fa7f55230, the Autogen/SameName test
was changed to not test .hh header file processing in AUTOGEN anymore,
because we had to revert that feature.  Since we now support .hh header file
processing in AUTOMOC again, we can restore the Autogen/SameName test for
that.
2020-01-04 11:33:04 +01:00
Brad King
7fa7f55230 Autogen: Revert processing of .hh files for compatibility
Since commit 4a9154537c (Autogen: Use cmake::IsHeader/SourceExtension
for file type detection, 2019-07-02, v3.16.0-rc1~470^2~4) we process
`.hh` files with `AUTOMOC`.  However, this change can break existing
projects that do not expect the behavior.  Revert it for now.  It can
be restored later via a policy.

Fixes: #20101
2019-12-18 05:34:27 -05:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Sebastian Holtermann
1933ade9f1 Tests: At QtAutogen.MocIncludeSymlink test 2019-09-18 11:48:23 -04:00
Sebastian Holtermann
706d9738a6 Tests: Merge QtAutogen.MocIncludeStrict and MocIncludeRelaxed 2019-09-18 11:48:10 -04:00
Sebastian Holtermann
8214ad442f Tests: Autogen: Extend SameName test with additional header extensions
This adds additional headers with suffixes ".hh" and uppercase ".H" to the
QtAutogen/SameName test.
2019-07-04 12:30:40 +02:00
Sebastian Holtermann
1a2d6bdefc Tests: Autogen: Use valid rcc compression levels
Avoid the invalid compression level 0 when invoking rcc.
It let's rcc fail with an error since Qt 5.13.
2019-07-01 09:18:24 -04:00
Sebastian Holtermann
58f04b6ecf Autogen: Add ManySources test
The QtAutogen/ManySources test generates a number of source, header, .ui and
.qrc files that get AUTOMOC, AUTOUIC and AUTORCC processed.  This stresses the
concurrency framework in `cmQtAutoMocUic` and should reveal any issues
with that.
2019-04-15 16:07:14 +02:00
Brad King
06dab0f0e5 Tests: Fix Qt*Autogen.GlobalAutogenTarget to use matching generator
Build the GAT project with the same generator as the rest of the test.
This was accidentally left out of commit 8c8731b422 (Autogen: Add test
for CMAKE_GLOBAL_AUTOGEN/RCC_TARGET, 2018-11-11, v3.14.0-rc1~396^2~2).
2019-04-10 10:01:19 -04:00
Sebastian Holtermann
91344e7a46 Autogen: Fix RerunMocPlugin test for Ninja generator 2019-02-15 10:56:55 +01:00
Sebastian Holtermann
a40864ae53 Autogen: Refactor RerunRccDepends test with fixed timestamp comparison
This refactors and simplifies the QtAutogen.RerunRccDepends test.
Repetitive task are packed into macros.
By using version strings to store file timestamps, timestamp comparison
becomes more reliable.  Test status and error messages are improved.
2019-02-13 23:01:46 +01:00
Sebastian Holtermann
724359489e Autogen: Refactor RerunRccConfigChange test
This refactors and simplifies the QtAutogen.RerunRccConfigChange test.
Repetitive task are packed into macros.
Test status and error messages are improved.
2019-02-13 22:54:32 +01:00
Sebastian Holtermann
6ed4ae4bad Autogen: Refactor RerunMocBasic test with fixed timestamp comparison
This refactors and simplifies the QtAutogen.RerunMocBasic test.
Repetitive task are packed into macros.
By using version strings to store file timestamps, timestamp comparison
becomes more reliable.  Test status and error messages are improved.
2019-02-13 22:54:32 +01:00