# Project wide compile options

**URL:** https://discourse.cmake.org/t/project-wide-compile-options/7103
**Category:** Code
**Created:** [December 21, 2022, 9:23am UTC](https://discourse.cmake.org/t/project-wide-compile-options/7103 "2022-12-21T09:23:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![some\_name](https://discourse.cmake.org/user_avatar/discourse.cmake.org/some_name/32/3023_2.png) [@some\_name](https://discourse.cmake.org/u/some_name)
#### Post date: [December 21, 2022, 9:23am UTC](https://discourse.cmake.org/t/project-wide-compile-options/7103/1 "2022-12-21T09:23:38Z")

</div>

I would like to set some options (such as /Wall) in the root of my project such that they apply to all code. I tried using add\_compile\_options but on Windows when I create a project using cmake -G “Visual Studio 17 2022”, these options are added to the ZERO\_CHECK target and Visual Studio complains. As an example, adding the /MP option through this method causes problems.

I would rather not have the manual method of ensuring these options are applied repeatedly to each target. And I don’t want to make my own custom macro. I feel like this is a simple enough task that I should be able to accomplish it with out-of-the-box commands. I am using CMake 3.25.1. Can you please guide me towards the correct solution?

---

<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: [December 21, 2022, 12:40pm UTC](https://discourse.cmake.org/t/project-wide-compile-options/7103/2 "2022-12-21T12:40:48Z")

</div>

`add_compile_options` should work… Why does VS make noise about things on `ZERO_CHECK`? That’s an internal target and shouldn’t care about flags at all. I wonder if the generator needs to learn to not do something here. Does generating 2019 work (in case VS got more strict since then)?
