summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/alias_targets/get_property.cmake
blob: 8a01c6f5d637f2ade41757deeb2fede2322b209a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

enable_language(CXX)

function (check_property alias property value)
  get_property (data TARGET ${alias} PROPERTY ${property})
  if (NOT "${value}" STREQUAL "${data}")
    message (SEND_ERROR "get_property(): Target property '${property}' from ALIAS '${alias}' has wrong value: '${data}' instead of '${value}'.")
  endif()
  get_target_property (data ${alias} ${property})
  if (NOT "${value}" STREQUAL "${data}")
    message (SEND_ERROR "get_target_property(): Target property '${property}' from ALIAS '${alias}' has wrong value: '${data}' instead of '${value}'.")
  endif()
endfunction()


add_library(lib empty.cpp)
set_property (TARGET lib PROPERTY LIB_PROPERTY "LIB")

add_library(alias::lib ALIAS lib)

check_property (alias::lib ALIASED_TARGET "lib")
check_property (alias::lib IMPORTED "FALSE")
check_property (alias::lib ALIAS_GLOBAL "TRUE")
check_property (alias::lib LIB_PROPERTY "LIB")


add_library(import-global SHARED IMPORTED GLOBAL)
set_property (TARGET import-global PROPERTY IMPORT_GLOBAL_PROPERTY "IMPORT_GLOBAL")

add_library(alias::import-global ALIAS import-global)

check_property (alias::import-global ALIASED_TARGET "import-global")
check_property (alias::import-global IMPORTED "TRUE")
check_property (alias::import-global ALIAS_GLOBAL "TRUE")
check_property (alias::import-global IMPORT_GLOBAL_PROPERTY "IMPORT_GLOBAL")


add_library(import-local SHARED IMPORTED)
set_property (TARGET import-local PROPERTY IMPORT_LOCAL_PROPERTY "IMPORT_LOCAL")

add_library(alias::import-local ALIAS import-local)

check_property (alias::import-local ALIASED_TARGET "import-local")
check_property (alias::import-local IMPORTED "TRUE")
check_property (alias::import-local ALIAS_GLOBAL "FALSE")
check_property (alias::import-local IMPORT_LOCAL_PROPERTY "IMPORT_LOCAL")


## upgrade imported target from local to global, alias stay local
add_library(import-lib SHARED IMPORTED)
add_library(alias::import-lib ALIAS import-lib)
check_property (alias::import-lib IMPORTED_GLOBAL "FALSE")
check_property (alias::import-lib ALIAS_GLOBAL "FALSE")
set_property (TARGET import-lib PROPERTY IMPORTED_GLOBAL "TRUE")
check_property (alias::import-lib IMPORTED_GLOBAL "TRUE")
check_property (alias::import-lib ALIAS_GLOBAL "FALSE")


add_subdirectory (get_property-subdir)