FindOpenSlide.cmake
Go to the documentation of this file.
1 # A CMake find module for the OpenSlide microscopy file reader library.
2 #
3 # http://openslide.org
4 #
5 # Once done, this module will define
6 # OPENSLIDE_FOUND - system has OpenSlide
7 # OPENSLIDE_INCLUDE_DIRS - the OpenSlide include directory
8 # OPENSLIDE_LIBRARIES - link to these to use OpenSlide
9 # OpenSlide::OpenSlide - imported target
10 
11 # Look for the header.
12 find_path(OPENSLIDE_INCLUDE_DIR
13  NAMES
14  openslide/openslide.h
15  PATHS
16  /usr/local/include
17  /usr/include)
18 
19 mark_as_advanced( OPENSLIDE_INCLUDE_DIR )
20 
21 # Look for the library.
22 find_library( OPENSLIDE_LIBRARY NAMES openslide )
23 mark_as_advanced( OPENSLIDE_LIBRARY )
24 
25 # Handle the QUIETLY and REQUIRED arguments and set OPENSLIDE_FOUND true if all
26 # the listed variables are TRUE.
27 
28 find_package( PackageHandleStandardArgs )
29 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSlide DEFAULT_MSG OPENSLIDE_LIBRARY OPENSLIDE_INCLUDE_DIR )
30 
31 if( OPENSLIDE_FOUND )
32  set( OPENSLIDE_LIBRARIES ${OPENSLIDE_LIBRARY} )
33  set( OPENSLIDE_INCLUDE_DIRS ${OPENSLIDE_INCLUDE_DIR} )
34  add_library(OpenSlide::OpenSlide UNKNOWN IMPORTED)
35  set_target_properties(OpenSlide::OpenSlide PROPERTIES
36  IMPORTED_LOCATION "${OPENSLIDE_LIBRARY}"
37  INTERFACE_INCLUDE_DIRECTORIES "${OPENSLIDE_INCLUDE_DIR}")
38 endif()