# Compiler warning flags for all except ExternalProjects

**URL:** https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176
**Category:** Code
**Created:** [September 30, 2021, 12:41pm UTC](https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176 "2021-09-30T12:41:25Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)
#### Post date: [October 1, 2021, 11:51am UTC](https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176/4 "2021-10-01T11:51:59Z")

</div>

I like the approach of having an interface target. My problem then becomes trying to figure out what syntax for `target_link_libraries` to use.

```cmake
target_link_libraries(mytgt PRIVATE buildflags) 

```

or

```cmake
target_link_libraries(mytgt buildflags) 

```

Apperently it is not possible to mix syntax for `target_link_libraries`.

> [@Consecutive target\_link\_libraries with and without PUBLIC](https://discourse.cmake.org/t/consecutive-target-link-libraries-with-and-without-public/3592/7):
>
> Yes, it has such a default, for when PUBLIC/PRIVATE is omitted always. However, once you use such a keyword in one invocation, you have to use it in all of them. The way to think about it is to consider target\_link\_libraries() to have two distinct modes of operation: plain one, and keyword-based one. You can use it just fine in either mode, but you cannot mix modes for the same consuming target.

---

_[View the full topic](https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176)._
