Merge topic 'export-static-private-depend'
aea1b036
Fix export of STATIC library PRIVATE dependencies with CMP0022 NEWe5cbec14
Tests: Use CMP0022 NEW behavior in some ExportImport cases0ca122fc
Tests: Isolate policy changes in ExportImport test
This commit is contained in:
commit
249aac71d0
|
@ -432,8 +432,11 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
|
|||
{
|
||||
std::string configLib = this->Target
|
||||
->GetDebugGeneratorExpressions(lib, llt);
|
||||
if (cmGeneratorExpression::IsValidTargetName(lib)
|
||||
|| cmGeneratorExpression::Find(lib) != std::string::npos)
|
||||
if (cmGeneratorExpression::IsValidTargetName(configLib))
|
||||
{
|
||||
configLib = "$<LINK_ONLY:$<TARGET_NAME:" + configLib + ">>";
|
||||
}
|
||||
else if (cmGeneratorExpression::Find(configLib) != std::string::npos)
|
||||
{
|
||||
configLib = "$<LINK_ONLY:" + configLib + ">";
|
||||
}
|
||||
|
|
|
@ -130,10 +130,15 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
|
|||
add_library(testLibNoSONAME SHARED testLibNoSONAME.c)
|
||||
set_property(TARGET testLibNoSONAME PROPERTY NO_SONAME 1)
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0022 NEW)
|
||||
# Test exporting dependent libraries into different exports
|
||||
add_library(testLibRequired testLibRequired.c)
|
||||
add_library(testLibDepends testLibDepends.c)
|
||||
target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired)
|
||||
add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c)
|
||||
target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate)
|
||||
cmake_policy(POP)
|
||||
|
||||
macro(add_include_lib _libName)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "/* no content */\n")
|
||||
|
@ -270,6 +275,7 @@ install(FILES
|
|||
DESTINATION include/testSharedLibRequiredUser
|
||||
)
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0022 NEW)
|
||||
add_library(testSharedLibRequiredUser2 SHARED testSharedLibRequiredUser2.cpp)
|
||||
generate_export_header(testSharedLibRequiredUser2)
|
||||
|
@ -283,7 +289,7 @@ install(FILES
|
|||
"${CMAKE_CURRENT_BINARY_DIR}/testsharedlibrequireduser2_export.h"
|
||||
DESTINATION include/testSharedLibRequiredUser2
|
||||
)
|
||||
cmake_policy(SET CMP0022 OLD)
|
||||
cmake_policy(POP)
|
||||
|
||||
add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp)
|
||||
set_property(TARGET testSharedLibDepends APPEND PROPERTY
|
||||
|
@ -311,6 +317,8 @@ target_link_libraries(testSharedLibDepends LINK_PUBLIC renamed_on_export)
|
|||
target_link_libraries(testSharedLibDepends LINK_INTERFACE_LIBRARIES
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:$<TARGET_NAME:testSharedLibRequired>>)
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0022 OLD)
|
||||
add_library(cmp0022OLD SHARED cmp0022_vs6_1.cpp)
|
||||
generate_export_header(cmp0022OLD BASE_NAME cmp0022)
|
||||
target_include_directories(cmp0022OLD PUBLIC
|
||||
|
@ -324,7 +332,7 @@ target_include_directories(cmp0022NEW PUBLIC
|
|||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/cmp0022>"
|
||||
)
|
||||
cmake_policy(SET CMP0022 OLD)
|
||||
cmake_policy(POP)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmp0022.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmp0022_export.h"
|
||||
|
@ -388,6 +396,10 @@ install(TARGETS
|
|||
INCLUDES DESTINATION
|
||||
$<INSTALL_PREFIX>/include/$<TARGET_PROPERTY:NAME>
|
||||
)
|
||||
install(TARGETS
|
||||
testStaticLibRequiredPrivate
|
||||
EXPORT RequiredExp DESTINATION lib
|
||||
)
|
||||
install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired)
|
||||
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest")
|
||||
|
|
|
@ -16,5 +16,10 @@
|
|||
#endif
|
||||
|
||||
extern int testLibRequired(void);
|
||||
extern int testStaticLibRequiredPrivate(void);
|
||||
|
||||
int testLibDepends(void) { return testLibRequired(); }
|
||||
int testLibDepends(void) {
|
||||
return testLibRequired()
|
||||
+ testStaticLibRequiredPrivate()
|
||||
;
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
int testStaticLibRequiredPrivate(void) { return 0; }
|
Loading…
Reference in New Issue