# 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:** 2

<div class="post-metadata">

### Author: ![codeling](https://discourse.cmake.org/user_avatar/discourse.cmake.org/codeling/32/1700_2.png) [@codeling](https://discourse.cmake.org/u/codeling)
#### Post date: [October 1, 2021, 11:23am UTC](https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176/2 "2021-10-01T11:23:30Z")

</div>

Can’t say for sure, but what I would try:

1. Check whether flags set via [`add_compile_options`](https://cmake.org/cmake/help/latest/command/add_compile_options.html#command:add_compile_options) are applied to your targets added via `ExternalProject_Add` as well; if not → GOOD!
2. Otherwise, do you have a list of all your “internal” targets? then you could loop over them and use [`target_compile_options`](https://cmake.org/cmake/help/latest/command/target_compile_options.html) to add the warning flags.
3. If it’s easier to get a list of all external projects, you could “subtract” that from the list of targets available via [`BUILDSYSTEM_TARGETS`](https://cmake.org/cmake/help/latest/prop_dir/BUILDSYSTEM_TARGETS.html) (you’d probably have to do this recursively for subdirectories, see also [this thread](https://discourse.cmake.org/t/cmake-list-of-all-project-targets/1077)), then use this list to do option 2.

---

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