ZoltanConfig.cmake 1.24 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
macro(parse_zoltan_makefile _FILE_ _TARGET_ _SCOPE_)

  file(STRINGS ${_FILE_} ZOLTAN_MAKEFILE_LINE REGEX "ZOLTAN_EXTRA_LIBS")
  get_filename_component(ZOLTAN_MAKEFILE_DIR "${ZOLTAN_MAKEFILE}" PATH CACHE)

  string(STRIP "${ZOLTAN_MAKEFILE_LINE}" LINE)
  if ("${LINE}" MATCHES "^ZOLTAN_EXTRA_LIBS[ ]*=[ ]*([a-zA-Z0-9_/. -]+)$")
    string(REGEX REPLACE " " ";" ZOLTAN_EXTRA_LIBS_LIST "${CMAKE_MATCH_1}")

    set(ZOLTAN_LIB_DIRS "")
    foreach(LIBS ${ZOLTAN_EXTRA_LIBS_LIST})
      string(STRIP "${LIBS}" LIBS)
      string(SUBSTRING "${LIBS}" 0 2 LIB_PREFIX)
      string(SUBSTRING "${LIBS}" 2 -1 LIB_NAME)
      if ("${LIB_PREFIX}" STREQUAL "-L")
        list(APPEND ZOLTAN_LIB_DIRS ${LIB_NAME})
      elseif ("${LIB_PREFIX}" STREQUAL "-l")
        find_library(_ZOLTAN_EXTERN_LIB ${LIB_NAME} HINTS ${ZOLTAN_LIB_DIRS})
        if (NOT _ZOLTAN_EXTERN_LIB)
          message(FATAL_ERROR "Could not find library \"${LIB_NAME}\" in directories ${ZOLTAN_LIB_DIRS}!")
        else ()
          target_link_libraries(${_TARGET_} ${_SCOPE_} ${_ZOLTAN_EXTERN_LIB})
        endif ()
        unset(_ZOLTAN_EXTERN_LIB CACHE)
      else ()
        message(WARNING "Unknown link parameter \"${LIBS}\"")
      endif ()
    endforeach (LIBS)
  endif()
endmacro(parse_zoltan_makefile)