https://github.com/Kitware/CMake
Raw File
Tip revision: 44b8937b7614560d9e88d25456c8394b4b209d51 authored by Brad King on 05 February 2020, 14:19:24 UTC
CMake 3.16.4
Tip revision: 44b8937
imported-target.cmake

enable_language(CXX)


add_executable(test-exe IMPORTED)
add_executable(alias-test-exe ALIAS test-exe)

if(TARGET alias-test-exe)
  get_target_property(aliased-target alias-test-exe ALIASED_TARGET)
  if("${aliased-target}" STREQUAL "test-exe")
    get_target_property(aliased-name alias-test-exe NAME)
    if("${aliased-name}" STREQUAL "test-exe")
      message("'alias-test-exe' is an alias for '${aliased-target}'"
              " and its name-property contains '${aliased-name}'.")
    else()
      message("'alias-test-exe' is an alias for '${aliased-target}'"
              " but its name-property contains '${aliased-name}'!?")
    endif()
  else()
    message("'alias-test-exe' is something but not a real target!?")
  endif()
else()
    message("'alias-test-exe' does not exist!?")
endif()


add_library(test-lib SHARED IMPORTED)
add_library(alias-test-lib ALIAS test-lib)

if(TARGET alias-test-lib)
  get_target_property(aliased-target alias-test-lib ALIASED_TARGET)
  if("${aliased-target}" STREQUAL "test-lib")
    get_target_property(aliased-name alias-test-lib NAME)
    if("${aliased-name}" STREQUAL "test-lib")
      message("'alias-test-lib' is an alias for '${aliased-target}'"
              " and its name-property contains '${aliased-name}'.")
    else()
      message("'alias-test-lib' is an alias for '${aliased-target}'"
              " but its name-property contains '${aliased-name}'!?")
    endif()
  else()
    message("'alias-test-lib' is something but not a real target!?")
  endif()
else()
    message("'alias-test-lib' does not exist!?")
endif()
back to top