diff options
author | Roger Leigh <rleigh@codelibre.net> | 2016-09-08 20:16:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-09 15:42:34 (GMT) |
commit | e9ce050342c34b92e0eaa281a4e454c9b78a41d9 (patch) | |
tree | 5fed572d6b588ad6d9a2849a377a1ace1521fd64 /Modules/FindBZip2.cmake | |
parent | f506489d1ed222761f9ce752144a458290020e55 (diff) | |
download | CMake-e9ce050342c34b92e0eaa281a4e454c9b78a41d9.zip CMake-e9ce050342c34b92e0eaa281a4e454c9b78a41d9.tar.gz CMake-e9ce050342c34b92e0eaa281a4e454c9b78a41d9.tar.bz2 |
FindBZip2: Add imported target
Diffstat (limited to 'Modules/FindBZip2.cmake')
-rw-r--r-- | Modules/FindBZip2.cmake | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index b670025..152d812 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -4,7 +4,16 @@ # # Try to find BZip2 # -# Once done this will define +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``BZip2::BZip2``, if +# BZip2 has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables: # # :: # @@ -64,6 +73,31 @@ if (BZIP2_FOUND) set(CMAKE_REQUIRED_LIBRARIES ${BZIP2_LIBRARIES}) CHECK_SYMBOL_EXISTS(BZ2_bzCompressInit "bzlib.h" BZIP2_NEED_PREFIX) cmake_pop_check_state() + + if(NOT TARGET BZip2::BZip2) + add_library(BZip2::BZip2 UNKNOWN IMPORTED) + set_target_properties(BZip2::BZip2 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}") + + if(BZIP2_LIBRARY_RELEASE) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(BZip2::BZip2 PROPERTIES + IMPORTED_LOCATION_RELEASE "${BZIP2_LIBRARY_RELEASE}") + endif() + + if(BZIP2_LIBRARY_DEBUG) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(BZip2::BZip2 PROPERTIES + IMPORTED_LOCATION_DEBUG "${BZIP2_LIBRARY_DEBUG}") + endif() + + if(NOT BZIP2_LIBRARY_RELEASE AND NOT BZIP2_LIBRARY_DEBUG) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_LOCATION "${BZIP2_LIBRARY}") + endif() + endif() endif () mark_as_advanced(BZIP2_INCLUDE_DIR) |