File: FindGrib.cmake

package info (click to toggle)
gnudatalanguage 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,832 kB
  • sloc: cpp: 198,435; ansic: 47,740; sh: 691; python: 474; makefile: 149; xml: 69; f90: 28
file content (44 lines) | stat: -rw-r--r-- 1,553 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
# copyright : (c) 2010 Maxime Lenoir, Alain Coulais,
#                      Sylwester Arabas and Orion Poplawski
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#


find_library(GRIB_LIBRARIES NAMES eccodes)
find_path(GRIB_INCLUDE_DIR NAMES grib_api.h)
include(FindPackageHandleStandardArgs)
# since there's no grib_api.pc let's check if this installation of grib required jasper and jpeg
include(CheckLibraryExists)
set(CMAKE_REQUIRED_LIBRARIES m)

if (GRIB_LIBRARIES)
  check_library_exists(${GRIB_LIBRARIES} grib_index_new_from_file "" GRIB_COMPILES)
  if(GRIB_COMPILES)
    find_package_handle_standard_args(Grib DEFAULT_MSG GRIB_LIBRARIES GRIB_INCLUDE_DIR)
  else(GRIB_COMPILES)
    find_package(Jasper)
    if(JASPER_FOUND)
      set(CMAKE_REQUIRED_LIBRARIES ${JASPER_LIBRARIES} m)
      check_library_exists(${GRIB_LIBRARIES} grib_index_new_from_file "" GRIB_COMPILES_JASPER)
      if(GRIB_COMPILES_JASPER)
	set(GRIB_LIBRARIES ${GRIB_LIBRARIES} ${JASPER_LIBRARIES})
	set(GRIB_INCLUDE_DIR ${GRIB_INCLUDE_DIR} ${JASPER_INCLUDE_DIR})
	find_package_handle_standard_args(Grib DEFAULT_MSG GRIB_LIBRARIES GRIB_INCLUDE_DIR)
      endif(GRIB_COMPILES_JASPER)
    endif(JASPER_FOUND)
  endif(GRIB_COMPILES)
endif(GRIB_LIBRARIES)

set(CMAKE_REQUIRED_LIBRARIES)

mark_as_advanced(
GRIB_LIBRARIES
GRIB_INCLUDE_DIR
GRIB_COMPILES
GRIB_COMPILES_JASPER
)