diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 0aee97166..988cf4167 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -10,8 +10,9 @@ # MAGNUM_TARGET_GLES - Defined if Magnum was built for OpenGL ES, # slightly reducing feature count. The same variable is also #defined in # Magnum headers. -# MAGNUM_LIBRARY - Magnum library -# MAGNUM_INCLUDE_DIR - Root include dir +# MAGNUM_LIBRARIES - Magnum library and dependent libraries +# MAGNUM_INCLUDE_DIRS - Root include dir and include dirs of +# dependencies # MAGNUM_PLUGINS_IMPORTER_DIR - Directory with importer plugins # # This command will try to find only the base library, not the optional @@ -35,10 +36,14 @@ # For each component is then defined: # # MAGNUM_*_FOUND - Whether the component was found -# MAGNUM_*_LIBRARY - Component library +# MAGNUM_*_LIBRARIES - Component library and dependent libraries # # Additionally these variables are defined for internal usage: # +# MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies) +# MAGNUM_LIBRARY - Magnum library (w/o dependencies) +# MAGNUM_*_LIBRARY - Component libraries (w/o dependencies) +# # MAGNUM_LIBRARY_INSTALL_DIR - Library installation directory # MAGNUM_PLUGINS_INSTALL_DIR - Plugin installation directory # MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR - Importer plugin installation directory @@ -91,7 +96,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # GLUT context dependencies if(${component} STREQUAL GlutContext) find_package(GLUT) - if(NOT GLUT_FOUND) + if(GLUT_FOUND) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_LIBRARIES}) + else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() @@ -99,7 +106,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # SDL2 context dependencies if(${component} STREQUAL Sdl2Context) find_package(SDL2) - if(NOT SDL2_FOUND) + if(SDL2_FOUND) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY}) + else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() @@ -108,7 +117,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) if(${component} STREQUAL EglContext) find_package(EGL) find_package(X11) - if(NOT EGL_FOUND OR NOT X11_FOUND) + if(EGL_FOUND AND X11_FOUND) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${EGL_LIBRARY} ${X11_LIBRARIES}) + else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() @@ -143,6 +154,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # Decide if the library was found if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) + set(MAGNUM_${_COMPONENT}_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARY} ${_MAGNUM_${_COMPONENT}_LIBRARIES}) set(Magnum_${component}_FOUND TRUE) else() set(Magnum_${component}_FOUND FALSE) @@ -154,6 +166,21 @@ find_package_handle_standard_args(Magnum REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY HANDLE_COMPONENTS) +# Dependent libraries and includes +set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR} + ${CORRADE_INCLUDE_DIR}) +set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARY} + ${CORRADE_UTILITY_LIBRARY} + ${CORRADE_PLUGINMANAGER_LIBRARY}) +if(NOT MAGNUM_TARGET_GLES) + set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} + ${OPENGL_gl_LIBRARY} + ${GLEW_LIBRARY}) +else() + set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} + ${OPENGLES2_LIBRARY}) +endif() + # Installation dirs set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(MAGNUM_PLUGINS_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum) @@ -162,6 +189,8 @@ set(MAGNUM_CMAKE_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules) set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum/Plugins) mark_as_advanced(FORCE + MAGNUM_LIBRARY + MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY_INSTALL_DIR MAGNUM_PLUGINS_INSTALL_DIR MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR