diff options
author | Brad King <brad.king@kitware.com> | 2023-07-19 14:55:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-07-19 14:55:30 (GMT) |
commit | b0054dd65c1d69a437abe85d27e704326884a9c2 (patch) | |
tree | 8e49628c253769984e756ff71e260777da8c9852 /Tests | |
parent | ee6335f75f63f90f73583ed6ec430769d905a354 (diff) | |
parent | 7351d590ee6a846ed0f2bd4793384a33bf49ea0d (diff) | |
download | CMake-b0054dd65c1d69a437abe85d27e704326884a9c2.zip CMake-b0054dd65c1d69a437abe85d27e704326884a9c2.tar.gz CMake-b0054dd65c1d69a437abe85d27e704326884a9c2.tar.bz2 |
Merge topic 'imported-implib-only'
7351d590ee cmTarget: Add a way to represent imported shared library stubs
83574a4772 GeneratorExpression: Expand testing of imported location resolution
b75ff51947 Testing: Map RelWithDebInfo config in GeneratorExpression test
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Jason Juang <jasjuang@gmail.com>
Merge-request: !8582
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Cuda/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/Cuda/StubRPATH/CMakeLists.txt | 21 | ||||
-rw-r--r-- | Tests/Cuda/StubRPATH/main.cxx | 17 | ||||
-rw-r--r-- | Tests/GeneratorExpression/CMakeLists.txt | 21 | ||||
-rw-r--r-- | Tests/GeneratorExpression/check-part3.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0111/CMP0111-Common.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt | 6 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake | 1 |
11 files changed, 79 insertions, 9 deletions
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 0041b07..c737bcc 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -13,6 +13,7 @@ add_cuda_test_macro(Cuda.MixedStandardLevels4 MixedStandardLevels4) add_cuda_test_macro(Cuda.MixedStandardLevels5 MixedStandardLevels5) add_cuda_test_macro(Cuda.NotEnabled CudaNotEnabled) add_cuda_test_macro(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly) +add_cuda_test_macro(Cuda.StubRPATH StubRPATH) add_cuda_test_macro(Cuda.Toolkit Toolkit) add_cuda_test_macro(Cuda.IncludePathNoToolkit IncludePathNoToolkit) add_cuda_test_macro(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) diff --git a/Tests/Cuda/StubRPATH/CMakeLists.txt b/Tests/Cuda/StubRPATH/CMakeLists.txt new file mode 100644 index 0000000..93643c5 --- /dev/null +++ b/Tests/Cuda/StubRPATH/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.18) +project(StubRPATH CXX) + +#Verify that linking to a stub library doesn't cause an `-rpath` entry + +# Needed for `CUDAToolkit_LIBRARY_SEARCH_DIRS` +find_package(CUDAToolkit REQUIRED) + +find_library(CUDA_DRIVER_STUB_LIBRARY + NAMES cuda + HINTS ${CUDAToolkit_LIBRARY_SEARCH_DIRS} + ENV CUDA_PATH + PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs +) +add_library(imported_stub IMPORTED SHARED) +set_target_properties(imported_stub PROPERTIES IMPORTED_IMPLIB "${CUDA_DRIVER_STUB_LIBRARY}") +set_target_properties(imported_stub PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIRS}") + +set(CMAKE_CXX_STANDARD 11) +add_executable(StubRPATH main.cxx) +target_link_libraries(StubRPATH PRIVATE imported_stub) diff --git a/Tests/Cuda/StubRPATH/main.cxx b/Tests/Cuda/StubRPATH/main.cxx new file mode 100644 index 0000000..877856e --- /dev/null +++ b/Tests/Cuda/StubRPATH/main.cxx @@ -0,0 +1,17 @@ + +#include <iostream> + +#include <cuda.h> + +int main(int argc, char** argv) +{ + int nDevices = 0; + cuInit(0); + auto err = cuDeviceGetCount(&nDevices); + if (err != CUDA_SUCCESS) { + std::cerr << "Failed to retrieve the number of CUDA enabled devices " + << err << std::endl; + return 1; + } + return 0; +} diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ef115e6..df7cda0 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -214,6 +214,22 @@ set_property(TARGET importedFallback2 PROPERTY IMPORTED_IMPLIB_SPECIAL special_i set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_NOCONFIG SPECIAL "") set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_DEBUG SPECIAL "") set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_RELEASE SPECIAL "") +set_property(TARGET importedFallback2 PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO SPECIAL "") + +add_library(importedFallback3 SHARED IMPORTED) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_LOCATION fallback_loc) +set_property(TARGET importedFallback3 PROPERTY IMPORTED_IMPLIB imp_loc) +set_property(TARGET importedFallback3 PROPERTY MAP_IMPORTED_CONFIG_DEBUG "" DEBUG) +set_property(TARGET importedFallback3 PROPERTY MAP_IMPORTED_CONFIG_RELEASE "") + +add_library(importedFallback4 SHARED IMPORTED) +set_property(TARGET importedFallback4 PROPERTY IMPORTED_LOCATION fallback_loc) +set_property(TARGET importedFallback4 PROPERTY IMPORTED_IMPLIB imp_loc) + +add_library(importedFallback5 SHARED IMPORTED) +set_property(TARGET importedFallback5 PROPERTY IMPORTED_IMPLIB imp_loc) add_library(importedFallback_genex STATIC IMPORTED) set_property(TARGET importedFallback_genex PROPERTY IMPORTED_CONFIGURATIONS RELEASE) @@ -232,7 +248,10 @@ add_custom_target(check-part3 ALL -Dconfig=$<CONFIGURATION> -Dtest_imported_includes=$<TARGET_PROPERTY:imported4,INCLUDE_DIRECTORIES> -Dtest_imported_fallback=$<STREQUAL:$<TARGET_FILE_NAME:importedFallback>,fallback_loc> - -Dtest_imported_fallback2=$<IF:$<OR:$<PLATFORM_ID:Windows,CYGWIN,MSYS>,$<AND:$<PLATFORM_ID:Darwin>,$<BOOL:${CMAKE_TAPI}>>>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback2>,special_imp>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback2>,fallback_loc>> + -Dtest_imported_fallback2=$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback2>,special_imp> + -Dtest_imported_fallback3=$<IF:$<PLATFORM_ID:Windows,CYGWIN,MSYS>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback3>,imp_loc>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback3>,fallback_loc>> + -Dtest_imported_fallback4=$<IF:$<PLATFORM_ID:Windows,CYGWIN,MSYS>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback4>,imp_loc>,$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback4>,fallback_loc>> + -Dtest_imported_fallback5=$<STREQUAL:$<TARGET_LINKER_FILE_NAME:importedFallback5>,imp_loc> -Dtest_imported_fallback_genex=$<STREQUAL:$<TARGET_PROPERTY:importedFallback_genex,INTERFACE_COMPILE_DEFINITIONS>,FOOBAR=1> -Dtest_alias_file_exe=$<STREQUAL:$<TARGET_FILE:Alias::SomeExe>,$<TARGET_FILE:someexe>> -Dtest_alias_file_lib=$<STREQUAL:$<TARGET_FILE:Alias::SomeLib>,$<TARGET_FILE:empty1>> diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 7bb0d85..eda3bc1 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -20,6 +20,9 @@ endif() check(test_imported_fallback "1") check(test_imported_fallback2 "1") +check(test_imported_fallback3 "1") +check(test_imported_fallback4 "1") +check(test_imported_fallback5 "1") check(test_imported_fallback_genex "1") check(test_alias_file_exe "1") diff --git a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake index c31e4ba..ab9e405 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-Common.cmake +++ b/Tests/RunCMake/CMP0111/CMP0111-Common.cmake @@ -1,6 +1,3 @@ -# Prevent duplicate errors on some platforms. -set(CMAKE_IMPORT_LIBRARY_SUFFIX "placeholder") - add_library(unknown_lib UNKNOWN IMPORTED) add_library(static_lib STATIC IMPORTED) add_library(shared_lib SHARED IMPORTED) diff --git a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt index e5eb4bf..c6439e2 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-NEW-stderr.txt @@ -1,4 +1,6 @@ ^(CMake Error in CMakeLists.txt: - IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. -+)+CMake Generate step failed. Build files cannot be regenerated correctly.$ +)+ +.*(IMPORTED_LOCATION or )?IMPORTED_IMPLIB not set for imported target.*"shared_lib".* +CMake Generate step failed. Build files cannot be regenerated correctly.$ diff --git a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt index 5286134..7a46c41 100644 --- a/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0111/CMP0111-WARN-stderr.txt @@ -4,7 +4,7 @@ details. Use the cmake_policy command to set the policy and suppress this warning. - IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. This warning is for project developers. Use -Wno-dev to suppress it. +)+CMake Warning \(dev\) in CMakeLists.txt: @@ -13,6 +13,7 @@ This warning is for project developers. Use -Wno-dev to suppress it. details. Use the cmake_policy command to set the policy and suppress this warning. - IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static|shared)_lib"( configuration + IMPORTED_(LOCATION|IMPLIB) not set for imported target "(unknown|static)_lib"( configuration "[^"]+")?. +.*(IMPORTED_LOCATION or )?IMPORTED_IMPLIB not set for imported target.*"shared_lib".* This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake index 4a0f068..65c708c 100644 --- a/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake +++ b/Tests/RunCMake/target_link_libraries-ALIAS/AliasTargets.cmake @@ -14,8 +14,14 @@ set_property(TARGET import-local PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMA set_property(TARGET import-local PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_IMPORT_LIBRARY_SUFFIX}") add_library(alias::local ALIAS import-local) +if(NOT DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) + add_library(import-local-stub SHARED IMPORTED) + set_property(TARGET import-local-stub PROPERTY IMPORTED_IMPLIB "${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}func${CMAKE_SHARED_LIBRARY_SUFFIX}") + add_library(alias::local-stub ALIAS import-local-stub) +endif() + add_library (lib-local SHARED lib.c) -target_link_libraries (lib-local PRIVATE alias::local) +target_link_libraries (lib-local PRIVATE alias::local $<TARGET_NAME_IF_EXISTS:alias::local-stub>) add_executable (main-local main.c) target_link_libraries (main-local PRIVATE alias::local) diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake b/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake new file mode 100644 index 0000000..04f9cfb --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/ImportedTargetStub.cmake @@ -0,0 +1,2 @@ +add_library(SharedStubImportedGlobal SHARED IMPORTED GLOBAL) +set_target_properties(SharedStubImportedGlobal PROPERTIES IMPORTED_IMPLIB z) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 7c5d77d..0e3877a 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -23,6 +23,7 @@ run_cmake(CMP0079-link-NEW-bogus) run_cmake(CMP0108-OLD-self-link) run_cmake(CMP0108-NEW-self-link) run_cmake(ImportedTarget) +run_cmake(ImportedTargetStub) run_cmake(ImportedTargetFailure) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) |