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
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?
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.