Commit 1d6dc450 authored by Reuther, Sebastian's avatar Reuther, Sebastian

modified zoltan makefile parser (cmake)

parent 5278c061
macro(parse_zoltan_makefile _FILE_ _TARGET_ _SCOPE_)
file(STRINGS ${_FILE_} ZOLTAN_MAKEFILE_LINE REGEX "ZOLTAN_EXTRA_LIBS")
# parse zoltan extra libs AND ld flags
file(STRINGS ${_FILE_} ZOLTAN_EXTRA_LIBS_LINE REGEX "ZOLTAN_EXTRA_LIBS")
file(STRINGS ${_FILE_} ZOLTAN_LDFLAGS_LINE REGEX "ZOLTAN_LDFLAGS")
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(STRIP "${ZOLTAN_EXTRA_LIBS_LINE}" ZOLTAN_EXTRA_LIBS_LINE)
string(STRIP "${ZOLTAN_LDFLAGS_LINE}" ZOLTAN_LDFLAGS_LINE)
if ("${ZOLTAN_EXTRA_LIBS_LINE}" MATCHES "^ZOLTAN_EXTRA_LIBS[ ]*=[ ]*([a-zA-Z0-9_/. -]+)*$")
string(REGEX REPLACE " " ";" ZOLTAN_EXTRA_LIBS_LIST "${CMAKE_MATCH_1}")
if ("${ZOLTAN_LDFLAGS_LINE}" MATCHES "^ZOLTAN_LDFLAGS[ ]*=[ ]*([a-zA-Z0-9_/. -]+)*$")
string(REGEX REPLACE " " ";" ZOLTAN_LDFLAGS_LIST "${CMAKE_MATCH_1}")
set(COMBINED_LIST ${ZOLTAN_LDFLAGS_LIST} ${ZOLTAN_EXTRA_LIBS_LIST})
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}!")
set(ZOLTAN_LIB_DIRS "")
foreach(LIBS ${COMBINED_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 ()
target_link_libraries(${_TARGET_} ${_SCOPE_} ${_ZOLTAN_EXTERN_LIB})
message(WARNING "Unknown link parameter \"${LIBS}\"")
endif ()
unset(_ZOLTAN_EXTERN_LIB CACHE)
else ()
message(WARNING "Unknown link parameter \"${LIBS}\"")
endif ()
endforeach (LIBS)
endforeach (LIBS)
endif()
endif()
endmacro(parse_zoltan_makefile)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment