diff options
author | Slava Barinov <v.barinov@samsung.com> | 2020-01-28 11:52:09 +0300 |
---|---|---|
committer | Slava Barinov <v.barinov@samsung.com> | 2020-01-28 11:52:09 +0300 |
commit | 5a33b45a98929bb730e6a11818416edd27e8fc00 (patch) | |
tree | 48aa69f9fd46c2519bd57037689d6b1a61765bda /Tests/ExportImport | |
parent | 4f290facafe45c5f05ceff7bc1f6aa9340273ea4 (diff) | |
download | cmake-5a33b45a98929bb730e6a11818416edd27e8fc00.tar.gz cmake-5a33b45a98929bb730e6a11818416edd27e8fc00.tar.bz2 cmake-5a33b45a98929bb730e6a11818416edd27e8fc00.zip |
Version upgrade
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Diffstat (limited to 'Tests/ExportImport')
29 files changed, 233 insertions, 80 deletions
diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index eaad3d46c..dc621eb27 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.7.20090711) +cmake_minimum_required (VERSION 3.9) project(ExportImport C CXX) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -15,7 +15,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index eeae3f006..c6b7dbc95 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -83,11 +83,23 @@ set_property(TARGET testLib7 PROPERTY OUTPUT_NAME testLib7-$<CONFIG>) add_library(testLib8 OBJECT testLib8A.c testLib8B.c sub/testLib8C.c) if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]") - set(maybe_testLib8 testLib8) + set(maybe_OBJECTS_DESTINATION OBJECTS DESTINATION $<1:lib>) else() - set(maybe_testLib8 "") + set(maybe_OBJECTS_DESTINATION "") endif() +cmake_policy(PUSH) +cmake_policy(SET CMP0022 NEW) +add_library(testLib9ObjPub OBJECT testLib9ObjPub.c) +target_compile_definitions(testLib9ObjPub INTERFACE testLib9ObjPub_USED) +add_library(testLib9ObjPriv OBJECT testLib9ObjPriv.c) +target_compile_definitions(testLib9ObjPriv INTERFACE testLib9ObjPriv_USED) +add_library(testLib9ObjIface OBJECT testLib9ObjIface.c) +target_compile_definitions(testLib9ObjIface INTERFACE testLib9ObjIface_USED) +add_library(testLib9 STATIC testLib9.c) +target_link_libraries(testLib9 INTERFACE testLib9ObjIface PUBLIC testLib9ObjPub PRIVATE testLib9ObjPriv) +cmake_policy(POP) + # Test using the target_link_libraries command to set the # LINK_INTERFACE_LIBRARIES* properties. We construct two libraries # providing the same two symbols. In each library one of the symbols @@ -143,6 +155,13 @@ add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c) target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate) cmake_policy(POP) +cmake_policy(PUSH) +cmake_policy(SET CMP0079 NEW) +add_library(TopDirLib STATIC testTopDirLib.c) +add_subdirectory(SubDirLinkA) +add_subdirectory(SubDirLinkB) +cmake_policy(POP) + macro(add_include_lib _libName) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "/* no content */\n") add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c") @@ -344,6 +363,14 @@ install(FILES set_property(TARGET testLib2 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB2) set_property(TARGET testLib3 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB3) +set_target_properties(testLib3 PROPERTIES + EXPORT_PROPERTIES "EXPORTED_PROPERTY1" + EXPORTED_PROPERTY1 "EXPORTING_TESTLIB3") +set_target_properties(testLib4 PROPERTIES + EXPORTED_PROPERTY2 "EXPORTING_TESTLIB4_1" + EXPORTED_PROPERTY3 "EXPORTING_TESTLIB4_2") +set_property(TARGET testLib4 PROPERTY + EXPORT_PROPERTIES EXPORTED_PROPERTY2 EXPORTED_PROPERTY3) set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2) # set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLibIncludeRequired2) # TODO: Test for error @@ -483,19 +510,26 @@ install( TARGETS testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt - testLib6 testLib7 ${maybe_testLib8} + testLib6 testLib7 testLib8 + testLib9 testLibCycleA testLibCycleB testLibNoSONAME cmp0022NEW cmp0022OLD + TopDirLib SubDirLinkA systemlib EXPORT exp - RUNTIME DESTINATION $<1:bin> - LIBRARY DESTINATION $<1:lib> NAMELINK_SKIP - ARCHIVE DESTINATION $<1:lib> - OBJECTS DESTINATION $<1:lib> + RUNTIME DESTINATION $<1:bin>$<0:/wrong> + LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP + ARCHIVE DESTINATION $<1:lib>$<0:/wrong> + ${maybe_OBJECTS_DESTINATION} FRAMEWORK DESTINATION Frameworks BUNDLE DESTINATION Applications ) +install( + TARGETS + testLib9ObjPub testLib9ObjPriv testLib9ObjIface + EXPORT exp + ) if (APPLE) file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/testLib4.framework/Headers) file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/testLib4.framework/Headers) @@ -540,12 +574,14 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 testSharedLibRequired testSharedLibRequiredUser testSharedLibRequiredUser2 testSharedLibDepends renamed_on_export cmp0022NEW cmp0022OLD + TopDirLib SubDirLinkA systemlib NAMESPACE bld_ FILE ExportBuildTree.cmake ) export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib - ${maybe_testLib8} + testLib8 + testLib9 testLib9ObjPub testLib9ObjPriv testLib9ObjIface testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibNoSONAME @@ -570,3 +606,39 @@ install( ) install(DIRECTORY $<1:include/abs>$<0:/wrong> DESTINATION $<1:include>$<0:/wrong>) install(EXPORT expAbs NAMESPACE expAbs_ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/expAbs) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_OPTIONS +add_library(testLinkOptions INTERFACE) +target_link_options(testLinkOptions INTERFACE INTERFACE_FLAG) + +install(TARGETS testLinkOptions + EXPORT RequiredExp DESTINATION lib) +export(TARGETS testLinkOptions NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_DIRECTORIES +add_library(testLinkDirectories INTERFACE) +target_link_directories(testLinkDirectories INTERFACE + $<BUILD_INTERFACE:/interface/build> + $<INSTALL_INTERFACE:interface/install>) + +install(TARGETS testLinkDirectories + EXPORT RequiredExp DESTINATION lib) +export(TARGETS testLinkDirectories NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) + + +#------------------------------------------------------------------------------ +# test export of INTERFACE_LINK_DEPENDS +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + add_library(testLinkDepends INTERFACE) + set_property(TARGET testLinkDepends PROPERTY INTERFACE_LINK_DEPENDS + $<BUILD_INTERFACE:BUILD_LINK_DEPENDS> + $<INSTALL_INTERFACE:INSTALL_LINK_DEPENDS>) + + install(TARGETS testLinkDepends + EXPORT RequiredExp DESTINATION lib) + export(TARGETS testLinkDepends NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake) +endif() diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index fd55c423c..22a4ef600 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -41,6 +41,8 @@ install(FILES add_library(cmakeonly INTERFACE) set_property(TARGET cmakeonly PROPERTY INTERFACE_COMPILE_DEFINITIONS [[DEF="\"\$\B"]]) +set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue) +set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property) install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target cmakeonly diff --git a/Tests/ExportImport/Export/Interface/source_target.cpp b/Tests/ExportImport/Export/Interface/source_target.cpp index 037191cf6..1eb5b1307 100644 --- a/Tests/ExportImport/Export/Interface/source_target.cpp +++ b/Tests/ExportImport/Export/Interface/source_target.cpp @@ -1,10 +1,10 @@ #ifndef USE_FROM_BUILD_DIR -#error Expected define USE_FROM_BUILD_DIR +# error Expected define USE_FROM_BUILD_DIR #endif #ifdef USE_FROM_INSTALL_DIR -#error Unexpected define USE_FROM_INSTALL_DIR +# error Unexpected define USE_FROM_INSTALL_DIR #endif int source_symbol() diff --git a/Tests/ExportImport/Export/Interface/source_target_for_install.cpp b/Tests/ExportImport/Export/Interface/source_target_for_install.cpp index 64514edb2..2f8819052 100644 --- a/Tests/ExportImport/Export/Interface/source_target_for_install.cpp +++ b/Tests/ExportImport/Export/Interface/source_target_for_install.cpp @@ -1,10 +1,10 @@ #ifdef USE_FROM_BUILD_DIR -#error Unexpected define USE_FROM_BUILD_DIR +# error Unexpected define USE_FROM_BUILD_DIR #endif #ifndef USE_FROM_INSTALL_DIR -#error Expected define USE_FROM_INSTALL_DIR +# error Expected define USE_FROM_INSTALL_DIR #endif int source_symbol() diff --git a/Tests/ExportImport/Export/systemlib.h b/Tests/ExportImport/Export/systemlib.h index 6fd00d503..8ec055bb0 100644 --- a/Tests/ExportImport/Export/systemlib.h +++ b/Tests/ExportImport/Export/systemlib.h @@ -3,9 +3,9 @@ #define SYSTEMLIB_H #if defined(_WIN32) || defined(__CYGWIN__) -#define systemlib_EXPORT __declspec(dllexport) +# define systemlib_EXPORT __declspec(dllexport) #else -#define systemlib_EXPORT +# define systemlib_EXPORT #endif struct systemlib_EXPORT SystemStruct diff --git a/Tests/ExportImport/Export/testExe2.c b/Tests/ExportImport/Export/testExe2.c index f8976c46a..958e4d2bc 100644 --- a/Tests/ExportImport/Export/testExe2.c +++ b/Tests/ExportImport/Export/testExe2.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2_EXPORT __declspec(dllexport) +# define testExe2_EXPORT __declspec(dllexport) #else -#define testExe2_EXPORT +# define testExe2_EXPORT #endif testExe2_EXPORT int testExe2Func(void) diff --git a/Tests/ExportImport/Export/testExe2lib.c b/Tests/ExportImport/Export/testExe2lib.c index 2a5a77bd5..905e6c7f5 100644 --- a/Tests/ExportImport/Export/testExe2lib.c +++ b/Tests/ExportImport/Export/testExe2lib.c @@ -1,9 +1,9 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2lib_EXPORT __declspec(dllexport) -#define testExe2libImp_IMPORT __declspec(dllimport) +# define testExe2lib_EXPORT __declspec(dllexport) +# define testExe2libImp_IMPORT __declspec(dllimport) #else -#define testExe2lib_EXPORT -#define testExe2libImp_IMPORT +# define testExe2lib_EXPORT +# define testExe2libImp_IMPORT #endif testExe2libImp_IMPORT int testExe2libImp(void); diff --git a/Tests/ExportImport/Export/testExe2libImp.c b/Tests/ExportImport/Export/testExe2libImp.c index aba914b88..8892c8553 100644 --- a/Tests/ExportImport/Export/testExe2libImp.c +++ b/Tests/ExportImport/Export/testExe2libImp.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2libImp_EXPORT __declspec(dllexport) +# define testExe2libImp_EXPORT __declspec(dllexport) #else -#define testExe2libImp_EXPORT +# define testExe2libImp_EXPORT #endif testExe2libImp_EXPORT int testExe2libImp(void) diff --git a/Tests/ExportImport/Export/testLib3.c b/Tests/ExportImport/Export/testLib3.c index cacac810f..016fae0b1 100644 --- a/Tests/ExportImport/Export/testLib3.c +++ b/Tests/ExportImport/Export/testLib3.c @@ -1,9 +1,9 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib3_EXPORT __declspec(dllexport) -#define testLib3Imp_IMPORT __declspec(dllimport) +# define testLib3_EXPORT __declspec(dllexport) +# define testLib3Imp_IMPORT __declspec(dllimport) #else -#define testLib3_EXPORT -#define testLib3Imp_IMPORT +# define testLib3_EXPORT +# define testLib3Imp_IMPORT #endif testLib3Imp_IMPORT int testLib3Imp(void); diff --git a/Tests/ExportImport/Export/testLib3Imp.c b/Tests/ExportImport/Export/testLib3Imp.c index 3d836daf1..877d0b6bf 100644 --- a/Tests/ExportImport/Export/testLib3Imp.c +++ b/Tests/ExportImport/Export/testLib3Imp.c @@ -1,9 +1,9 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib3Imp_EXPORT __declspec(dllexport) -#define testLib3ImpDep_IMPORT __declspec(dllimport) +# define testLib3Imp_EXPORT __declspec(dllexport) +# define testLib3ImpDep_IMPORT __declspec(dllimport) #else -#define testLib3Imp_EXPORT -#define testLib3ImpDep_IMPORT +# define testLib3Imp_EXPORT +# define testLib3ImpDep_IMPORT #endif testLib3ImpDep_IMPORT int testLib3ImpDep(void); diff --git a/Tests/ExportImport/Export/testLib3ImpDep.c b/Tests/ExportImport/Export/testLib3ImpDep.c index b824e03de..4fc97836b 100644 --- a/Tests/ExportImport/Export/testLib3ImpDep.c +++ b/Tests/ExportImport/Export/testLib3ImpDep.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib3ImpDep_EXPORT __declspec(dllexport) +# define testLib3ImpDep_EXPORT __declspec(dllexport) #else -#define testLib3ImpDep_EXPORT +# define testLib3ImpDep_EXPORT #endif testLib3ImpDep_EXPORT int testLib3ImpDep(void) diff --git a/Tests/ExportImport/Export/testLib4.c b/Tests/ExportImport/Export/testLib4.c index 0e583b176..2031a4fd7 100644 --- a/Tests/ExportImport/Export/testLib4.c +++ b/Tests/ExportImport/Export/testLib4.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib4_EXPORT __declspec(dllexport) +# define testLib4_EXPORT __declspec(dllexport) #else -#define testLib4_EXPORT +# define testLib4_EXPORT #endif testLib4_EXPORT int testLib4(void) diff --git a/Tests/ExportImport/Export/testLib5.c b/Tests/ExportImport/Export/testLib5.c index 7c61fc030..edd02ebd1 100644 --- a/Tests/ExportImport/Export/testLib5.c +++ b/Tests/ExportImport/Export/testLib5.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLib5_EXPORT __declspec(dllexport) +# define testLib5_EXPORT __declspec(dllexport) #else -#define testLib5_EXPORT +# define testLib5_EXPORT #endif testLib5_EXPORT int testLib5(void) diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c index c896c10ef..6100da1dc 100644 --- a/Tests/ExportImport/Export/testLibDepends.c +++ b/Tests/ExportImport/Export/testLibDepends.c @@ -4,15 +4,15 @@ #include "testLibIncludeRequired4.h" #ifndef testLibRequired_IFACE_DEFINE -#error Expected testLibRequired_IFACE_DEFINE +# error Expected testLibRequired_IFACE_DEFINE #endif #ifndef BuildOnly_DEFINE -#error Expected BuildOnly_DEFINE +# error Expected BuildOnly_DEFINE #endif #ifdef InstallOnly_DEFINE -#error Unexpected InstallOnly_DEFINE +# error Unexpected InstallOnly_DEFINE #endif extern int testLibRequired(void); diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c index 4d98562df..955284852 100644 --- a/Tests/ExportImport/Export/testLibNoSONAME.c +++ b/Tests/ExportImport/Export/testLibNoSONAME.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testLibNoSONAME_EXPORT __declspec(dllexport) +# define testLibNoSONAME_EXPORT __declspec(dllexport) #else -#define testLibNoSONAME_EXPORT +# define testLibNoSONAME_EXPORT #endif testLibNoSONAME_EXPORT int testLibNoSoName(void) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 01960ea19..b5df96168 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -1,3 +1,9 @@ +# Prepare imported targets that the exported project itself imported. +add_library(SubDirLinkAImported IMPORTED INTERFACE) +target_compile_definitions(SubDirLinkAImported INTERFACE DEF_SubDirLinkAImportedForImport) +add_library(SubDirLinkBImported IMPORTED INTERFACE) +target_compile_definitions(SubDirLinkBImported INTERFACE DEF_SubDirLinkBImportedForImport) + # Import targets from the exported build tree. include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake) @@ -32,6 +38,20 @@ add_executable(imp_testExe1 ${Import_BINARY_DIR}/exp_generated4.c ) +function(checkForProperty _TARGET _PROP _EXPECTED) + get_target_property(EXPORTED_PROPERTY ${_TARGET} "${_PROP}") + if (NOT EXPORTED_PROPERTY STREQUAL "${_EXPECTED}") + message(SEND_ERROR "${_TARGET} was expected to export \"${_PROP}\" with value \"${_EXPECTED}\" but got \"${EXPORTED_PROPERTY}\"") + endif() +endfunction() + +checkForProperty(bld_testLib3 "EXPORTED_PROPERTY1" "EXPORTING_TESTLIB3") +checkForProperty(exp_testLib3 "EXPORTED_PROPERTY1" "EXPORTING_TESTLIB3") +checkForProperty(bld_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1") +checkForProperty(exp_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1") +checkForProperty(bld_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2") +checkForProperty(exp_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2") + # Try linking to a library imported from the install tree. target_link_libraries(imp_testExe1 exp_testLib2 @@ -144,6 +164,11 @@ target_link_libraries(cmp0022OLD_exp_test exp_cmp0022OLD) add_executable(cmp0022NEW_exp_test cmp0022NEW_test_vs6_2.cpp) target_link_libraries(cmp0022NEW_exp_test exp_cmp0022NEW) +add_executable(SubDirLink_bld SubDirLink.c) +target_link_libraries(SubDirLink_bld PRIVATE bld_TopDirLib bld_SubDirLinkA) +add_executable(SubDirLink_exp SubDirLink.c) +target_link_libraries(SubDirLink_exp PRIVATE exp_TopDirLib exp_SubDirLinkA) + # Try building a plugin to an executable imported from the build tree. add_library(imp_mod1b MODULE imp_mod1.c) target_link_libraries(imp_mod1b bld_testExe2) @@ -229,15 +254,44 @@ add_library(imp_lib1b STATIC imp_lib1.c) target_link_libraries(imp_lib1b bld_testLib2) if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]") - # Create a executable that is using objects imported from the install tree - add_executable(imp_testLib8 imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>) + set(bld_objlib_type OBJECT_LIBRARY) + + # Create executables using objects imported from the install tree + add_executable(imp_testLib8_src imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>) + add_executable(imp_testLib8_link imp_testLib8.c) + target_link_libraries(imp_testLib8_link exp_testLib8) if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT XCODE_VERSION VERSION_LESS 5) - # Create a executable that is using objects imported from the build tree - add_executable(imp_testLib8b imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>) + # Create executables using objects imported from the build tree + add_executable(imp_testLib8b_src imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>) + add_executable(imp_testLib8b_link imp_testLib8.c) + target_link_libraries(imp_testLib8b_link bld_testLib8) endif() +else() + set(bld_objlib_type INTERFACE_LIBRARY) endif() +# Create an executable that uses a library imported from the install tree +# that itself was built using an object library. Verify we get the usage +# requirements. +add_executable(imp_testLib9 imp_testLib9.c) +target_link_libraries(imp_testLib9 exp_testLib9) +# Similarly for importing from the build tree. +add_executable(imp_testLib9b imp_testLib9.c) +target_link_libraries(imp_testLib9b bld_testLib9) + +# Check that object libraries were transformed on export as expected. +foreach(vis Pub Priv Iface) + get_property(type TARGET exp_testLib9Obj${vis} PROPERTY TYPE) + if(NOT type STREQUAL INTERFACE_LIBRARY) + message(FATAL_ERROR "exp_testLib9Obj${vis} type is '${type}', not 'INTERFACE_LIBRARY'") + endif() + get_property(type TARGET bld_testLib9Obj${vis} PROPERTY TYPE) + if(NOT type STREQUAL "${bld_objlib_type}") + message(FATAL_ERROR "bld_testLib9Obj${vis} type is '${type}', not '${bld_objlib_type}'") + endif() +endforeach() + #----------------------------------------------------------------------------- # Test that handling imported targets, including transitive dependencies, # works in CheckFunctionExists (...and hopefully all other try_compile() checks @@ -278,7 +332,6 @@ if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") else() if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" - OR CMAKE_SYSTEM_NAME MATCHES "IRIX64" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(run_pic_test 0) else() @@ -354,7 +407,7 @@ endforeach() unset(_configs) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR CMAKE_C_COMPILER_ID STREQUAL Clang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")) AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) @@ -429,3 +482,20 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA endif() endif() endif() + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_OPTIONS property +checkForProperty(bld_testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG") +checkForProperty(Req::testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG") + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_DIRECTORIES property +checkForProperty(bld_testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "/interface/build") +checkForProperty(Req::testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "${CMAKE_INSTALL_PREFIX}/interface/install") + +#--------------------------------------------------------------------------------- +# check that imported libraries have the expected INTERFACE_LINK_DEPENDS property +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + checkForProperty(bld_testLinkDepends "INTERFACE_LINK_DEPENDS" "BUILD_LINK_DEPENDS") + checkForProperty(Req::testLinkDepends "INTERFACE_LINK_DEPENDS" "${CMAKE_INSTALL_PREFIX}/INSTALL_LINK_DEPENDS") +endif() diff --git a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp index 587834987..778b8287e 100644 --- a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp +++ b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp @@ -1,9 +1,9 @@ #ifndef USING_TESTLIB2 -#error Expected USING_TESTLIB2 +# error Expected USING_TESTLIB2 #endif #ifdef USING_TESTLIB3 -#error Unexpected USING_TESTLIB3 +# error Unexpected USING_TESTLIB3 #endif int main(void) diff --git a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp index e50158b76..9eaaee9b4 100644 --- a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp +++ b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp @@ -1,9 +1,9 @@ #ifdef USING_TESTLIB2 -#error Unexpected USING_TESTLIB2 +# error Unexpected USING_TESTLIB2 #endif #ifndef USING_TESTLIB3 -#error Expected USING_TESTLIB3 +# error Expected USING_TESTLIB3 #endif int main(void) diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c index 1539bcb68..e2d973c2f 100644 --- a/Tests/ExportImport/Import/A/deps_iface.c +++ b/Tests/ExportImport/Import/A/deps_iface.c @@ -14,15 +14,15 @@ #include "installIncludesTest8.h" #ifndef testLibRequired_IFACE_DEFINE -#error Expected testLibRequired_IFACE_DEFINE +# error Expected testLibRequired_IFACE_DEFINE #endif #ifdef BuildOnly_DEFINE -#error Unexpected BuildOnly_DEFINE +# error Unexpected BuildOnly_DEFINE #endif #ifndef InstallOnly_DEFINE -#error Expected InstallOnly_DEFINE +# error Expected InstallOnly_DEFINE #endif extern int testLibDepends(void); diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 3658ab548..d239fb418 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -3,32 +3,32 @@ #include "testSharedLibDepends.h" #ifdef CHECK_PIC_WORKS -#if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) -#error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency -#endif +# if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) +# error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency +# endif #endif #ifndef PIC_PROPERTY_IS_ON -#error Expected PIC_PROPERTY_IS_ON +# error Expected PIC_PROPERTY_IS_ON #endif #ifndef CUSTOM_PROPERTY_IS_ON -#error Expected CUSTOM_PROPERTY_IS_ON +# error Expected CUSTOM_PROPERTY_IS_ON #endif #ifndef CUSTOM_STRING_IS_MATCH -#error Expected CUSTOM_STRING_IS_MATCH +# error Expected CUSTOM_STRING_IS_MATCH #endif #ifdef TEST_SUBDIR_LIB -#include "renamed.h" -#include "subdir.h" +# include "renamed.h" +# include "subdir.h" #endif #ifdef DO_GNU_TESTS -#ifndef CUSTOM_COMPILE_OPTION -#error Expected CUSTOM_COMPILE_OPTION -#endif +# ifndef CUSTOM_COMPILE_OPTION +# error Expected CUSTOM_COMPILE_OPTION +# endif #endif int main(int, char**) diff --git a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp index 357f64f02..ddb8c4b35 100644 --- a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp +++ b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp @@ -2,5 +2,5 @@ #include <testLib4/testLib4.h> #ifndef TESTLIB4_H -#error Expected define TESTLIB4_H +# error Expected define TESTLIB4_H #endif diff --git a/Tests/ExportImport/Import/A/iface_test.cpp b/Tests/ExportImport/Import/A/iface_test.cpp index fa4474bdb..4428c1c50 100644 --- a/Tests/ExportImport/Import/A/iface_test.cpp +++ b/Tests/ExportImport/Import/A/iface_test.cpp @@ -1,6 +1,6 @@ #ifndef USING_TESTSHAREDLIBREQUIRED -#error Expected USING_TESTSHAREDLIBREQUIRED +# error Expected USING_TESTSHAREDLIBREQUIRED #endif #include "excludedFromAll.h" diff --git a/Tests/ExportImport/Import/A/imp_mod1.c b/Tests/ExportImport/Import/A/imp_mod1.c index 89d754595..9385d5519 100644 --- a/Tests/ExportImport/Import/A/imp_mod1.c +++ b/Tests/ExportImport/Import/A/imp_mod1.c @@ -1,7 +1,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) -#define testExe2_IMPORT __declspec(dllimport) +# define testExe2_IMPORT __declspec(dllimport) #else -#define testExe2_IMPORT +# define testExe2_IMPORT #endif testExe2_IMPORT int testExe2Func(void); diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 348843928..8173557cd 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -14,9 +14,9 @@ extern int testLibPerConfigDest(void); /* Switch a symbol between debug and optimized builds to make sure the proper library is found from the testLib4 link interface. */ #ifdef EXE_DBG -#define testLib4libcfg testLib4libdbg +# define testLib4libcfg testLib4libdbg #else -#define testLib4libcfg testLib4libopt +# define testLib4libcfg testLib4libopt #endif extern testLib4libcfg(void); diff --git a/Tests/ExportImport/Import/A/imp_testExeAbs1.c b/Tests/ExportImport/Import/A/imp_testExeAbs1.c index 629b891f1..fd0524206 100644 --- a/Tests/ExportImport/Import/A/imp_testExeAbs1.c +++ b/Tests/ExportImport/Import/A/imp_testExeAbs1.c @@ -2,10 +2,10 @@ #include "testLibAbs1a.h" #include "testLibAbs1b.h" #ifndef testLibAbs1a -#error "testLibAbs1a not defined" +# error "testLibAbs1a not defined" #endif #ifndef testLibAbs1b -#error "testLibAbs1b not defined" +# error "testLibAbs1b not defined" #endif int main() { diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index c850508e5..a07a5b3c4 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -109,4 +109,12 @@ foreach(ns exp bld) "not\n" " " [[DEF="\"\$\B"]] "\n") endif() + get_property(custom TARGET ${ns}::cmakeonly PROPERTY custom_property) + if(NOT custom STREQUAL "CustomPropertyValue") + message(SEND_ERROR + "${ns}::cmakeonly property custom_property is:\n" + " ${custom}\n" + "not\n" + " CustomPropertyValue\n") + endif() endforeach() diff --git a/Tests/ExportImport/Import/Interface/headeronlytest.cpp b/Tests/ExportImport/Import/Interface/headeronlytest.cpp index 0e754e9e3..7b63a0496 100644 --- a/Tests/ExportImport/Import/Interface/headeronlytest.cpp +++ b/Tests/ExportImport/Import/Interface/headeronlytest.cpp @@ -2,11 +2,11 @@ #include "headeronly.h" #ifndef HEADERONLY_DEFINE -#error Expected HEADERONLY_DEFINE +# error Expected HEADERONLY_DEFINE #endif #ifdef SHAREDLIB_DEFINE -#error Unexpected SHAREDLIB_DEFINE +# error Unexpected SHAREDLIB_DEFINE #endif int main(int, char**) diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp index 7be816286..c1e29c246 100644 --- a/Tests/ExportImport/Import/Interface/interfacetest.cpp +++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp @@ -2,15 +2,15 @@ #include "sharedlib.h" #ifndef SHAREDLIB_DEFINE -#error Expected SHAREDLIB_DEFINE +# error Expected SHAREDLIB_DEFINE #endif #ifdef HEADERONLY_DEFINE -#error Unexpected HEADERONLY_DEFINE +# error Unexpected HEADERONLY_DEFINE #endif #ifndef DEFINE_IFACE_DEFINE -#error Expected DEFINE_IFACE_DEFINE +# error Expected DEFINE_IFACE_DEFINE #endif int main(int, char**) |