find/FindMathGL.cmake

53 lines
1.3 KiB
CMake

set(MATHGL_PREFIX "" CACHE PATH "The path to the prefix of an MathGL installation")
find_path(MATHGL_INCLUDE_DIR NAMES mgl2/mgl.h
PATHS
${MATHGL_PREFIX}/include
/opt/local/include
/usr/include
/usr/local/include
)
find_library(MATHGL_LIBRARIES NAMES mgl mgl2
PATHS
${MATHGL_PREFIX}/lib
/opt/local/lib
/usr/lib
/usr/local/lib
)
find_library(MATHGL_QT5_LIBRARIES NAMES mgl-qt5 mgl2-qt5
PATHS
${MATHGL_PREFIX}/lib
/opt/local/lib
/usr/lib
/usr/local/lib
)
if(MATHGL_INCLUDE_DIR AND MATHGL_LIBRARIES AND
NOT TARGET MathGL::Mgl AND NOT TARGET MathGL::Qt5)
get_filename_component(MATHGL_LIBRARY_DIR ${MATHGL_LIBRARIES} PATH)
set(MATHGL_FOUND TRUE)
add_library(MathGL::Mgl INTERFACE IMPORTED)
set_target_properties(MathGL::Mgl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${MATHGL_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${MATHGL_LIBRARIES}"
)
add_library(MathGL::Qt5 INTERFACE IMPORTED)
set_target_properties(MathGL::Qt5 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${MATHGL_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${MATHGL_QT5_LIBRARIES}"
)
endif()
if(MATHGL_FOUND)
if(NOT MATHGL_FIND_QUIETLY)
MESSAGE(STATUS "Found MathGL: ${MATHGL_LIBRARIES}")
endif()
set(HAVE_MATHGL 1)
elseif(MATHGL_FOUND)
if(MATHGL_FIND_REQUIRED)
message(FATAL_ERROR "Could not find MATHGL")
endif()
endif()