https://bugs.kde.org/show_bug.cgi?id=496537

            Bug ID: 496537
           Summary: KDEClangFormat.cmake:98 with cmake 3.31.0 generating
                    hundreds of lines of warnings with many kde packages
    Classification: Frameworks and Libraries
           Product: extra-cmake-modules
           Version: unspecified
          Platform: Other
                OS: Other
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: ecm-bugs-n...@kde.org
          Reporter: 1i5t5.dun...@cox.net
  Target Milestone: ---

ECM's git-master KDEClangFormat.cmake file, with cmake 3.31+ and clang(with
clang-format) installed, is now triggering hundreds of warnings (can be 1000+
lines!) from file line 98.

I'm building kde from git-master using the gentoo/kde repository ebuilds for
that purpose.  Unfortunately I couldn't find git-master in the version list
above.  Current extra-cmake-modules HEAD is
1cc17521fefd7adb0631d24a03497bcf63b9512d from Nov 8.

Presumably this hasn't been caught yet at the kde level because nobody's
running cmake 3.31+ yet; Gentoo only got it Nov 8 (significantly, the same date
as the ECM HEAD above) and the release was likely not long before that.

I have clang installed to build firefox so KDEClangFormat.cmake triggers its
checks.  Unfortunately line 98 is now triggering up to hundreds of these in
most kde builds (this one's the first from my last ksvg build, which "only" had
46 such warnings according to grep, as mentioned some kde packages have
hundreds):

(Quotes demarcated by >>>> <<<<)
>>>>

^[[33mCMake Warning (dev) at /usr/share/ECM/kde-modules/KDEClangFormat.cmake:98
(add_custom_command):
The following keywords are not supported when using
add_custom_command(TARGET): DEPENDS.

Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
command to set the policy and suppress this warning.
Call Stack (most recent call first):
/usr/share/ECM/kde-modules/KDEFrameworkCompilerSettings.cmake:66
(kde_clang_format)
CMakeLists.txt:18 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

<<<<

The mentioned cmake --help-policy CMP0175 output is (note the version added:
3.31, and for this instance anyway, the TARGET does not accept DEPENDS bit, tho
I didn't check if they're all TARGET DEPENDS warnings or not):

>>>>

CMP0175
-------

.. versionadded:: 3.31

``add_custom_command()`` rejects invalid arguments.

CMake 3.30 and earlier silently ignored unsupported keywords and missing or
invalid arguments for the different forms of the ``add_custom_command()``
command. CMake 3.31 implements more rigorous argument checking and will flag
invalid or missing arguments as errors.

The ``OLD`` behavior of this policy will accept the same invalid keywords or
arguments as CMake 3.30 and earlier. The ``NEW`` behavior will flag the
following as errors that previously went unreported:

* The ``OUTPUT`` form does not accept ``PRE_BUILD``, ``PRE_LINK``, or
``POST_BUILD`` keywords.
* When the ``APPEND`` keyword is given, the ``OUTPUT`` form also does not
accept ``BYPRODUCTS``, ``COMMAND_EXPAND_LISTS``, ``DEPENDS_EXPLICIT_ONLY``,
``DEPFILE``, ``JOB_POOL``, ``JOB_SERVER_AWARE``, ``USES_TERMINAL``, or
``VERBATIM`` keywords.
* The ``TARGET`` form requires exactly one of ``PRE_BUILD``, ``PRE_LINK``, or
``POST_BUILD`` to be given.  Previously, if none were given, ``POST_BUILD``
was assumed, or if multiple keywords were given, the last one was used.
* The ``TARGET`` form does not accept ``DEPENDS``, ``DEPENDS_EXPLICIT_ONLY``,
``DEPFILE``, ``IMPLICIT_DEPENDS``, ``MAIN_DEPENDENCY``, ``JOB_POOL``,
``JOB_SERVER_AWARE``, or ``USES_TERMINAL`` keywords.
* The ``TARGET`` form now requires at least one ``COMMAND`` to be given.
* If a keyword expects a value to be given after it, but no value is provided,
that was previously treated as though the keyword was not given at all.
* The ``COMMENT`` keyword expects exactly one value after it.  If multiple
values are given, or if the ``COMMENT`` keyword is given more than once,
this is an error.

This policy was introduced in CMake version 3.31.
It may be set by ``cmake_policy()`` or ``cmake_minimum_required()``.
If it is not set, CMake warns, and uses ``OLD`` behavior.

<<<<

Finally, it's too big to reasonably quote but here's a direct link to the cmake
3.31 add_custom_command build-events documentation (incl. TARGET, landing you
half way down the rather long page) on cmake.org:
https://cmake.org/cmake/help/v3.31/command/add_custom_command.html#build-events

Of course I could figure out how to turn off the warnings here and do so (or
file the bug at the gentoo level), but that wouldn't fix it for everyone else
that will eventually be hit by this, thus this bug.

(Meanwhile, I may just install-mask clang's clang-format executable and remove
it, thereby hopefully just skipping the triggering logic when it can't be
found; it's not like I'm a dev and can actually use its output, and unlike
figuring out how to set some cmake policy I already know how to install-mask a
file on gentoo.)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to