# How do I replace the compiler options for one target?

**URL:** https://discourse.cmake.org/t/how-do-i-replace-the-compiler-options-for-one-target/7815
**Category:** Usage
**Created:** [April 3, 2023, 8:17pm UTC](https://discourse.cmake.org/t/how-do-i-replace-the-compiler-options-for-one-target/7815 "2023-04-03T20:17:31Z")
**Posts on this page:** 1
**Showing post:** 5

<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: [April 4, 2023, 9:46am UTC](https://discourse.cmake.org/t/how-do-i-replace-the-compiler-options-for-one-target/7815/5 "2023-04-04T09:46:20Z")

</div>

Avoid setting `CMAKE_<LANG>_FLAGS`, `CMAKE_<LANG>_FLAGS_<CONFIG>`, `CMAKE_<TYPE>_LINKER_FLAGS` or `CMAKE_<TYPE>_LINKER_FLAGS_<CONFIG>` variables in the project. These are for the user to manipulate. For those things, use either the directory or target property manipulation commands like `add_compile_options()`, `add_link_options()`, `target_compile_options()` or `target_link_options()`.

The `CMAKE_<LANG>_STANDARD` flag is more contentious. Personally, I see that as something the project should set, but some people hold strong views that it should be under the user’s control. I understand the arguments for and against. I think the project can and should set it, but that can be done in a way that the user can still override it if they need to build everything with a higher language standard.

Regarding the use vcpkg and wanting to use your own toolchain file, vcpkg provides the `VCPKG_CHAINLOAD_TOOLCHAIN_FILE` variable for that. Or you can just include their toolchain file at the bottom of yours. Both methods are supported by vcpkg.

---

_[View the full topic](https://discourse.cmake.org/t/how-do-i-replace-the-compiler-options-for-one-target/7815)._
