diff options
author | Brad King <brad.king@kitware.com> | 2021-10-07 13:21:55 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-10-07 13:22:11 (GMT) |
commit | 6e037a04e780f8516dd0a2b5221f2af4e6b20e1d (patch) | |
tree | a0a8bfacef7e4ece039a1b9054d42434f0c87247 /Modules | |
parent | eb724e938ae82e50f2b45a1d3dd9c4571fc4fec0 (diff) | |
parent | 6e8754c6251bc2f7edfb0d71303e1b85fce93f5e (diff) | |
download | CMake-6e037a04e780f8516dd0a2b5221f2af4e6b20e1d.zip CMake-6e037a04e780f8516dd0a2b5221f2af4e6b20e1d.tar.gz CMake-6e037a04e780f8516dd0a2b5221f2af4e6b20e1d.tar.bz2 |
Merge topic 'FindJasper-imported-target'
6e8754c625 FindJasper: Add IMPORTED target
bdbce845cd FindJasper: Add JASPER_INCLUDE_DIRS result variable
7f8413c309 FindJasper: Modernize documentation layout
524205a7a5 FindJasper: Modernize code layout
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4633
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindJasper.cmake | 95 |
1 files changed, 69 insertions, 26 deletions
diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index 729a503..9a62669 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -5,43 +5,86 @@ FindJasper ---------- -Try to find the Jasper JPEG2000 library +Find the Jasper JPEG2000 library. -Once done this will define +IMPORTED Targets +^^^^^^^^^^^^^^^^ -:: +``Jasper::Jasper`` + The jasper library, if found. - JASPER_FOUND - system has Jasper - JASPER_INCLUDE_DIR - the Jasper include directory - JASPER_LIBRARIES - the libraries needed to use Jasper - JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8) -#]=======================================================================] +Result Variables +^^^^^^^^^^^^^^^^ -find_path(JASPER_INCLUDE_DIR jasper/jasper.h) +This module defines the following variables: + +``JASPER_FOUND`` + system has Jasper +``JASPER_INCLUDE_DIRS`` + .. versionadded:: 3.22 + + the Jasper include directory +``JASPER_LIBRARIES`` + the libraries needed to use Jasper +``JASPER_VERSION_STRING`` + the version of Jasper found + +Cache variables +^^^^^^^^^^^^^^^ -if (NOT JASPER_LIBRARIES) - find_package(JPEG) +The following cache variables may also be set: - find_library(JASPER_LIBRARY_RELEASE NAMES jasper libjasper) - find_library(JASPER_LIBRARY_DEBUG NAMES jasperd) +``JASPER_INCLUDE_DIR`` + where to find jasper/jasper.h, etc. +``JASPER_LIBRARY_RELEASE`` + where to find the Jasper library (optimized). +``JASPER_LIBARRY_DEBUG`` + where to find the Jasper library (debug). +#]=======================================================================] - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) - SELECT_LIBRARY_CONFIGURATIONS(JASPER) -endif () +find_path(JASPER_INCLUDE_DIR jasper/jasper.h) +mark_as_advanced(JASPER_INCLUDE_DIR) -if (JASPER_INCLUDE_DIR AND EXISTS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h") - file(STRINGS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" jasper_version_str REGEX "^#define[\t ]+JAS_VERSION[\t ]+\".*\".*") +if(NOT JASPER_LIBRARIES) + find_package(JPEG) + find_library(JASPER_LIBRARY_RELEASE NAMES jasper libjasper) + find_library(JASPER_LIBRARY_DEBUG NAMES jasperd) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(JASPER) +endif() - string(REGEX REPLACE "^#define[\t ]+JAS_VERSION[\t ]+\"([^\"]+)\".*" "\\1" JASPER_VERSION_STRING "${jasper_version_str}") -endif () +if(JASPER_INCLUDE_DIR AND EXISTS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h") + file(STRINGS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" jasper_version_str REGEX "^#define[\t ]+JAS_VERSION[\t ]+\".*\".*") + string(REGEX REPLACE "^#define[\t ]+JAS_VERSION[\t ]+\"([^\"]+)\".*" "\\1" JASPER_VERSION_STRING "${jasper_version_str}") +endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper +find_package_handle_standard_args(Jasper REQUIRED_VARS JASPER_LIBRARIES JASPER_INCLUDE_DIR JPEG_LIBRARIES VERSION_VAR JASPER_VERSION_STRING) -if (JASPER_FOUND) - set(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES} ) -endif () - -mark_as_advanced(JASPER_INCLUDE_DIR) +if(JASPER_FOUND) + set(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES}) + set(JASPER_INCLUDE_DIRS ${JASPER_INCLUDE_DIR}) + if(NOT TARGET Jasper::Jasper) + add_library(Jasper::Jasper UNKNOWN IMPORTED) + if(JASPER_INCLUDE_DIRS) + set_target_properties(Jasper::Jasper PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${JASPER_INCLUDE_DIRS}") + endif() + if(EXISTS "${JASPER_LIBRARY_RELEASE}") + set_property(TARGET Jasper::Jasper APPEND PROPERTY + IMPORTED CONFIGURATION RELEASE) + set_target_properties(Jasper::Jasper PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION "${JASPER_LIBRARY_RELEASE}") + endif() + if(EXISTS "${JASPER_LIBRARY_DEBUG}") + set_property(TARGET Jasper::Jasper APPEND PROPERTY + IMPORTED CONFIGURATION DEBUG) + set_target_properties(Jasper::Jasper PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION "${JASPER_LIBRARY_DEBUG}") + endif() + endif() +endif() |