# Apply clang-tidy on objective-c++ file using cmake ?

**URL:** https://discourse.cmake.org/t/apply-clang-tidy-on-objective-c-file-using-cmake/4860
**Category:** Code
**Tags:** os:macos, comp:clang
**Created:** [January 16, 2022, 1:20pm UTC](https://discourse.cmake.org/t/apply-clang-tidy-on-objective-c-file-using-cmake/4860 "2022-01-16T13:20:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zohar81](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zohar81/32/2252_2.png) [@zohar81](https://discourse.cmake.org/u/zohar81)
#### Post date: [January 16, 2022, 1:20pm UTC](https://discourse.cmake.org/t/apply-clang-tidy-on-objective-c-file-using-cmake/4860/1 "2022-01-16T13:20:22Z")

</div>

Hi, I’m applying my clang-tidy rules on macOS cmake project using the following command :

```auto
set_target_properties(${target_name} PROPERTIES CXX_CLANG_TIDY ${clang_tidy_cmd})

```

Recently I’ve added a file that is written in objective-c++, so the clang-tidy rules applies to it as well.

The makefile was generated ok, but when try to compile it I got compilation error which relates to the system include line

```auto
#import <Foundation/Foundation.h>

```

The error was :

```auto
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.
sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does 
not return NSString [clang-diagnostic-error]

- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value 
table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT 
API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
                                                                                                                                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.
sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: 
expanded from macro 'NS_FORMAT_ARGUMENT'
        #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
                                                      ^

```

When avoid setting clang-tidy on the target’s properties, the compilation passes.  
I could try and avoid this if it was a rules that breaks, but it seems like a compilation error, so i assume that clang-tidy settings changes compiler configuration somehow…

Any idea how to resolve it ?

---

<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: [January 16, 2022, 6:15pm UTC](https://discourse.cmake.org/t/apply-clang-tidy-on-objective-c-file-using-cmake/4860/2 "2022-01-16T18:15:22Z")

</div>

It would seem that `clang-tidy` doesn’t know it is Objective C++? Can you get `clang-tidy` to work on the file outside of CMake?
