target_enable_zoltan.cmake 966 Bytes
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
macro(target_enable_zoltan _TARGET_ _SCOPE_)
    if (${ARGC} GREATER 2)
    set(LINK_EXECUTABLE ON)
  else ()
    set(LINK_EXECUTABLE OFF)
  endif ()

  find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${ZOLTAN_DIR}/include ${PETSC_INCLUDE_DIRS})
  if (ZOLTAN_HEADER_FILE)
    get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE)
    target_include_directories(${_TARGET_} ${_SCOPE_} ${ZOLTAN_HEADER_DIR})
  else()
    message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!")
  endif(ZOLTAN_HEADER_FILE)

  target_compile_definitions(${_TARGET_} ${_SCOPE_} HAVE_ZOLTAN=1)

  if (LINK_EXECUTABLE)
    find_library(ZOLTAN_LIB zoltan
      HINTS ENV LIBRARY_PATH DOC "Full path to the zoltan library")
    if (ZOLTAN_LIB)
      target_link_libraries(${_TARGET_} ${_SCOPE_} ${ZOLTAN_LIB})
    else()
      message(FATAL_ERROR "Could not find zoltan library!")
    endif()
  endif (LINK_EXECUTABLE)
endmacro(target_enable_zoltan)