Browse Source

Plural versions of *_INCLUDE_DIR and *_LIBRARY FindMagnum variables.

It took me years to fully accept this CMake policy. Now it's enough to
specify ${MAGNUM_LIBRARIES} instead of all those Corrade, OpenGL /
OpenGL ES, GLEW etc. dependencies (heh).
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
fd78db3f47
  1. 41
      modules/FindMagnum.cmake

41
modules/FindMagnum.cmake

@ -10,8 +10,9 @@
# MAGNUM_TARGET_GLES - Defined if Magnum was built for OpenGL ES, # MAGNUM_TARGET_GLES - Defined if Magnum was built for OpenGL ES,
# slightly reducing feature count. The same variable is also #defined in # slightly reducing feature count. The same variable is also #defined in
# Magnum headers. # Magnum headers.
# MAGNUM_LIBRARY - Magnum library # MAGNUM_LIBRARIES - Magnum library and dependent libraries
# MAGNUM_INCLUDE_DIR - Root include dir # MAGNUM_INCLUDE_DIRS - Root include dir and include dirs of
# dependencies
# MAGNUM_PLUGINS_IMPORTER_DIR - Directory with importer plugins # MAGNUM_PLUGINS_IMPORTER_DIR - Directory with importer plugins
# #
# This command will try to find only the base library, not the optional # This command will try to find only the base library, not the optional
@ -35,10 +36,14 @@
# For each component is then defined: # For each component is then defined:
# #
# MAGNUM_*_FOUND - Whether the component was found # 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: # 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_LIBRARY_INSTALL_DIR - Library installation directory
# MAGNUM_PLUGINS_INSTALL_DIR - Plugin installation directory # MAGNUM_PLUGINS_INSTALL_DIR - Plugin installation directory
# MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR - Importer plugin installation directory # MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR - Importer plugin installation directory
@ -91,7 +96,9 @@ foreach(component ${Magnum_FIND_COMPONENTS})
# GLUT context dependencies # GLUT context dependencies
if(${component} STREQUAL GlutContext) if(${component} STREQUAL GlutContext)
find_package(GLUT) find_package(GLUT)
if(NOT GLUT_FOUND) if(GLUT_FOUND)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_LIBRARIES})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY) unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif() endif()
endif() endif()
@ -99,7 +106,9 @@ foreach(component ${Magnum_FIND_COMPONENTS})
# SDL2 context dependencies # SDL2 context dependencies
if(${component} STREQUAL Sdl2Context) if(${component} STREQUAL Sdl2Context)
find_package(SDL2) find_package(SDL2)
if(NOT SDL2_FOUND) if(SDL2_FOUND)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY) unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif() endif()
endif() endif()
@ -108,7 +117,9 @@ foreach(component ${Magnum_FIND_COMPONENTS})
if(${component} STREQUAL EglContext) if(${component} STREQUAL EglContext)
find_package(EGL) find_package(EGL)
find_package(X11) 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) unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif() endif()
endif() endif()
@ -143,6 +154,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
# Decide if the library was found # Decide if the library was found
if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR)
set(MAGNUM_${_COMPONENT}_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARY} ${_MAGNUM_${_COMPONENT}_LIBRARIES})
set(Magnum_${component}_FOUND TRUE) set(Magnum_${component}_FOUND TRUE)
else() else()
set(Magnum_${component}_FOUND FALSE) set(Magnum_${component}_FOUND FALSE)
@ -154,6 +166,21 @@ find_package_handle_standard_args(Magnum
REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY
HANDLE_COMPONENTS) 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 # Installation dirs
set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(MAGNUM_PLUGINS_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum) 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_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum/Plugins) set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum/Plugins)
mark_as_advanced(FORCE mark_as_advanced(FORCE
MAGNUM_LIBRARY
MAGNUM_INCLUDE_DIR
MAGNUM_LIBRARY_INSTALL_DIR MAGNUM_LIBRARY_INSTALL_DIR
MAGNUM_PLUGINS_INSTALL_DIR MAGNUM_PLUGINS_INSTALL_DIR
MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR

Loading…
Cancel
Save