# CMake - search in list - "Unknown arguments specified"

**URL:** https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471
**Category:** Code
**Tags:** tool:cmake, comp:gcc, os:windows
**Created:** [November 11, 2021, 4:36pm UTC](https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471 "2021-11-11T16:36:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![LynarStudios](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/50afbb/32.png) [@LynarStudios](https://discourse.cmake.org/u/LynarStudios)
#### Post date: [November 11, 2021, 4:36pm UTC](https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471/1 "2021-11-11T16:36:31Z")

</div>

Hello community 🙂

I’m currently facing a cmake code issue, which I’m trying to understand and might need some support here. So I hope this is the right place to address this.

The following code should detect the used compiler and decide if it’s supported by my library or not.

```auto
cmake_minimum_required(VERSION 3.17)

# not important stuff

# supported compilers

list(APPEND SUPPORTED_COMPILERS "GNU")
list(APPEND SUPPORTED_COMPILERS "Clang")

# check for compiler support

message("${PROJECT_NAME}: Check if compiler is supported...")

if(${CMAKE_CXX_COMPILER_ID} IN_LIST ${SUPPORTED_COMPILERS})
    message("${PROJECT_NAME}: \"${SELECTED_COMPILER_SUPPORTED}\" is supported...")
else()
    message("${PROJECT_NAME}: \"${CMAKE_CXX_COMPILER_ID}\" is not supported...")
    return()
endif()

```

This unfortunately produces the following error message when loading the CMake project:

```auto
CMake Error at CMakeLists.txt:36 (if):
  if given arguments:

    "GNU" "IN_LIST" "GNU" "Clang"

  Unknown arguments specified

```

So here is what I understand:

- both the list and the compiler variable are not empty, so the logic seems kind of working
- GNU is even the compiler I’d like to use
- Checking the **IN\_LIST** documentation states that this is supported with CMake version **3.3**
- I also tried setting the cmake policy CMP0057 to NEW - which I think isn’t even necessary with my used CMake version? (I’m running CMake **3.20.2** , which comes as bundled with **CLion**.)

If you guys could support me here, I’d really appreciate it.  
So thanks in advance,

Patrick

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [November 11, 2021, 4:41pm UTC](https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471/2 "2021-11-11T16:41:56Z")

</div>

The documentation says:  
`if(<variable|string> IN_LIST <variable>)`  
which basically means that after `IN_LIST` comes the **NAME** of the variable containing the list. Not a list itself (which is what you did by expanding the variable)

---

<div class="post-metadata">

### Author: ![LynarStudios](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/50afbb/32.png) [@LynarStudios](https://discourse.cmake.org/u/LynarStudios)
#### Post date: [November 12, 2021, 9:19am UTC](https://discourse.cmake.org/t/cmake-search-in-list-unknown-arguments-specified/4471/3 "2021-11-12T09:19:19Z")

</div>

> [@LynarStudios](#):
>
> `SUPPORTED_COMPILERS`

Thank you, replacing the variable by the name solved the issue 🙂

```auto
if(${CMAKE_CXX_COMPILER_ID} IN_LIST SUPPORTED_COMPILERS)

```
