# Setting properties for Qt autogen target

**URL:** https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573
**Category:** Code
**Created:** [July 21, 2023, 2:17pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573 "2023-07-21T14:17:20Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![brentd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brentd/32/3596_2.png) [@brentd](https://discourse.cmake.org/u/brentd)
#### Post date: [July 21, 2023, 2:17pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/1 "2023-07-21T14:17:20Z")

</div>

I have a library using Qt and I am using cppcheck. I do not want to run cppcheck on the resulting ‘autogen’ target, but you can’t set the target properties on the autogen target to disable cppcheck because the target is created (I think) during the _generation_ step of cmake. See code below.

Is there a way to set properties for the Qt autogen targets to disable cppcheck on those targets? Is there another way to keep cppcheck from running on those targets?

```auto
set( CMAKE_CXX_CPPCHECK "/path/to/cppcheck" )

add_library( GUI SHARED )

set_target_properties( GUI PROPERTIES AUTORCC TRUE )

target_sources( GUI
  PRIVATE
  SomeSources.hpp
  SomeSources.cpp
  # cppcheck can't handle the resultant qrc_*.cpp files
  some_resource.qrc
  another_resource.qrc
)

# need to disable cppcheck on autogen target, but can't do this
# because GUI_autogen doesn't exist
set_property( TARGET GUI_autogen PROPERTY CXX_CPPCHECK "" )

```

Thanks!

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [July 21, 2023, 2:40pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/2 "2023-07-21T14:40:46Z")

</div>

You could create a .clang-tidy file in the build folder that disables all tests.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 21, 2023, 4:32pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/3 "2023-07-21T16:32:46Z")

</div>

You may be able to set source file properties on them. CMake 3.27 also has the [`SKIP_LINTING`](https://cmake.org/cmake/help/latest/prop_sf/SKIP_LINTING.html) property which may be able to help.

---

<div class="post-metadata">

### Author: ![brentd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brentd/32/3596_2.png) [@brentd](https://discourse.cmake.org/u/brentd)
#### Post date: [July 21, 2023, 4:41pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/4 "2023-07-21T16:41:18Z")

</div>

Are the source file properties for the Qt resource files (.qrc) transitive to the autogen target? It didn’t work for me. The GUI\_autogen target still ran the resulting qrc\_some\_resource.cpp file through cppcheck.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 21, 2023, 4:53pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/5 "2023-07-21T16:53:28Z")

</div>

You might be able to set the property on the `qrc_some_resource.cpp` filename (source properties can be loose, so this might be a benefit here).

---

<div class="post-metadata">

### Author: ![brentd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brentd/32/3596_2.png) [@brentd](https://discourse.cmake.org/u/brentd)
#### Post date: [July 21, 2023, 9:52pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/6 "2023-07-21T21:52:54Z")

</div>

I just installed 3.27 to play with the generator expressions for the \_CPPCHECK property and cppcheck is no longer run on the auto targets!

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 23, 2023, 10:11pm UTC](https://discourse.cmake.org/t/setting-properties-for-qt-autogen-target/8573/7 "2023-07-23T22:11:43Z")

</div>

Yes, autogen files are skipped for code checks starting with CMake 3.27, thanks to [MR 8467](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8467).
