#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
# 2020, 2021, 2022 Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
cmake_minimum_required ( VERSION 3.4 )
option ( HUNTER_ENABLED "Get dependencies (Corrade, GLFW, SDL2, ...) via Hunter" OFF )
if ( HUNTER_ENABLED )
include ( ${ CMAKE_CURRENT_LIST_DIR } /package/hunter/HunterInit.cmake )
endif ( )
# Don't restrict INTERPROCEDURAL_OPTIMIZATION only for icc on Linux
if ( POLICY CMP0069 )
cmake_policy ( SET CMP0069 NEW )
endif ( )
# If CMAKE_AUTOMOC is set, all uses of corrade_add_resource() would otherwise
# complain on 3.10 that AUTOMOC is not processing GENERATED files
if ( POLICY CMP0071 )
cmake_policy ( SET CMP0071 NEW )
endif ( )
# Superprojects can use just set(MAGNUM_WITH_BLAH ON) without FORCE CACHE on
# 3.13+
if ( POLICY CMP0077 )
cmake_policy ( SET CMP0077 NEW )
endif ( )
project ( Magnum CXX )
if ( HUNTER_ENABLED )
include ( ${ CMAKE_CURRENT_LIST_DIR } /package/hunter/HunterAddPackages.cmake )
endif ( )
# Use folders for nice tree in Visual Studio and XCode
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
set ( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${ CMAKE_MODULE_PATH } )
# Find Corrade first so we can check on the target
find_package ( Corrade REQUIRED Utility )
include ( CMakeDependentOption )
# Options that used to be unprefixed. 66 values for 67 option() and
# cmake_dependent_option() calls, one of which is HUNTER_ENABLED that we don't
# prefix. New options shouldn't be added to this list.
set ( _MAGNUM_DEPRECATED_UNPREFIXED_OPTIONS
W I T H _ A U D I O
W I T H _ D E B U G T O O L S
W I T H _ G L
W I T H _ M E S H T O O L S
W I T H _ P R I M I T I V E S
W I T H _ S C E N E G R A P H
W I T H _ S C E N E T O O L S
W I T H _ S H A D E R S
W I T H _ S H A D E R T O O L S
W I T H _ T E X T
W I T H _ T E X T U R E T O O L S
W I T H _ T R A D E
W I T H _ V K
W I T H _ O P E N G L T E S T E R
W I T H _ V U L K A N T E S T E R
W I T H _ A N D R O I D A P P L I C A T I O N
W I T H _ E M S C R I P T E N A P P L I C A T I O N
W I T H _ G L X A P P L I C A T I O N
W I T H _ G L F W A P P L I C A T I O N
W I T H _ S D L 2 A P P L I C A T I O N
W I T H _ X E G L A P P L I C A T I O N
W I T H _ W I N D O W L E S S C G L A P P L I C A T I O N
W I T H _ W I N D O W L E S S E G L A P P L I C A T I O N
W I T H _ W I N D O W L E S S G L X A P P L I C A T I O N
W I T H _ W I N D O W L E S S I O S A P P L I C A T I O N
W I T H _ W I N D O W L E S S W G L A P P L I C A T I O N
W I T H _ C G L C O N T E X T
W I T H _ E G L C O N T E X T
W I T H _ G L X C O N T E X T
W I T H _ W G L C O N T E X T
W I T H _ G L _ I N F O
W I T H _ A L _ I N F O
W I T H _ V K _ I N F O
W I T H _ F O N T C O N V E R T E R
W I T H _ D I S T A N C E F I E L D C O N V E R T E R
W I T H _ I M A G E C O N V E R T E R
W I T H _ S C E N E C O N V E R T E R
W I T H _ S H A D E R C O N V E R T E R
W I T H _ A N Y A U D I O I M P O R T E R
W I T H _ A N Y I M A G E C O N V E R T E R
W I T H _ A N Y I M A G E I M P O R T E R
W I T H _ A N Y S C E N E C O N V E R T E R
W I T H _ A N Y S C E N E I M P O R T E R
W I T H _ A N Y S H A D E R C O N V E R T E R
W I T H _ M A G N U M F O N T
W I T H _ M A G N U M F O N T C O N V E R T E R
W I T H _ O B J I M P O R T E R
W I T H _ T G A I M P O R T E R
W I T H _ T G A I M A G E C O N V E R T E R
W I T H _ W A V A U D I O I M P O R T E R
B U I L D _ D E P R E C A T E D
B U I L D _ S T A T I C
B U I L D _ S T A T I C _ P I C
B U I L D _ S T A T I C _ U N I Q U E _ G L O B A L S
B U I L D _ P L U G I N S _ S T A T I C
B U I L D _ T E S T S
B U I L D _ G L _ T E S T S
B U I L D _ A L _ T E S T S
B U I L D _ V K _ T E S T S
T A R G E T _ G L
T A R G E T _ G L E S
T A R G E T _ G L E S 2
T A R G E T _ D E S K T O P _ G L E S
T A R G E T _ H E A D L E S S
T A R G E T _ V K )
# If during the first run (i.e., when the variable isn't in cache yet), check
# if any of the prefixed options are already set. If so, we assume the user is
# already switched to the prefixed options and won't accept the deprecated
# unprefixed options for backwards compatibility. This way it's possible for
# projects to reuse these variables for other purposes without affecting
# Magnum in any way.
if ( NOT DEFINED _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS )
set ( _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS ON CACHE INTERNAL "" )
foreach ( option ${ _MAGNUM_DEPRECATED_UNPREFIXED_OPTIONS } )
if ( DEFINED MAGNUM_ ${ option } )
set ( _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS OFF CACHE INTERNAL "" )
break ( )
endif ( )
endforeach ( )
endif ( )
# Magnum GL Info (currently only using GLX/CGL/EGL on *nix, WGL/EGL on Windows
# and EGL on Emscripten)
if ( CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS OR CORRADE_TARGET_EMSCRIPTEN )
option ( MAGNUM_WITH_GL_INFO "Build magnum-gl-info utility" OFF )
endif ( )
# Desktop-only utilities. Not guaranteed to build on GLES, but showing the
# option everywhere for simplicity.
if ( CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS )
option ( MAGNUM_WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF )
if ( MAGNUM_WITH_FONTCONVERTER AND MAGNUM_BUILD_STATIC AND MAGNUM_BUILD_PLUGINS_STATIC )
set ( MAGNUM_FONTCONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-fontconverter utility" )
endif ( )
option ( MAGNUM_WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF )
if ( MAGNUM_WITH_DISTANCEFIELDCONVERTER AND MAGNUM_BUILD_STATIC AND MAGNUM_BUILD_PLUGINS_STATIC )
set ( MAGNUM_DISTANCEFIELDCONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-distancefieldconverter utility" )
endif ( )
endif ( )
# API-independent utilities
option ( MAGNUM_WITH_IMAGECONVERTER "Build magnum-imageconverter utility" OFF )
if ( MAGNUM_WITH_IMAGECONVERTER AND MAGNUM_BUILD_STATIC AND MAGNUM_BUILD_PLUGINS_STATIC )
set ( MAGNUM_IMAGECONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-imageconverter utility" )
endif ( )
option ( MAGNUM_WITH_SCENECONVERTER "Build magnum-sceneconverter utility" OFF )
if ( MAGNUM_WITH_SCENECONVERTER AND MAGNUM_BUILD_STATIC AND MAGNUM_BUILD_PLUGINS_STATIC )
set ( MAGNUM_SCENECONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-sceneconverter utility" )
endif ( )
option ( MAGNUM_WITH_SHADERCONVERTER "Build magnum-shaderconverter utility" OFF )
if ( MAGNUM_WITH_SHADERCONVERTER AND MAGNUM_BUILD_STATIC AND MAGNUM_BUILD_PLUGINS_STATIC )
set ( MAGNUM_SHADERCONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-shaderconverter utility" )
endif ( )
# Magnum AL Info
option ( MAGNUM_WITH_AL_INFO "Build magnum-al-info utility" OFF )
# Magnum Vk Info
option ( MAGNUM_WITH_VK_INFO "Build magnum-vk-info utility" OFF )
# Plugins
option ( MAGNUM_WITH_ANYIMAGEIMPORTER "Build AnyImageImporter plugin" OFF )
option ( MAGNUM_WITH_ANYAUDIOIMPORTER "Build AnyAudioImporter plugin" OFF )
option ( MAGNUM_WITH_ANYIMAGECONVERTER "Build AnyImageConverter plugin" OFF )
option ( MAGNUM_WITH_ANYSCENECONVERTER "Build AnySceneConverter plugin" OFF )
option ( MAGNUM_WITH_ANYSCENEIMPORTER "Build AnySceneImporter plugin" OFF )
option ( MAGNUM_WITH_ANYSHADERCONVERTER "Build AnyShaderConverter plugin" OFF )
option ( MAGNUM_WITH_WAVAUDIOIMPORTER "Build WavAudioImporter plugin" OFF )
option ( MAGNUM_WITH_MAGNUMFONT "Build MagnumFont plugin" OFF )
option ( MAGNUM_WITH_MAGNUMFONTCONVERTER "Build MagnumFontConverter plugin" OFF )
option ( MAGNUM_WITH_OBJIMPORTER "Build ObjImporter plugin" OFF )
cmake_dependent_option ( MAGNUM_WITH_TGAIMAGECONVERTER "Build TgaImageConverter plugin" OFF "NOT MAGNUM_WITH_MAGNUMFONTCONVERTER" ON )
cmake_dependent_option ( MAGNUM_WITH_TGAIMPORTER "Build TgaImporter plugin" OFF "NOT MAGNUM_WITH_MAGNUMFONT" ON )
# Parts of the library
cmake_dependent_option ( MAGNUM_WITH_AUDIO "Build Audio library" OFF "NOT MAGNUM_WITH_AL_INFO;NOT MAGNUM_WITH_ANYAUDIOIMPORTER;NOT MAGNUM_WITH_WAVAUDIOIMPORTER" ON )
option ( MAGNUM_WITH_DEBUGTOOLS "Build DebugTools library" ON )
option ( MAGNUM_WITH_MATERIALTOOLS "Build MaterialTools library" ON )
cmake_dependent_option ( MAGNUM_WITH_MESHTOOLS "Build MeshTools library" ON "NOT MAGNUM_WITH_OBJIMPORTER;NOT MAGNUM_WITH_SCENECONVERTER" ON )
option ( MAGNUM_WITH_SCENEGRAPH "Build SceneGraph library" ON )
cmake_dependent_option ( MAGNUM_WITH_SCENETOOLS "Build SceneTools library" ON "NOT MAGNUM_WITH_SCENECONVERTER" ON )
option ( MAGNUM_WITH_SHADERS "Build Shaders library" ON )
cmake_dependent_option ( MAGNUM_WITH_SHADERTOOLS "Build ShaderTools library" ON "NOT MAGNUM_WITH_SHADERCONVERTER" ON )
cmake_dependent_option ( MAGNUM_WITH_TEXT "Build Text library" ON "NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_MAGNUMFONT;NOT MAGNUM_WITH_MAGNUMFONTCONVERTER" ON )
cmake_dependent_option ( MAGNUM_WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT MAGNUM_WITH_TEXT;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON )
cmake_dependent_option ( MAGNUM_WITH_TRADE "Build Trade library" ON "NOT MAGNUM_WITH_MATERIALTOOLS;NOT MAGNUM_WITH_MESHTOOLS;NOT MAGNUM_WITH_PRIMITIVES;NOT MAGNUM_WITH_SCENETOOLS;NOT MAGNUM_WITH_IMAGECONVERTER;NOT MAGNUM_WITH_ANYIMAGEIMPORTER;NOT MAGNUM_WITH_ANYIMAGECONVERTER;NOT MAGNUM_WITH_ANYSCENEIMPORTER;NOT MAGNUM_WITH_OBJIMPORTER;NOT MAGNUM_WITH_TGAIMAGECONVERTER;NOT MAGNUM_WITH_TGAIMPORTER" ON )
cmake_dependent_option ( MAGNUM_WITH_GL "Build GL library" ON "NOT MAGNUM_WITH_SHADERS;NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_ANDROIDAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSIOSAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSCGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSGLXAPPLICATION;NOT MAGNUM_WITH_CGLCONTEXT;NOT MAGNUM_WITH_GLXAPPLICATION;NOT MAGNUM_WITH_GLXCONTEXT;NOT MAGNUM_WITH_XEGLAPPLICATION;NOT MAGNUM_WITH_WINDOWLESSWGLAPPLICATION;NOT MAGNUM_WITH_WGLCONTEXT;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON )
option ( MAGNUM_WITH_PRIMITIVES "Build Primitives library" ON )
cmake_dependent_option ( MAGNUM_TARGET_GL "Build libraries with OpenGL interoperability" ON "MAGNUM_WITH_GL" OFF )
# If targeting iOS, Android, Emscripten or Windows RT, implicitly enable GLES.
# Otherwise default to desktop GL.
if ( CORRADE_TARGET_IOS OR CORRADE_TARGET_ANDROID OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_WINDOWS_RT )
set ( MAGNUM_TARGET_GLES ON )
elseif ( MAGNUM_WITH_GL )
cmake_dependent_option ( MAGNUM_TARGET_GLES "Build for OpenGL ES / WebGL" OFF "MAGNUM_WITH_GL" OFF )
endif ( )
# If targeting Android, Emscripten or Windows RT, implicitly enable EGL.
# Otherwise enable EGL by default only if targeting GLES and not on iOS (where
# it's EAGL instead)
if ( CORRADE_TARGET_ANDROID OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_WINDOWS_RT )
set ( MAGNUM_TARGET_EGL ON )
else ( )
if ( MAGNUM_TARGET_GLES AND NOT CORRADE_TARGET_IOS )
set ( _MAGNUM_TARGET_EGL_DEFAULT ON )
else ( )
set ( _MAGNUM_TARGET_EGL_DEFAULT OFF )
endif ( )
cmake_dependent_option ( MAGNUM_TARGET_EGL "Build for EGL instead of EAGL / CGL / GLX / WGL" ${ _MAGNUM_TARGET_EGL_DEFAULT } "MAGNUM_WITH_GL" OFF )
endif ( )
cmake_dependent_option ( MAGNUM_TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "MAGNUM_TARGET_GLES" OFF )
# Vulkan, everywhere except Emscripten
if ( NOT CORRADE_TARGET_EMSCRIPTEN )
cmake_dependent_option ( MAGNUM_WITH_VK "Build Vk library" OFF "NOT MAGNUM_WITH_VK_INFO" ON )
cmake_dependent_option ( MAGNUM_TARGET_VK "Build libraries with Vulkan interoperability" ON "MAGNUM_WITH_VK" OFF )
endif ( )
# EGL context and windowless EGL application, available everywhere. If
# targeting EGL and not on Windows, it's implied by the CLI tools, otherwise
# it's independent.
if ( MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_WINDOWS )
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER;NOT MAGNUM_WITH_FONTCONVERTER" ON )
else ( )
# TODO when CMake 3.22 can be relied on, clean this up to use a proper
# condition instead
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF "ON" OFF )
endif ( )
option ( MAGNUM_WITH_EGLCONTEXT "Build EglContext library" OFF )
# Android-specific application libraries
if ( CORRADE_TARGET_ANDROID )
option ( MAGNUM_WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF )
# Emscripten-specific application libraries
elseif ( CORRADE_TARGET_EMSCRIPTEN )
option ( MAGNUM_WITH_EMSCRIPTENAPPLICATION "Build EmscriptenApplication library" OFF )
# iOS-specific application libraries
elseif ( CORRADE_TARGET_IOS )
option ( MAGNUM_WITH_WINDOWLESSIOSAPPLICATION "Build WindowlessIosApplication library" OFF )
# macOS-specific application libraries
elseif ( CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_EGL )
# WindowlessCglApplication implied by the CLI tools unless targeting EGL
if ( NOT MAGNUM_TARGET_EGL )
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON )
else ( )
# TODO when CMake 3.22 can be relied on, clean this up to use a proper
# condition instead
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "ON" OFF )
endif ( )
option ( MAGNUM_WITH_CGLCONTEXT "Build CglContext library" OFF )
# X11 + GLX/EGL-specific application libraries
elseif ( CORRADE_TARGET_UNIX )
option ( MAGNUM_WITH_GLXAPPLICATION "Build GlxApplication library" OFF )
# WindowlessGlxApplication implied by the CLI tools unless targeting EGL
if ( NOT MAGNUM_TARGET_EGL )
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON )
else ( )
# TODO when CMake 3.22 can be relied on, clean this up to use a proper
# condition instead
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "ON" OFF )
endif ( )
option ( MAGNUM_WITH_GLXCONTEXT "Build GlxContext library" OFF )
option ( MAGNUM_WITH_XEGLAPPLICATION "Build XEglApplication library" OFF )
# Windows-specific application libraries
elseif ( CORRADE_TARGET_WINDOWS )
# WindowlessWglApplication implied by the CLI tools unless targeting EGL
if ( NOT MAGNUM_TARGET_EGL )
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSWGLAPPLICATION "Build WindowlessWglApplication library" OFF "NOT MAGNUM_WITH_GL_INFO;NOT MAGNUM_WITH_FONTCONVERTER;NOT MAGNUM_WITH_DISTANCEFIELDCONVERTER" ON )
else ( )
# TODO when CMake 3.22 can be relied on, clean this up to use a proper
# condition instead
cmake_dependent_option ( MAGNUM_WITH_WINDOWLESSWGLAPPLICATION "Build WindowlessWglApplication library" OFF "ON" OFF )
endif ( )
option ( MAGNUM_WITH_WGLCONTEXT "Build WglContext library" OFF )
endif ( )
# Platform-independent (almost) application libraries
if ( NOT CORRADE_TARGET_ANDROID )
option ( MAGNUM_WITH_SDL2APPLICATION "Build Sdl2Application library" OFF )
endif ( )
if ( NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_EMSCRIPTEN )
option ( MAGNUM_WITH_GLFWAPPLICATION "Build GlfwApplication library" OFF )
endif ( )
option ( MAGNUM_BUILD_DEPRECATED "Include deprecated API in the build" ON )
set ( MAGNUM_DEPLOY_PREFIX "."
C A C H E S T R I N G " P r e f i x w h e r e t o p u t f i n a l a p p l i c a t i o n e x e c u t a b l e s " )
option ( MAGNUM_BUILD_STATIC "Build static libraries (default are shared)" OFF )
# Disable PIC on Emscripten by default (but still allow it to be enabled
# explicitly if one so desires). Currently causes linker errors related to
# __memory_base etc.: https://github.com/emscripten-core/emscripten/issues/8761
if ( CORRADE_TARGET_EMSCRIPTEN )
set ( ON_EXCEPT_EMSCRIPTEN OFF )
else ( )
set ( ON_EXCEPT_EMSCRIPTEN ON )
endif ( )
option ( MAGNUM_BUILD_STATIC_PIC "Build static libraries and plugins with position-independent code" ${ ON_EXCEPT_EMSCRIPTEN } )
cmake_dependent_option ( MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS "Build static libraries with globals unique across shared libraries" ${ ON_EXCEPT_EMSCRIPTEN } "MAGNUM_BUILD_STATIC" OFF )
option ( MAGNUM_BUILD_PLUGINS_STATIC "Build static plugins (default are dynamic)" OFF )
option ( MAGNUM_BUILD_TESTS "Build unit tests" OFF )
cmake_dependent_option ( MAGNUM_BUILD_GL_TESTS "Build unit tests for OpenGL code" OFF "MAGNUM_BUILD_TESTS;MAGNUM_TARGET_GL" OFF )
cmake_dependent_option ( MAGNUM_BUILD_AL_TESTS "Build unit tests for OpenAL code" ON "MAGNUM_BUILD_TESTS;MAGNUM_WITH_AUDIO" OFF )
cmake_dependent_option ( MAGNUM_BUILD_VK_TESTS "Build unit tests for Vulkan code" OFF "MAGNUM_BUILD_TESTS;MAGNUM_TARGET_VK" OFF )
# OpenGLTester / VulkanTester libraries, built by default only if GL / VK tests
# are enabled
cmake_dependent_option ( MAGNUM_WITH_OPENGLTESTER "Build OpenGLTester library" OFF "NOT MAGNUM_BUILD_GL_TESTS" ON )
cmake_dependent_option ( MAGNUM_WITH_VULKANTESTER "Build VulkanTester library" OFF "NOT MAGNUM_BUILD_VK_TESTS" ON )
# Backwards compatibility for unprefixed CMake options. If the user isn't
# explicitly using prefixed options in the first run already, accept the
# unprefixed options, and remember this decision for subsequent runs
if ( NOT DEFINED _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS )
set ( _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS ON CACHE INTERNAL "" )
endif ( )
# If the user wasn't explicitly using prefixed options in the first run and the
# MAGNUM_BUILD_DEPRECATED option is not currently disabled (which can get
# changed subsequently), accept the unprefixed options and print a warning if
# they're different from the prefixed ones.
if ( _MAGNUM_ACCEPT_DEPRECATED_UNPREFIXED_OPTIONS AND MAGNUM_BUILD_DEPRECATED )
# The following variables need extra care -- mirroring what's done in
# cmake_dependent_option(), but only the cases that enable a dependency
# that is off by default, not cases that hide an option from the GUI when
# it's needed by something else or cases that disable and hide the option
# from the GUI on unsupported platforms. In other words, if the original
# user flag setup didn't make sense before but the option dependency fixed
# it, it'll be broken now, but if it made sense, it should keep working.
#
# Doing this before propagating the unprefixed options to avoid a
# false-positive warning when e.g. MAGNUM_BUILD_STATIC_PIC is implicitly ON
# but BUILD_STATIC_PIC not yet.
if ( TARGET_GLES )
if ( NOT DEFINED TARGET_GLES2 )
set ( TARGET_GLES2 ON )
endif ( )
endif ( )
if ( BUILD_STATIC )
if ( NOT CORRADE_TARGET_EMSCRIPTEN AND NOT DEFINED BUILD_STATIC_PIC )
set ( BUILD_STATIC_PIC ON )
endif ( )
if ( NOT CORRADE_TARGET_EMSCRIPTEN AND NOT DEFINED BUILD_STATIC_UNIQUE_GLOBALS )
set ( BUILD_STATIC_UNIQUE_GLOBALS ON )
endif ( )
endif ( )
if ( BUILD_TESTS )
if ( NOT DEFINED BUILD_AL_TESTS )
set ( BUILD_AL_TESTS ON )
endif ( )
endif ( )
if ( BUILD_GL_TESTS )
if ( NOT DEFINED WITH_OPENGLTESTER )
set ( WITH_OPENGLTESTER ON )
endif ( )
endif ( )
if ( BUILD_VK_TESTS )
if ( NOT DEFINED WITH_VULKANTESTER )
set ( WITH_VULKANTESTER ON )
endif ( )
endif ( )
if ( WITH_MAGNUMFONTCONVERTER )
if ( NOT DEFINED WITH_TGAIMAGECONVERTER )
set ( WITH_TGAIMAGECONVERTER ON )
endif ( )
endif ( )
if ( WITH_MAGNUMFONT )
if ( NOT DEFINED WITH_TGAIMPORTER )
set ( WITH_TGAIMPORTER ON )
endif ( )
endif ( )
if ( WITH_AL_INFO OR WITH_ANYAUDIOIMPORTER OR WITH_WAVAUDIOIMPORTER )
if ( NOT DEFINED WITH_AUDIO )
set ( WITH_AUDIO ON )
endif ( )
endif ( )
if ( WITH_GL_INFO OR WITH_OPENGLTESTER OR WITH_DISTANCEFIELDCONVERTER )
if ( CORRADE_TARGET_ANDROID OR CORRADE_TARGET_EMSCRIPTEN )
if ( NOT DEFINED WITH_WINDOWLESSEGLAPPLICATION )
set ( WITH_WINDOWLESSEGLAPPLICATION ON )
endif ( )
elseif ( CORRADE_TARGET_IOS )
if ( NOT DEFINED WITH_WINDOWLESSIOSAPPLICATION )
set ( WITH_WINDOWLESSIOSAPPLICATION ON )
endif ( )
CMake: fix a bug where TARGET_GLES2 was forced on mobile platforms.
I'll be happy once I can delete all this brittle backwards compatibility
post-release. The problem is as follows -- when running CMake without
any options on Android, iOS, Emscripten or UWP, such as
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=path/to/toolchains/generic/Emscripten.cmake
It sees that no MAGNUM_-prefixed options were used, and thus assumes the
backwards compatibility for unprefixed WITH_, TARGET_ etc is still
desired, which is the right thing to do.
But then, there was a branch that enables TARGET_GLES *unconditionally*
on mobile platforms, if the backwards compatibility mode is enabled.
That alone would be harmless on its own, just causing garbage in the
CMake cache, unfortunately right after it sees that TARGET_GLES was set
and enables also TARGET_GLES2, because that's the default behavior. So
then, when one does
cmake . -DMAGNUM_TARGET_GLES2=ON
It'll ignore that option and instead yells at the users that TARGET_GLES
was set by them and it's deprecated, even though none of that was
actually intended:
CMake Deprecation Warning at CMakeLists.txt:501 (message):
Unprefixed options such as TARGET_GLES2 are deprecated, use
MAGNUM_TARGET_GLES2 instead. Delete the unprefixed variable from
CMake cache or set both to the same value to silence this warning.
The fix is that it's no longer setting TARGET_GLES implicitly on mobile
platforms, but instead considers the mobile platforms as well in
addition to checking if TARGET_GLES is set. Which means the backwards
compatibility variable dependencies only get set if there's at least one
of them coming from the user, never by default.
4 years ago
elseif ( CORRADE_TARGET_APPLE AND NOT TARGET_GLES AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT )
if ( NOT DEFINED WITH_WINDOWLESSCGLAPPLICATION )
set ( WITH_WINDOWLESSCGLAPPLICATION ON )
endif ( )
elseif ( CORRADE_TARGET_UNIX )
# Checking the old deprecated options here, checking
# MAGNUM_TARGET_EGL wouldn't make sense as that's an option the
# old code definitely won't use.
CMake: fix a bug where TARGET_GLES2 was forced on mobile platforms.
I'll be happy once I can delete all this brittle backwards compatibility
post-release. The problem is as follows -- when running CMake without
any options on Android, iOS, Emscripten or UWP, such as
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=path/to/toolchains/generic/Emscripten.cmake
It sees that no MAGNUM_-prefixed options were used, and thus assumes the
backwards compatibility for unprefixed WITH_, TARGET_ etc is still
desired, which is the right thing to do.
But then, there was a branch that enables TARGET_GLES *unconditionally*
on mobile platforms, if the backwards compatibility mode is enabled.
That alone would be harmless on its own, just causing garbage in the
CMake cache, unfortunately right after it sees that TARGET_GLES was set
and enables also TARGET_GLES2, because that's the default behavior. So
then, when one does
cmake . -DMAGNUM_TARGET_GLES2=ON
It'll ignore that option and instead yells at the users that TARGET_GLES
was set by them and it's deprecated, even though none of that was
actually intended:
CMake Deprecation Warning at CMakeLists.txt:501 (message):
Unprefixed options such as TARGET_GLES2 are deprecated, use
MAGNUM_TARGET_GLES2 instead. Delete the unprefixed variable from
CMake cache or set both to the same value to silence this warning.
The fix is that it's no longer setting TARGET_GLES implicitly on mobile
platforms, but instead considers the mobile platforms as well in
addition to checking if TARGET_GLES is set. Which means the backwards
compatibility variable dependencies only get set if there's at least one
of them coming from the user, never by default.
4 years ago
if ( ( NOT TARGET_GLES AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT AND NOT TARGET_HEADLESS ) OR TARGET_DESKTOP_GLES )
if ( NOT DEFINED WITH_WINDOWLESSGLXAPPLICATION )
set ( WITH_WINDOWLESSGLXAPPLICATION ON )
endif ( )
else ( )
if ( NOT DEFINED WITH_WINDOWLESSEGLAPPLICATION )
set ( WITH_WINDOWLESSEGLAPPLICATION ON )
endif ( )
endif ( )
elseif ( CORRADE_TARGET_WINDOWS )
CMake: fix a bug where TARGET_GLES2 was forced on mobile platforms.
I'll be happy once I can delete all this brittle backwards compatibility
post-release. The problem is as follows -- when running CMake without
any options on Android, iOS, Emscripten or UWP, such as
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=path/to/toolchains/generic/Emscripten.cmake
It sees that no MAGNUM_-prefixed options were used, and thus assumes the
backwards compatibility for unprefixed WITH_, TARGET_ etc is still
desired, which is the right thing to do.
But then, there was a branch that enables TARGET_GLES *unconditionally*
on mobile platforms, if the backwards compatibility mode is enabled.
That alone would be harmless on its own, just causing garbage in the
CMake cache, unfortunately right after it sees that TARGET_GLES was set
and enables also TARGET_GLES2, because that's the default behavior. So
then, when one does
cmake . -DMAGNUM_TARGET_GLES2=ON
It'll ignore that option and instead yells at the users that TARGET_GLES
was set by them and it's deprecated, even though none of that was
actually intended:
CMake Deprecation Warning at CMakeLists.txt:501 (message):
Unprefixed options such as TARGET_GLES2 are deprecated, use
MAGNUM_TARGET_GLES2 instead. Delete the unprefixed variable from
CMake cache or set both to the same value to silence this warning.
The fix is that it's no longer setting TARGET_GLES implicitly on mobile
platforms, but instead considers the mobile platforms as well in
addition to checking if TARGET_GLES is set. Which means the backwards
compatibility variable dependencies only get set if there's at least one
of them coming from the user, never by default.
4 years ago
if ( ( NOT TARGET_GLES AND NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT ) OR TARGET_DESKTOP_GLES )
if ( NOT DEFINED WITH_WINDOWLESSWGLAPPLICATION )
set ( WITH_WINDOWLESSWGLAPPLICATION ON )
endif ( )
else ( )
if ( NOT DEFINED WITH_WINDOWLESSEGLAPPLICATION )
set ( WITH_WINDOWLESSEGLAPPLICATION ON )
endif ( )
endif ( )
endif ( )
endif ( )
if ( WITH_VK_INFO OR WITH_VULKANTESTER )
if ( NOT DEFINED WITH_VK )
set ( WITH_VK ON )
endif ( )
endif ( )
if ( WITH_VK )
if ( NOT DEFINED TARGET_VK )
set ( TARGET_VK ON )
endif ( )
endif ( )
set ( _MAGNUM_WARN_DEPRECATED_UNPREFIXED_OPTION )
foreach ( option ${ _MAGNUM_DEPRECATED_UNPREFIXED_OPTIONS } )
if ( DEFINED ${ option } )
# CMake has no comparison of boolean values (EQUAL returns false if
# comparing ON and 1 or OFF and FALSE, STREQUAL also), so we have
# to do it this way. Also warn only on the first encountered
# variable so people can fix it, reconfigure and go to the next one
# that warns.
if ( ( ${ option } AND NOT MAGNUM_ ${ option } ) OR
( N O T $ { o p t i o n } A N D M A G N U M _ $ { o p t i o n } ) A N D N O T _ M A G N U M _ W A R N _ D E P R E C A T E D _ U N P R E F I X E D _ O P T I O N )
set ( _MAGNUM_WARN_DEPRECATED_UNPREFIXED_OPTION ${ option } )
endif ( )
set ( MAGNUM_ ${ option } ${ ${option } } )
# If variables specified on the command line don't match any
# options, they're kept in cache but set as UNINITIALIZED, meaning
# they don't appear in cmake-gui or ccmake, so there's no way to
# fix the warning apart from hand-enditing the CMakeCache.txt or
# recreating the build dir. Update their cached type to be BOOL to
# make them appear.
set ( ${ option } ${ ${option } } CACHE BOOL "Deprecated, use MAGNUM_${option} instead" FORCE )
endif ( )
endforeach ( )
if ( _MAGNUM_WARN_DEPRECATED_UNPREFIXED_OPTION )
# CMake 3.5+ has deprecation warnings enabled by default (which makes
# sense), 3.4 not. Use a warning there instead.
# TODO: drop when 3.4 is not supported anymore
if ( CMAKE_VERSION VERSION_LESS 3.5 )
set ( DEPRECATION_OR_WARNING WARNING )
else ( )
set ( DEPRECATION_OR_WARNING DEPRECATION )
endif ( )
message ( ${ DEPRECATION_OR_WARNING } "Unprefixed options such as ${_MAGNUM_WARN_DEPRECATED_UNPREFIXED_OPTION} are deprecated, use MAGNUM_${_MAGNUM_WARN_DEPRECATED_UNPREFIXED_OPTION} instead. Delete the unprefixed variable from CMake cache or set both to the same value to silence this warning." )
endif ( )
endif ( )
# Handle other deprecated options. For non-deprecated builds CMake will at most
# warn about "variable being unused". Done after the MAGNUM_ prefix backwards
# compatibility above to pick up also the old names, i.e. TARGET_HEADLESS ->
# MAGNUM_TARGET_EGL.
if ( MAGNUM_BUILD_DEPRECATED )
# BUILD_MULTITHREADED got moved to Corrade itself. Print a warning in case
# it's set but Corrade reports a different value. We can't print a warning
# in case it's set because that would cause false positives when both
# Corrade and Magnum are subprojects (and thus this option is visible to
# both).
if ( DEFINED BUILD_MULTITHREADED AND ( ( NOT CORRADE_BUILD_MULTITHREADED AND BUILD_MULTITHREADED ) OR ( CORRADE_BUILD_MULTITHREADED AND NOT BUILD_MULTITHREADED ) ) )
message ( DEPRECATION "BUILD_MULTITHREADED (set to ${BUILD_MULTITHREADED}) is now ignored — you need to set it when building Corrade instead (there it's ${CORRADE_BUILD_MULTITHREADED} now)" )
endif ( )
# The following two options were desktop-only, so don't handle any
# backwards compatibility on mobile / web platforms
if ( NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT )
# MAGNUM_TARGET_HEADLESS is now MAGNUM_TARGET_EGL. Print a warning in
# case we're on desktop GL (where it was meant to be used) and the two
# are set to a different value, and sync them.
if ( NOT MAGNUM_TARGET_GLES AND DEFINED MAGNUM_TARGET_HEADLESS AND ( ( NOT MAGNUM_TARGET_EGL AND MAGNUM_TARGET_HEADLESS ) OR ( MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_HEADLESS ) ) )
message ( DEPRECATION "MAGNUM_TARGET_HEADLESS is deprecated, use MAGNUM_TARGET_EGL instead" )
set ( MAGNUM_TARGET_EGL ${ MAGNUM_TARGET_HEADLESS } )
endif ( )
# MAGNUM_TARGET_DESKTOP_GLES is now an inverse of MAGNUM_TARGET_EGL.
# Print a warning in case we're on GLES (where it was meant to be used)
# and the two are set to a different value, and sync them.
if ( MAGNUM_TARGET_GLES AND DEFINED MAGNUM_TARGET_DESKTOP_GLES AND ( ( MAGNUM_TARGET_EGL AND MAGNUM_TARGET_DESKTOP_GLES ) OR ( NOT MAGNUM_TARGET_EGL AND NOT MAGNUM_TARGET_DESKTOP_GLES ) ) )
message ( DEPRECATION "MAGNUM_TARGET_DESKTOP_GLES is deprecated, use MAGNUM_TARGET_EGL instead" )
if ( MAGNUM_TARGET_DESKTOP_GLES )
set ( MAGNUM_TARGET_EGL OFF )
else ( )
set ( MAGNUM_TARGET_EGL ON )
endif ( )
endif ( )
endif ( )
endif ( )
# Dynamic linking is meaningless on Emscripten and too inconvenient on Android
if ( CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID )
set ( MAGNUM_BUILD_STATIC ON )
set ( MAGNUM_BUILD_PLUGINS_STATIC ON )
# Dynamic plugins are not working on iOS or Windows RT at the moment
elseif ( CORRADE_TARGET_IOS OR CORRADE_TARGET_WINDOWS_RT )
set ( MAGNUM_BUILD_PLUGINS_STATIC ON )
endif ( )
# Check dependencies
if ( MAGNUM_WITH_GL )
if ( NOT MAGNUM_TARGET_GLES OR ( MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_EGL AND NOT CORRADE_TARGET_IOS ) )
# OpenGL library preference. Prefer to use GLVND, since that's the
# better approach nowadays, but allow the users to override it from
# outside in case it is broken for some reason (Nvidia drivers in
# Debian's testing (Buster) -- reported on 2019-04-09).
if ( NOT CMAKE_VERSION VERSION_LESS 3.10 AND NOT OpenGL_GL_PREFERENCE )
set ( OpenGL_GL_PREFERENCE GLVND )
endif ( )
find_package ( OpenGL REQUIRED )
elseif ( MAGNUM_TARGET_GLES2 )
find_package ( OpenGLES2 REQUIRED )
else ( )
find_package ( OpenGLES3 REQUIRED )
endif ( )
else ( )
# Especially now with the backwards compatibility for unprefixed variables
# it's easiest to just force-disable all this
set ( MAGNUM_TARGET_GL OFF )
# These are implicitly enabled for embedded platforms, disable them all for
# consistency
set ( MAGNUM_TARGET_GLES OFF )
set ( MAGNUM_TARGET_GLES2 OFF )
set ( MAGNUM_TARGET_EGL OFF )
endif ( )
if ( NOT MAGNUM_WITH_VK )
# Especially now with the backwards compatibility for unprefixed variables
# it's easiest to just force-disable this
set ( MAGNUM_TARGET_VK OFF )
endif ( )
# Dependent configuration variables
if ( MAGNUM_TARGET_GLES )
if ( NOT MAGNUM_TARGET_GLES2 )
set ( MAGNUM_TARGET_GLES3 1 )
endif ( )
if ( CORRADE_TARGET_EMSCRIPTEN )
set ( MAGNUM_TARGET_WEBGL 1 )
endif ( )
endif ( )
# Testing setup
if ( MAGNUM_BUILD_TESTS )
find_package ( Corrade REQUIRED TestSuite )
if ( CORRADE_TARGET_IOS )
set ( CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX "cz.mosra.magnum" )
endif ( )
enable_testing ( )
# For experimental Gradle-less Android APK creation. Only with CMake > 3.7
# that has builtin Android support -- Gradle uses 3.6 so this will nicely
# work in both cases.
if ( CORRADE_TARGET_ANDROID AND CMAKE_ANDROID_NDK )
include ( ${ PROJECT_SOURCE_DIR } /toolchains/modules/UseAndroid.cmake )
endif ( )
# If CORRADE_TESTSUITE_TEST_TARGET is set, tests aren't built by default
# (in the ALL target) but instead set as dependencies of a target named
# after the value of CORRADE_TESTSUITE_TEST_TARGET. This is a copy of
# what's done in corrade_add_test(), because we also build various test
# libraries and plugins in addition to the test executables.
if ( CORRADE_TESTSUITE_TEST_TARGET )
if ( NOT TARGET ${ CORRADE_TESTSUITE_TEST_TARGET } )
add_custom_target ( ${ CORRADE_TESTSUITE_TEST_TARGET } )
endif ( )
set ( EXCLUDE_FROM_ALL_IF_TEST_TARGET EXCLUDE_FROM_ALL )
endif ( )
endif ( )
if ( MAGNUM_WITH_OPENGLTESTER )
if ( MAGNUM_TARGET_EGL )
set ( MAGNUM_WITH_WINDOWLESSEGLAPPLICATION ON )
set ( OPENGLTESTER_APPLICATION MagnumWindowlessEglApplication )
elseif ( CORRADE_TARGET_IOS )
set ( MAGNUM_WITH_WINDOWLESSIOSAPPLICATION ON )
set ( OPENGLTESTER_APPLICATION MagnumWindowlessIosApplication )
elseif ( CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES )
set ( MAGNUM_WITH_WINDOWLESSCGLAPPLICATION ON )
set ( OPENGLTESTER_APPLICATION MagnumWindowlessCglApplication )
elseif ( CORRADE_TARGET_UNIX )
set ( MAGNUM_WITH_WINDOWLESSGLXAPPLICATION ON )
set ( OPENGLTESTER_APPLICATION MagnumWindowlessGlxApplication )
elseif ( CORRADE_TARGET_WINDOWS )
set ( MAGNUM_WITH_WINDOWLESSWGLAPPLICATION ON )
set ( OPENGLTESTER_APPLICATION MagnumWindowlessWglApplication )
else ( )
# Assuming this gets hit only if MAGNUM_BUILD_GL_TESTS are enabled
message ( FATAL_ERROR "Cannot run tests for OpenGL code on this platform. Set MAGNUM_BUILD_GL_TESTS to OFF to skip building them." )
endif ( )
endif ( )
if ( NOT MAGNUM_BUILD_STATIC )
set ( SHARED_OR_STATIC SHARED )
else ( )
set ( SHARED_OR_STATIC STATIC )
endif ( )
# If we're in a CMake subproject, find_package(Magnum) will be looking for
# these when targeting Emscripten, so supply their in-source location
if ( CORRADE_TARGET_EMSCRIPTEN AND NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
set ( MAGNUM_EMSCRIPTENAPPLICATION_JS ${ PROJECT_SOURCE_DIR } /src/Magnum/Platform/EmscriptenApplication.js CACHE INTERNAL "" FORCE )
set ( MAGNUM_WINDOWLESSEMSCRIPTENAPPLICATION_JS ${ PROJECT_SOURCE_DIR } /src/Magnum/Platform/WindowlessEmscriptenApplication.js CACHE INTERNAL "" FORCE )
set ( MAGNUM_WEBAPPLICATION_CSS ${ PROJECT_SOURCE_DIR } /src/Magnum/Platform/WebApplication.css CACHE INTERNAL "" FORCE )
endif ( )
# Installation paths
include ( ${ CORRADE_LIB_SUFFIX_MODULE } )
set ( MAGNUM_BINARY_INSTALL_DIR bin )
set ( MAGNUM_LIBRARY_INSTALL_DIR lib ${ LIB_SUFFIX } )
set ( MAGNUM_DATA_INSTALL_DIR share/magnum )
set ( MAGNUM_CMAKE_MODULE_INSTALL_DIR share/cmake/Magnum )
set ( MAGNUM_INCLUDE_INSTALL_DIR include/Magnum )
set ( MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR include/MagnumExternal )
set ( MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR include/MagnumPlugins )
if ( MAGNUM_BUILD_DEPRECATED AND MAGNUM_INCLUDE_INSTALL_PREFIX AND NOT MAGNUM_INCLUDE_INSTALL_PREFIX STREQUAL "." )
message ( DEPRECATION "MAGNUM_INCLUDE_INSTALL_PREFIX is obsolete as its primary use was for old Android NDK versions. Please switch to the NDK r19+ layout instead of using this variable and recreate your build directory to get rid of this warning." )
set ( MAGNUM_DATA_INSTALL_DIR ${ MAGNUM_INCLUDE_INSTALL_PREFIX } / ${ MAGNUM_DATA_INSTALL_DIR } )
set ( MAGNUM_CMAKE_MODULE_INSTALL_DIR ${ MAGNUM_INCLUDE_INSTALL_PREFIX } / ${ MAGNUM_CMAKE_MODULE_INSTALL_DIR } )
set ( MAGNUM_INCLUDE_INSTALL_DIR ${ MAGNUM_INCLUDE_INSTALL_PREFIX } / ${ MAGNUM_INCLUDE_INSTALL_DIR } )
set ( MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${ MAGNUM_INCLUDE_INSTALL_PREFIX } / ${ MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR } )
set ( MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${ MAGNUM_INCLUDE_INSTALL_PREFIX } / ${ MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR } )
endif ( )
# Separate install dirs for debug and release plugins
set ( MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_BINARY_INSTALL_DIR } /magnum-d )
set ( MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_LIBRARY_INSTALL_DIR } /magnum-d )
set ( MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_BINARY_INSTALL_DIR } /magnum )
set ( MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_LIBRARY_INSTALL_DIR } /magnum )
set ( MAGNUM_PLUGINS_FONT_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /fonts )
set ( MAGNUM_PLUGINS_FONT_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /fonts )
set ( MAGNUM_PLUGINS_FONT_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /fonts )
set ( MAGNUM_PLUGINS_FONT_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /fonts )
set ( MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMPORTER_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /importers )
set ( MAGNUM_PLUGINS_IMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /importers )
set ( MAGNUM_PLUGINS_IMPORTER_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /importers )
set ( MAGNUM_PLUGINS_IMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /importers )
set ( MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } /audioimporters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } /audioimporters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_BINARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } /audioimporters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } /audioimporters )
# Plugin dirs based on whether we are in debug or release build, needed by some
# command-line tools
if ( CORRADE_TARGET_WINDOWS )
set ( MAGNUM_PLUGINS_DEBUG_DIR_INIT ${ CMAKE_INSTALL_PREFIX } / ${ MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR } )
set ( MAGNUM_PLUGINS_RELEASE_DIR_INIT ${ CMAKE_INSTALL_PREFIX } / ${ MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR } )
else ( )
set ( MAGNUM_PLUGINS_DEBUG_DIR_INIT ${ CMAKE_INSTALL_PREFIX } / ${ MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR } )
set ( MAGNUM_PLUGINS_RELEASE_DIR_INIT ${ CMAKE_INSTALL_PREFIX } / ${ MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR } )
endif ( )
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set ( MAGNUM_PLUGINS_DIR_INIT ${ MAGNUM_PLUGINS_DEBUG_DIR_INIT } )
else ( )
set ( MAGNUM_PLUGINS_DIR_INIT ${ MAGNUM_PLUGINS_RELEASE_DIR_INIT } )
endif ( )
# Make these paths configurable from outside. This is *not* PATH, because CMake
# always converts the path to an absolute location internally, making it
# impossible to specify relative paths there. Sorry in advance for not having
# the dir selection button in CMake GUI.
set ( MAGNUM_PLUGINS_DEBUG_DIR ""
C A C H E S T R I N G " B a s e d i r e c t o r y w h e r e t o l o o k f o r M a g n u m p l u g i n s f o r d e b u g b u i l d s " )
set ( MAGNUM_PLUGINS_RELEASE_DIR ""
C A C H E S T R I N G " B a s e d i r e c t o r y w h e r e t o l o o k f o r M a g n u m p l u g i n s f o r r e l e a s e b u i l d s " )
set ( MAGNUM_PLUGINS_DIR ""
C A C H E S T R I N G " B a s e d i r e c t o r y w h e r e t o l o o k f o r M a g n u m p l u g i n s " )
# Plugin directories. Set only if the above are non-empty. otherwise empty as
# well.
if ( MAGNUM_PLUGINS_DIR )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_DIR ${ MAGNUM_PLUGINS_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_FONT_DIR ${ MAGNUM_PLUGINS_DIR } /fonts )
set ( MAGNUM_PLUGINS_FONTCONVERTER_DIR ${ MAGNUM_PLUGINS_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_DIR ${ MAGNUM_PLUGINS_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMPORTER_DIR ${ MAGNUM_PLUGINS_DIR } /importers )
set ( MAGNUM_PLUGINS_SCENECONVERTER_DIR ${ MAGNUM_PLUGINS_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${ MAGNUM_PLUGINS_DIR } /audioimporters )
endif ( )
if ( MAGNUM_PLUGINS_DEBUG_DIR )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_FONT_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /fonts )
set ( MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /importers )
set ( MAGNUM_PLUGINS_FONT_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /fonts )
set ( MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${ MAGNUM_PLUGINS_DEBUG_DIR } /audioimporters )
endif ( )
if ( MAGNUM_PLUGINS_RELEASE_DIR )
set ( MAGNUM_PLUGINS_SHADERCONVERTER_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /shaderconverters )
set ( MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /fontconverters )
set ( MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /imageconverters )
set ( MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /importers )
set ( MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /sceneconverters )
set ( MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${ MAGNUM_PLUGINS_RELEASE_DIR } /audioimporters )
endif ( )
# Library version. MAGNUM_VERSION_YEAR/MONTH is used in
# src/Magnum/CMakeLists.txt to generate the version.h header.
set ( MAGNUM_LIBRARY_VERSION 2.4 )
set ( MAGNUM_LIBRARY_SOVERSION 2 )
set ( MAGNUM_VERSION_YEAR 2020 )
set ( MAGNUM_VERSION_MONTH 6 )
# A single output location. After a decade of saying NO THIS IS A NON-SOLUTION
# TO A NON-PROBLEM I reconsidered my views and enabled this, because:
#
# - On Windows (which don't have RPATH), this makes test execution finally
# possible without having to install all the stuff first (including the
# test-only libs, which is ugh).
# - With CMake subprojects, this makes it finally possible to use dynamic
# plugins directly from the build dir (again without installing anything) ---
# all plugins are put into the same place, so PluginManager has a single
# place to look into; and thanks to the dynamic libraries being there as
# well, this location can be automagically detected as relative to
# Utility::Path::libraryLocation().
# - Thanks to the $<CONFIG> being part of the output path, you are always sure
# you never accidentally mix up debug/release libraries when switching
# CMAKE_BUILD_TYPE in an existing build dir.
#
# The runtime location is set to CMAKE_BINARY_DIR and not PROJECT_BINARY_DIR
# because have one runtime location per CMake subproject would not solve much
# either. If the user already provides CMAKE_RUNTIME_OUTPUT_DIRECTORY (even
# empty), it's respected and nothing is being done.
#
# Explicitly using a generator expression to ensure plugins are added to e.g.
# <CONFIG>/lib/magnum/importers/ instead of lib/magnum/importers/<CONFIG>. Also
# adding this to cache, making superprojects pick that up implicitly as well,
# without forcing them to explicitly mirror this setting.
if ( NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY AND NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY AND NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } / $< CONFIG > /bin CACHE PATH "" FORCE )
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } / $< CONFIG > /lib CACHE PATH "" FORCE )
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } / $< CONFIG > /lib CACHE PATH "" FORCE )
endif ( )
add_subdirectory ( modules )
add_subdirectory ( src )
# Build snippets as part of testing. Unlike all other Test/ directories, this
# one isn't added with ${EXCLUDE_FROM_ALL_IF_TEST_TARGET} because the targets
# from there aren't referenced by CTest and thus it'd likely happen that they
# accidentally don't get added as a dependency to that target, causing them to
# be never built. Instead, each target there is handled separately, to minimize
# the chance of an accident.
if ( MAGNUM_BUILD_TESTS )
add_subdirectory ( doc/snippets )
endif ( )