# The target name is reserved or not valid for certain CMake features...

**URL:** https://discourse.cmake.org/t/the-target-name-is-reserved-or-not-valid-for-certain-cmake-features/6913
**Category:** Usage
**Created:** [November 20, 2022, 4:50am UTC](https://discourse.cmake.org/t/the-target-name-is-reserved-or-not-valid-for-certain-cmake-features/6913 "2022-11-20T04:50:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [November 20, 2022, 4:50am UTC](https://discourse.cmake.org/t/the-target-name-is-reserved-or-not-valid-for-certain-cmake-features/6913/1 "2022-11-20T04:50:34Z")

</div>

I am not sure why this library alias is causing this error. Using double colon `::` seems to be permitted with `import` and `alias` targets. See [double-colon in target name](https://cmake.org/cmake/help/latest/policy/CMP0028.html#:~:text=Double%20colon%20in%20target%20name,IMPORTED%20targets%20and%20ALIAS%20targets.) .

error:

```auto
  The target name "zeromq::zeromq" is reserved or not valid for certain CMake
  features, such as generator expressions, and may result in undefined
  behavior.

```

code:

```auto
include(FetchContent)
FetchContent_Declare(
    ZeroMQ
    GIT_REPOSITORY https://github.com/zeromq/libzmq
    GIT_TAG v4.3.4
    GIT_SHALLOW TRUE
    GIT_PROGRESS TRUE
    OVERRIDE_FIND_PACKAGE
)
message("ZEROMQ_LIBRARY is ${ZEROMQ_LIBRARY}")
add_library(zeromq::zeromq alias ${ZEROMQ_LIBRARY})

```

---

<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: [November 20, 2022, 8:33am UTC](https://discourse.cmake.org/t/the-target-name-is-reserved-or-not-valid-for-certain-cmake-features/6913/2 "2022-11-20T08:33:53Z")

</div>

The `ALIAS` keyword needs to be in uppercase:

```cmake
add_library(zeromq::zeromq ALIAS ${ZEROMQ_LIBRARY})

```

It looks like you are missing a `FetchContent_MakeAvailable(ZeroMQ)` there though. I’d also recommend a check that the target doesn’t already exist before you call `add_library()` to create the alias target. There are scenarios in which that target might already have been created (e.g. by a dependency provider, or an earlier call that already populated the ZeroMQ dependency).

---

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [November 20, 2022, 1:28pm UTC](https://discourse.cmake.org/t/the-target-name-is-reserved-or-not-valid-for-certain-cmake-features/6913/3 "2022-11-20T13:28:43Z")

</div>

Ah of course. Embarrassing for me. I was experimenting while debugging something else. I had the makeavailable call but it was after the attempt to create the library alias.

Thank you
