[cmake-developers] Question about ALIAS targets

David Cole DLRdave at aol.com
Mon Jun 5 16:10:21 EDT 2017


Is there a good reason why this error must be an error?

    CMake Error at CMakeLists.txt:23 (add_library):
      add_library cannot create ALIAS target "MyProj::gtest" because target
      "OtherProj::googletest" is IMPORTED.

The line of code is:

    add_library(MyProj::gtest ALIAS OtherProj::googletest)

Why is there any restriction on ALIAS targets about what sorts of
targets they may be aliases of?

After my find_package(OtherProj) call, which is a super build which
defines lots of imported targets, I want the target to be named gtest
to match its library name, but OtherProj has named it googletest.

I can brute force this particular one to just be another IMPORTED
target with all the same properties and property values as the
original, but it seems to me this particular case should be allowed
unless there's a fundamental problem I'm not aware of.

Thanks for any explanations....


David C.


More information about the cmake-developers mailing list