FindZOLTAN.cmake 2.25 KB
Newer Older
1
# FindZOLTAN.cmake
2
3
4
5
6
#
# Finds the Zoltan library
#
# This will define the following variables
#
7
#    ZOLTAN_FOUND
8
9
10
11
12
#    ZOLTAN_INCLUDE_DIR
#    ZOLTAN_LIBS
#
# and the following imported targets
#
13
#     ZOLTAN::ZOLTAN
14
15
16
17
#
# Author: Simon Praetorius <simon.praetorius@tu-dresden.de>


18
mark_as_advanced(ZOLTAN_FOUND ZOLTAN_VERSION ZOLTAN_INCLUDE_DIR ZOLTAN_LIBS)
19

20
21
22
find_package(Zoltan QUIET CONFIG)
if (ZOLTAN_FOUND)
  find_file(ZOLTAN_HEADER zoltan.h HINTS ${ZOLTAN_INCLUDE_DIRS})
23
  if (ZOLTAN_HEADER)
24
    set(ZOLTAN_INCLUDE_DIR ${ZOLTAN_INCLUDE_DIRS} PARENT_SCOPE)
25
26
27
  endif (ZOLTAN_HEADER)

  set(ZOLTAN_LIBS "")
28
29
  foreach (LIB_NAME ${ZOLTAN_LIBRARIES})
    find_library(_ZOLTAN_LIB ${LIB_NAME} HINTS ${ZOLTAN_LIBRARY_DIRS})
30
31
32
33
34
    if (_ZOLTAN_LIB)
      list(APPEND ZOLTAN_LIBS ${_ZOLTAN_LIB})
    endif ()
    unset(_ZOLTAN_LIB CACHE)
  endforeach(LIB_NAME)
35
else (ZOLTAN_FOUND)
36
37
38
39
40
41
42
43
44
  find_file(ZOLTAN_HEADER zoltan.h
    HINTS
      ${ZOLTAN_ROOT}
      ${PETSC_INCLUDE_DIRS}
      ENV ZOLTAN_ROOT
      ENV EBROOTZOLTAN
    PATH_SUFFIXES include/
  )
  if (ZOLTAN_HEADER)
45
46
47
48
49
    get_filename_component(ZOLTAN_INCLUDE_DIR "${ZOLTAN_HEADER}" PATH)

    # extract Zoltan version number
    file(STRINGS ${ZOLTAN_HEADER} ZOLTAN_VERSION_LINE REGEX "#define ZOLTAN_VERSION_NUMBER")
    string(REGEX MATCH "([0-9]+[.][0-9]+)" ZOLTAN_VERSION_REGEX ${ZOLTAN_VERSION_LINE})
50
    set(ZOLTAN_VERSION ${CMAKE_MATCH_1})
51
52
53
54
  endif (ZOLTAN_HEADER)

  find_library(ZOLTAN_LIB zoltan
    HINTS
55
      ${ZOLTAN_INCLUDE_DIR}/..
56
57
58
59
60
61
62
63
      ${ZOLTAN_ROOT}
      ${PETSC_LIB_DIRS}
      ENV ZOLTAN_ROOT
      ENV EBROOTZOLTAN
    PATH_SUFFIXES lib/ lib64/
  )

  include(parse_zoltan_makefile)
64
  find_file(ZOLTAN_CONFIG_FILE Makefile.export.zoltan HINTS ${ZOLTAN_INCLUDE_DIR})
65
66
67
68
  if (ZOLTAN_CONFIG_FILE)
    set(ZOLTAN_LIBS ${ZOLTAN_LIB})
    parse_zoltan_makefile(${ZOLTAN_CONFIG_FILE} ZOLTAN_LIBS)
  endif ()
69
endif (ZOLTAN_FOUND)
70
71
72
73

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zoltan
  REQUIRED_VARS ZOLTAN_INCLUDE_DIR ZOLTAN_LIBS
74
  VERSION_VAR ZOLTAN_VERSION
75
76
)

77
78
if(ZOLTAN_FOUND AND NOT TARGET ZOLTAN::ZOLTAN)
  add_library(ZOLTAN::ZOLTAN INTERFACE IMPORTED)
79

80
  set_target_properties(ZOLTAN::ZOLTAN PROPERTIES
81
82
83
84
    INTERFACE_INCLUDE_DIRECTORIES "${ZOLTAN_INCLUDE_DIR}"
    INTERFACE_LINK_LIBRARIES "${ZOLTAN_LIBS}"
  )
endif()