summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-12 13:31:41 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-12 13:31:41 (GMT)
commitb3b238c3cc8cfd1f320faf0233ae860dcfcbfda0 (patch)
treeb8ba123a683a9d53e016cff9fe82af86c6198cba /Modules
parenta3aaf0a1815c99bed1acf4578c3aef34d6ef3cdc (diff)
parent79eba4b7abf940501a5b2060e8aaa3048d743652 (diff)
downloadCMake-b3b238c3cc8cfd1f320faf0233ae860dcfcbfda0.zip
CMake-b3b238c3cc8cfd1f320faf0233ae860dcfcbfda0.tar.gz
CMake-b3b238c3cc8cfd1f320faf0233ae860dcfcbfda0.tar.bz2
Merge topic 'bzip2-imported-targets'
79eba4b7 Help: Add notes for topic 'bzip2-imported-targets' 069cac58 Tests: Add FindBZip2 unit tests e9ce0503 FindBZip2: Add imported target
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindBZip2.cmake36
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)