# Omit targets that are not supported by compiler

**URL:** https://discourse.cmake.org/t/omit-targets-that-are-not-supported-by-compiler/5809
**Category:** Code
**Created:** [June 6, 2022, 11:56pm UTC](https://discourse.cmake.org/t/omit-targets-that-are-not-supported-by-compiler/5809 "2022-06-06T23:56:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrew/32/2478_2.png) [@Andrew](https://discourse.cmake.org/u/Andrew)
#### Post date: [June 6, 2022, 11:56pm UTC](https://discourse.cmake.org/t/omit-targets-that-are-not-supported-by-compiler/5809/1 "2022-06-06T23:56:54Z")

</div>

We have projects that build on a variety of platforms. I’ve added some extension code that requires some C++11 features not supported by one of the platforms, but I don’t mind if the code doesn’t build on that platform.

I could add a bunch of conditional parameters from the top down, but is there an easy way to say “if you don’t know how to build this, it’s OK to skip it”?

Essentially, test whether I would get the following error:

> Target “my\_target” requires the language dialect “CXX11” (with compiler extensions), but CMake does not know the compile flags to use to enable it.

and in that case just omit the target

---

<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: [June 7, 2022, 1:14am UTC](https://discourse.cmake.org/t/omit-targets-that-are-not-supported-by-compiler/5809/2 "2022-06-07T01:14:35Z")

</div>

You can test `if ("cxx_std_11" IN_LIST CMAKE_CXX_COMPILE_FEATURES)` to test if C++11 is supported. There may be a feature for what you want as well. If that isn’t sufficient, `try_compile` can be used to test for it directly.

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [June 7, 2022, 7:22am UTC](https://discourse.cmake.org/t/omit-targets-that-are-not-supported-by-compiler/5809/3 "2022-06-07T07:22:49Z")

</div>

You can also test that in the code with an ifdef, maybe.
