FindMOAB.cmake 2.47 KB
Newer Older
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
# - Try to find MOAB headers and libraries
#
# Usage of this module as follows:
#
#     find_package(MOAB)
#
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
#  MOAB_ROOT_DIR  Set this variable to the root installation of
#                            MOAB if the module has problems finding
#                            the proper installation path.
#
# Variables defined by this module:
#
#  MOAB_FOUND              System has MOAB libs/headers
#  MOAB_INCLUDE_DIRS       The location of MOAB headers
#
# Targets defined by this module:
#  MOAB
#

find_path(MOAB_ROOT_DIR
    NAMES include/MOAB/version.h
)

find_path(MOAB_INCLUDE_DIR
    NAMES moab/Core.hpp
    HINTS ${MOAB_ROOT_DIR}/include/
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(MOAB DEFAULT_MSG
    MOAB_INCLUDE_DIR)

if(MOAB_FOUND)
39 40 41 42 43 44
  #if not set deduce the ROOT_DIR from the INCLUDE_DIR
  if(NOT MOAB_ROOT_DIR)
    get_filename_component(MOAB_ROOT_DIR
                           "${MOAB_INCLUDE_DIR}"
                           DIRECTORY)
  endif()
45

46 47 48 49 50 51 52 53 54 55 56
  if(SMTK_USE_SYSTEM_MOAB)
    #if using system moab, determine if we have found a build or install
    #version of the library
    if(EXISTS ${MOAB_ROOT_DIR}/lib/MOABConfig.cmake)
      #found a build version of moab
      include(${MOAB_ROOT_DIR}/lib/MOABConfig.cmake)
      include(${MOAB_ROOT_DIR}/lib/MOABTargets.cmake)
    elseif(EXISTS ${MOAB_ROOT_DIR}/lib/cmake/MOAB/MOABConfig.cmake)
      #found an install version of moab
      include(${MOAB_ROOT_DIR}/lib/cmake/MOAB/MOABConfig.cmake)
      include(${MOAB_ROOT_DIR}/lib/cmake/MOAB/MOABTargets.cmake)
David Thompson's avatar
David Thompson committed
57 58 59 60
    elseif(EXISTS ${MOAB_ROOT_DIR}/lib64/cmake/MOAB/MOABConfig.cmake)
      #found an install version of moab
      include(${MOAB_ROOT_DIR}/lib64/cmake/MOAB/MOABConfig.cmake)
      include(${MOAB_ROOT_DIR}/lib64/cmake/MOAB/MOABTargets.cmake)
61
    endif()
62 63 64 65
  else()
      #Use the config files provided by the third-party version of moab
      include(MOABConfig.cmake)
      include(MOABTargets.cmake)
66
  endif()
67

68 69 70 71 72 73
  #Certain version of moab define a scope variable called BUILD_SHARED_LIBS
  #which hides the cache version of said variable. So we defend against
  #this by unsetting the variable
  unset(BUILD_SHARED_LIBS)


74 75 76
  set_target_properties(MOAB PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${MOAB_INCLUDE_DIR}"
      )
77 78 79 80 81 82 83
endif()

set(MOAB_INCLUDE_DIRS ${MOAB_INCLUDE_DIR})
mark_as_advanced(
    MOAB_ROOT_DIR
    MOAB_INCLUDE_DIR
    )