Copying files from WRF build, unfortunately
[WPS.git] / cmake / modules / FindJasper.cmake
blob3b9bc6210c539e320eadbcc2d23334b69f05baad
1 # Find Jasper
2 # Eventually replace with Jasper's actual config if using that
3 # Once found this file will define:
4 #  Jasper_FOUND - System has Jasper
5 #  Jasper_INCLUDE_DIRS - The Jasper include directories
6 #  Jasper_LIBRARIES - The libraries needed to use Jasper
8 find_package( PkgConfig )
9 pkg_check_modules( PC_Jasper QUIET Jasper )
10 # set(CMAKE_FIND_DEBUG_MODE TRUE)
11 find_path(
12           Jasper_INCLUDE_DIR
13           NAMES jasper/jasper.h # Make it so we go up one dir
14           # Hints before PATHS
15           HINTS ${Jasper_ROOT} ${JASPERINC} ${JASPER_PATH} ENV Jasper_ROOT ENV JASPERINC ENV JASPER_PATH
16           PATHS ${PC_Jasper_INCLUDE_DIRS}
17           PATH_SUFFIXES Jasper jasper include #include/jasper
18         )
19 find_library(
20               Jasper_LIBRARY
21               NAMES jasper
22               # Hints before PATHS
23               HINTS ${Jasper_ROOT} ${JASPERLIB} ${JASPER_PATH} ENV Jasper_ROOT ENV JASPERLIB ENV JASPER_PATH
24               PATHS ${PC_Jasper_LIBRARY_DIRS}
25               PATH_SUFFIXES lib
26             )
28 # set(CMAKE_FIND_DEBUG_MODE FALSE)
30 include(FindPackageHandleStandardArgs)
31 find_package_handle_standard_args(
32                                   Jasper
33                                   FOUND_VAR Jasper_FOUND
34                                   REQUIRED_VARS
35                                     Jasper_LIBRARY
36                                     Jasper_INCLUDE_DIR
37                                   # VERSION_VAR Jasper_VERSION
38                                 )
40 if ( Jasper_FOUND AND NOT TARGET Jasper::Jasper )
41   add_library( Jasper::Jasper UNKNOWN IMPORTED )
42   set_target_properties(
43                         Jasper::Jasper
44                         PROPERTIES
45                           IMPORTED_LOCATION             "${Jasper_LIBRARY}"
46                           INTERFACE_COMPILE_OPTIONS     "${PC_Jasper_CFLAGS_OTHER}"
47                           INTERFACE_INCLUDE_DIRECTORIES "${Jasper_INCLUDE_DIR}"
48                         )
50   # Allow traditional/legacy style usage
51   set( Jasper_LIBRARIES    ${Jasper_LIBRARY}         )
52   set( Jasper_INCLUDE_DIRS ${Jasper_INCLUDE_DIR}     )
53   set( Jasper_DEFINITIONS  ${PC_Jasper_CFLAGS_OTHER} )
55   mark_as_advanced(
56                     Jasper_INCLUDE_DIR
57                     Jasper_LIBRARY
58                   )
59 endif()