# How to set an alias for a target imported by find\_package?

**URL:** https://discourse.cmake.org/t/how-to-set-an-alias-for-a-target-imported-by-find-package/15831
**Category:** Usage
**Created:** [September 14, 2026, 8:46am UTC](https://discourse.cmake.org/t/how-to-set-an-alias-for-a-target-imported-by-find-package/15831 "2026-09-14T08:46:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.cmake.org/user_avatar/discourse.cmake.org/csatizoltan/32/5488_2.png) [@CsatiZoltan](https://discourse.cmake.org/u/CsatiZoltan)
#### Post date: [September 14, 2026, 8:46am UTC](https://discourse.cmake.org/t/how-to-set-an-alias-for-a-target-imported-by-find-package/15831/1 "2026-09-14T08:46:18Z")

</div>

When I create my own library target with `add_library`, it has an `ALIAS` option. However, I cannot find similar for libraries imported via `find_package`.  
In my case, I import OpenMP with

```auto
find_package(OpenMP COMPONENTS CXX REQUIRED)

```

and then link it with my library as

```auto
target_link_libraries(myLib PRIVATE OpenMP::OpenMP_CXX)

```

When I generate the dependency graph among the CMake targets, it appears as `OpenMP::OpenMP_CXX`. This is verbose, I would like OpenMP to appear as `OpenMP` in the graph. Is it possible?

---

<div class="post-metadata">

### Author: ![HelenMarsh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@HelenMarsh](https://discourse.cmake.org/u/HelenMarsh)
#### Post date: [September 15, 2026, 8:04am UTC](https://discourse.cmake.org/t/how-to-set-an-alias-for-a-target-imported-by-find-package/15831/2 "2026-09-15T08:04:07Z")

</div>

You can create an alias for an imported target as well (with a recent CMake):

```cmake

find\_package(OpenMP COMPONENTS CXX REQUIRED)

if(TARGET OpenMP::OpenMP\_CXX AND NOT TARGET OpenMP)

add\_library(OpenMP ALIAS OpenMP::OpenMP\_CXX)

endif()

target\_link\_libraries(myLib PRIVATE OpenMP)

```

That gives you the shorter spelling in your own CMake code. It does not rename the imported target, though, so the Graphviz generator may still label the node `OpenMP::OpenMP_CXX`; if the shorter label is essential, post-process the `.dot` output (or filter it with `CMakeGraphVizOptions.cmake`). Also keep the alias in a scope where the imported target is visible.

---

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.cmake.org/user_avatar/discourse.cmake.org/csatizoltan/32/5488_2.png) [@CsatiZoltan](https://discourse.cmake.org/u/CsatiZoltan)
#### Post date: [September 15, 2026, 8:22am UTC](https://discourse.cmake.org/t/how-to-set-an-alias-for-a-target-imported-by-find-package/15831/3 "2026-09-15T08:22:47Z")

</div>

Thank you. For me, the abbreviation is needed only for the .dot output.

> post-process the `.dot` output

I will do that if necessary, but I hope it is simpler with _CMakeGraphVizOptions.cmake_.

> filter it with _CMakeGraphVizOptions.cmake_

I already use the _CMakeGraphVizOptions.cmake_ file, but I didn’t find in the [documentation](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-graphviz) how to modify the node name of a target.

> Also keep the alias in a scope where the imported target is visible.

What do you mean by that?
