From 0c612dee3d7a47b09d1aef6b7fa89f16e4320ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Mar 2013 12:06:25 +0100 Subject: [PATCH] FindMagnum: provide MAGNUM_APPLICATION_{LIBRARIES,INCLUDE_DIRS} aliases. Convenience aliases to variables related to one particular *Application component, defined if and only if exactly one *Application component is requested and found. Meant to be used to simplify porting when each platform uses different *Application library. --- modules/FindMagnum.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 35c635118..ceae0e368 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -41,6 +41,10 @@ # MAGNUM_*_FOUND - Whether the component was found # MAGNUM_*_LIBRARIES - Component library and dependent libraries # MAGNUM_*_INCLUDE_DIRS - Include dirs of module dependencies +# If exactly one *Application component is requested and found, its +# libraries and include dirs are also available in convenience aliases +# MAGNUM_APPLICATION_LIBRARIES and MAGNUM_APPLICATION_INCLUDE_DIRS to +# simplify porting. # # Features of found Magnum library are exposed in these variables: # MAGNUM_TARGET_GLES - Defined if compiled for OpenGL ES @@ -283,6 +287,19 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # Don't expose variables w/o dependencies to end users mark_as_advanced(FORCE MAGNUM_${_COMPONENT}_LIBRARY _MAGNUM_${_COMPONENT}_INCLUDE_DIR) + + # If this is application library, make it available also in global + # MAGNUM_APPLICATION_LIBRARIES and MAGNUM_APPLICATION_INCLUDE_DIRS. If + # these variables are already set, unset them to avoid ambiguity. + if(${component} MATCHES .+Application) + if(NOT DEFINED MAGNUM_APPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_APPLICATION_INCLUDE_DIRS) + set(MAGNUM_APPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) + set(MAGNUM_APPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) + else() + unset(MAGNUM_APPLICATION_LIBRARIES) + unset(MAGNUM_APPLICATION_INCLUDE_DIRS) + endif() + endif() else() set(Magnum_${component}_FOUND FALSE) endif()