Only valid target names or generator expressions may appear in the target field of a LINK_ONLY expression. Other content like link flags should still be added to that property (wrapped in config-specific generator expressions), but not wrapped in LINK_ONLY. Otherwise undue warnings would be issued for the policy CMP0022. The LINK_ONLY expression only has an effect for actual target names anyway, so there is no logical deficit.
13 lines
473 B
CMake
13 lines
473 B
CMake
|
|
project(CMP0022-NOWARN-static)
|
|
|
|
add_library(foo STATIC empty_vs6_1.cpp)
|
|
add_library(bar STATIC empty_vs6_2.cpp)
|
|
add_library(bat STATIC empty_vs6_3.cpp)
|
|
target_link_libraries(foo bar)
|
|
# The last element here needs to contain a space so that it is a single
|
|
# element which is not a valid target name. As bar is a STATIC library,
|
|
# this tests that the LINK_ONLY generator expression is not used for
|
|
# that element, creating an error.
|
|
target_link_libraries(bar bat "-lz -lm")
|