diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2022-08-21 05:13:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-09-22 14:21:38 (GMT) |
commit | 1f5d9c5299bb7add5a7afcc1d054fd4259c04b89 (patch) | |
tree | 5b39d5db7a842986a3a2514445f8925acd6bf59c /Source/Modules | |
parent | 9cdf5a67790ef78292366268af0a3de4b5cc3892 (diff) | |
download | CMake-1f5d9c5299bb7add5a7afcc1d054fd4259c04b89.zip CMake-1f5d9c5299bb7add5a7afcc1d054fd4259c04b89.tar.gz CMake-1f5d9c5299bb7add5a7afcc1d054fd4259c04b89.tar.bz2 |
Build: Use imported target `LibArchive::LibArchive` instead of variables
Diffstat (limited to 'Source/Modules')
-rw-r--r-- | Source/Modules/CMakeBuildUtilities.cmake | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index dad4bc1..157367f 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -259,12 +259,16 @@ if(CMAKE_USE_SYSTEM_LIBARCHIVE) if(NOT LibArchive_FOUND) message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") endif() - set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) - set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) + # NOTE `FindLibArchive` got imported targets support since 3.17 + if (NOT TARGET LibArchive::LibArchive) + add_library(LibArchive::LibArchive UNKNOWN IMPORTED) + set_target_properties(LibArchive::LibArchive PROPERTIES + IMPORTED_LOCATION "${LibArchive_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LibArchive_INCLUDE_DIRS}") + endif () else() set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) - add_compile_definitions(LIBARCHIVE_STATIC) set(ENABLE_MBEDTLS OFF) set(ENABLE_NETTLE OFF) if(DEFINED CMAKE_USE_OPENSSL) @@ -300,8 +304,9 @@ else() set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag") set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)") add_subdirectory(Utilities/cmlibarchive) + add_library(LibArchive::LibArchive ALIAS cmlibarchive) + target_compile_definitions(cmlibarchive INTERFACE LIBARCHIVE_STATIC) CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") - set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) endif() #--------------------------------------------------------------------- |