diff --git a/doc/cmake.dox b/doc/cmake.dox index d545c04d3..84b1040ff 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -85,14 +85,13 @@ OpenGL ES libraries). Additional dependencies are specified by the components. The optional components are: - `Audio` -- @ref Audio library -- `DebugTools` -- @ref DebugTools library (depends on `MeshTools`, - `Primitives`, `SceneGraph`, `Shaders` and `Shapes` components) +- `DebugTools` -- @ref DebugTools library - `MeshTools` -- @ref MeshTools library - `Primitives` -- @ref Primitives library - `SceneGraph` -- @ref SceneGraph library - `Shaders` -- @ref Shaders library -- `Shapes` -- @ref Shapes library (depends on `SceneGraph` component) -- `Text` -- @ref Text library (depends on `TextureTools` component) +- `Shapes` -- @ref Shapes library +- `Text` -- @ref Text library - `TextureTools` -- @ref TextureTools library Platform namespace is split into more components: @@ -126,17 +125,14 @@ loads them dynamically. However, if they are built as static (see executable and then explicitly imported. Also if you are going to use them as dependencies, you need to find the dependency and then link to it. -- `MagnumFont` -- @ref Text::MagnumFont "MagnumFont" plugin (depends on - `Text` component and `TgaImporter` plugin) +- `MagnumFont` -- @ref Text::MagnumFont "MagnumFont" plugin - `MagnumFontConverter` -- @ref Text::MagnumFontConverter "MagnumFontConverter" - plugin (depends on `Text` component and `TgaImageConverter` plugin) -- `ObjImporter` -- @ref Trade::ObjImporter "ObjImporter" plugin (depends on - `MeshTools` component) + plugin +- `ObjImporter` -- @ref Trade::ObjImporter "ObjImporter" plugin - `TgaImageConverter` -- @ref Trade::TgaImageConverter "TgaImageConverter" plugin - `TgaImporter` -- @ref Trade::TgaImporter "TgaImporter" plugin - `WavAudioImporter` -- @ref Audio::WavImporter "WavAudioImporter" plugin - (depends on `Audio` component) Note that [each namespace](namespaces.html), all @ref Platform libraries and each plugin class contain more detailed information about dependencies, diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 3c784b381..1cf41856a 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -34,23 +34,20 @@ # OpenGL ES libraries). Additional dependencies are specified by the # components. The optional components are: # Audio - Audio library -# DebugTools - DebugTools library (depends on MeshTools, Primitives, -# SceneGraph, Shaders and Shapes components) +# DebugTools - DebugTools library # MeshTools - MeshTools library # Primitives - Primitives library # SceneGraph - SceneGraph library # Shaders - Shaders library -# Shapes - Shapes library (depends on SceneGraph component) -# Text - Text library (depends on TextureTools component) +# Shapes - Shapes library +# Text - Text library # TextureTools - TextureTools library -# MagnumFont - Magnum bitmap font plugin (depends on Text component -# and TgaImporter plugin) -# MagnumFontConverter - Magnum bitmap font converter plugin (depends on Text -# component and TgaImageConverter plugin) +# MagnumFont - Magnum bitmap font plugin +# MagnumFontConverter - Magnum bitmap font converter plugin # ObjImporter - OBJ importer plugin # TgaImageConverter - TGA image converter plugin # TgaImporter - TGA importer plugin -# WavAudioImporter - WAV audio importer plugin (depends on Audio component) +# WavAudioImporter - WAV audio importer plugin # GlutApplication - GLUT application # GlxApplication - GLX application # NaClApplication - NaCl application @@ -230,15 +227,44 @@ elseif(MAGNUM_TARGET_GLES3) set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY}) endif() -# On Windows and in static builds, *Application libraries need to have -# ${MAGNUM_LIBRARIES} listed in dependencies also after all other library names -# to avoid linker errors. Applicaiton libraries are often last thus it is -# +- sufficient to add it there only. -if(CORRADE_TARGET_WINDOWS OR MAGNUM_BUILD_STATIC) - set(_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY ${MAGNUM_LIBRARIES}) +# Ensure that all inter-component dependencies are specified as well +set(_MAGNUM_ADDITIONAL_COMPONENTS ) +foreach(component ${Magnum_FIND_COMPONENTS}) + string(TOUPPER ${component} _COMPONENT) + + # The dependencies need to be sorted by their dependency order as well + if(component STREQUAL Shapes) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES SceneGraph) + elseif(component STREQUAL Text) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TextureTools) + elseif(component STREQUAL DebugTools) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Shapes) + elseif(component STREQUAL MagnumFont) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TgaImporter) # and below + elseif(component STREQUAL MagnumFontConverter) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TgaImageConverter) # and below + elseif(component STREQUAL ObjImporter) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools) + endif() + + if(component MATCHES ".+AudioImporter") + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES Audio) + elseif(component MATCHES ".+(Font|FontConverter)") + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TextureTools Text) + endif() + + list(APPEND _MAGNUM_ADDITIONAL_COMPONENTS ${_MAGNUM_${_COMPONENT}_DEPENDENCIES}) +endforeach() + +# Join the lists, remove duplicate components +if(_MAGNUM_ADDITIONAL_COMPONENTS) + list(INSERT Magnum_FIND_COMPONENTS 0 ${_MAGNUM_ADDITIONAL_COMPONENTS}) +endif() +if(Magnum_FIND_COMPONENTS) + list(REMOVE_DUPLICATES Magnum_FIND_COMPONENTS) endif() -# Additional components +# Find all components foreach(component ${Magnum_FIND_COMPONENTS}) string(TOUPPER ${component} _COMPONENT) @@ -394,11 +420,6 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() endif() - # Common application dependencies - set(_MAGNUM_${_COMPONENT}_LIBRARIES - ${_MAGNUM_${_COMPONENT}_LIBRARIES} - ${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY}) - # Context libraries elseif(${component} MATCHES ".+Context") set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) @@ -466,10 +487,30 @@ foreach(component ${Magnum_FIND_COMPONENTS}) PATHS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) endif() + # Add inter-project dependencies, mark the component as not found if + # any dependency is not found + set(_MAGNUM_${_COMPONENT}_DEPENDENCY_LIBRARIES ) + set(_MAGNUM_${_COMPONENT}_DEPENDENCY_INCLUDE_DIRS ) + foreach(dependency ${_MAGNUM_${_COMPONENT}_DEPENDENCIES}) + string(TOUPPER ${dependency} _DEPENDENCY) + if(MAGNUM_${_DEPENDENCY}_LIBRARY) + list(APPEND _MAGNUM_${_COMPONENT}_DEPENDENCY_LIBRARIES ${MAGNUM_${_DEPENDENCY}_LIBRARY} ${_MAGNUM_${_DEPENDENCY}_LIBRARIES}) + list(APPEND _MAGNUM_${_COMPONENT}_DEPENDENCY_INCLUDE_DIRS ${MAGNUM_${_DEPENDENCY}_INCLUDE_DIRS}) + else() + unset(MAGNUM_${_DEPENDENCY}_LIBRARY) + endif() + endforeach() + # 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}_INCLUDE_DIRS ${_MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) + set(MAGNUM_${_COMPONENT}_LIBRARIES + ${MAGNUM_${_COMPONENT}_LIBRARY} + ${_MAGNUM_${_COMPONENT}_LIBRARIES} + ${_MAGNUM_${_COMPONENT}_DEPENDENCY_LIBRARIES} + ${MAGNUM_LIBRARIES}) + set(MAGNUM_${_COMPONENT}_INCLUDE_DIRS + ${_MAGNUM_${_COMPONENT}_INCLUDE_DIRS} + ${_MAGNUM_${_COMPONENT}_DEPENDENCY_INCLUDE_DIRS}) set(Magnum_${component}_FOUND TRUE)