mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-09 10:00:12 -05:00
LINK_LIBRARIES: Add support for LINK_ONLY genex
Previously we always used content guarded by `$<LINK_ONLY:...>` in `LINK_LIBRARIES`, even when evaluating for non-linking usage requirements. Add a policy to honor `LINK_ONLY` in `LINK_LIBRARIES` the same way we already do in `INTERFACE_LINK_LIBRARIES`.
This commit is contained in:
@@ -59,3 +59,12 @@ set_property(TARGET bar_static_private APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
||||
|
||||
add_executable(InterfaceLinkLibraries main_vs6_4.cpp)
|
||||
set_property(TARGET InterfaceLinkLibraries APPEND PROPERTY LINK_LIBRARIES bar_static_private)
|
||||
|
||||
add_library(foo_link_only STATIC foo_link_only.c)
|
||||
target_compile_definitions(foo_link_only PUBLIC FOO_LINK_ONLY)
|
||||
add_executable(use_foo_link_only_CMP0131_OLD use_foo_link_only.c)
|
||||
target_link_libraries(use_foo_link_only_CMP0131_OLD PRIVATE "$<LINK_ONLY:foo_link_only>")
|
||||
target_compile_definitions(use_foo_link_only_CMP0131_OLD PRIVATE EXPECT_FOO_LINK_ONLY)
|
||||
cmake_policy(SET CMP0131 NEW)
|
||||
add_executable(use_foo_link_only_CMP0131_NEW use_foo_link_only.c)
|
||||
target_link_libraries(use_foo_link_only_CMP0131_NEW PRIVATE "$<LINK_ONLY:foo_link_only>")
|
||||
|
||||
8
Tests/InterfaceLinkLibraries/foo_link_only.c
Normal file
8
Tests/InterfaceLinkLibraries/foo_link_only.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef FOO_LINK_ONLY
|
||||
# error "FOO_LINK_ONLY incorrectly not defined"
|
||||
#endif
|
||||
|
||||
int foo_link_only(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
16
Tests/InterfaceLinkLibraries/use_foo_link_only.c
Normal file
16
Tests/InterfaceLinkLibraries/use_foo_link_only.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifdef EXPECT_FOO_LINK_ONLY
|
||||
# ifndef FOO_LINK_ONLY
|
||||
# error "FOO_LINK_ONLY incorrectly not defined"
|
||||
# endif
|
||||
#else
|
||||
# ifdef FOO_LINK_ONLY
|
||||
# error "FOO_LINK_ONLY incorrectly defined"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int foo_link_only(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return foo_link_only();
|
||||
}
|
||||
Reference in New Issue
Block a user