Similar to the change done in Corrade, see the commit for details:
878624ac36
Wow, this is probably the most backwards-compatibility code I've ever
written. Can't wait until I can drop all that.
cmake_dependent_option(WITH_WINDOWLESSEGLAPPLICATION"Build WindowlessEglApplication library"OFF"NOT TARGET_GLES OR TARGET_DESKTOP_GLES OR NOT WITH_GL_INFO;NOT TARGET_HEADLESS"ON)
cmake_dependent_option(MAGNUM_WITH_WINDOWLESSEGLAPPLICATION"Build WindowlessEglApplication library"OFF"NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES OR NOT MAGNUM_WITH_GL_INFO;NOT TARGET_HEADLESS"ON)
option(BUILD_STATIC_PIC"Build static libraries and plugins with position-independent code"${ON_EXCEPT_EMSCRIPTEN})
cmake_dependent_option(BUILD_STATIC_UNIQUE_GLOBALS"Build static libraries with globals unique across shared libraries"${ON_EXCEPT_EMSCRIPTEN}"BUILD_STATIC"OFF)
option(BUILD_PLUGINS_STATIC"Build static plugins (default are dynamic)"OFF)
option(BUILD_TESTS"Build unit tests"OFF)
cmake_dependent_option(BUILD_GL_TESTS"Build unit tests for OpenGL code"OFF"BUILD_TESTS;TARGET_GL"OFF)
cmake_dependent_option(BUILD_AL_TESTS"Build unit tests for OpenAL code"ON"BUILD_TESTS;WITH_AUDIO"OFF)
cmake_dependent_option(BUILD_VK_TESTS"Build unit tests for Vulkan code"OFF"BUILD_TESTS;TARGET_VK"OFF)
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)
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.")
@ -989,7 +1003,7 @@ Then you can install the library using @cb{.sh} cmake --build . --target install
to make it available to depending projects.
If you have Node.js installed, you can also build and run unit tests using
`ctest`. See the `BUILD_TESTS` option @ref building-tests "above".
`ctest`. See the `MAGNUM_BUILD_TESTS` option @ref building-tests "above".
For ArchLinux there are also prepared package files in `package/archlinux`,
named `PKGBUILD-emscripten`, `PKGBUILD-emscripten-webgl2`,
@ -1023,10 +1037,10 @@ You can omit specifying `CORRADE_RC_EXECUTABLE` if
through `PATH`.
As every application is in its own sandbox, it doesn't make sense to build
shared libraries (although it is supported). Enable `BUILD_STATIC` to build
static libraries. Dynamically loaded plugins are not supported on iOS at the
moment, thus `BUILD_PLUGINS_STATIC` is implicitly enabled. OpenGL ES 2.0 is
enabled by default, switch to 3.0 by disabling `TARGET_GLES2`.
shared libraries (although it is supported). Enable `MAGNUM_BUILD_STATIC` to
build static libraries. Dynamically loaded plugins are not supported on iOS at
the moment, thus `MAGNUM_BUILD_PLUGINS_STATIC` is implicitly enabled. OpenGL ES
2.0 is enabled by default, switch to 3.0 by disabling `MAGNUM_TARGET_GLES2`.
@m_class{m-console-wrap}
@ -1038,10 +1052,10 @@ cmake .. \
-DCMAKE_OSX_ARCHITECTURES="arm64;armv7;armv7s" \
-DCMAKE_INSTALL_PREFIX=~/ios-libs \
-DCORRADE_RC_EXECUTABLE=/path/to/corrade-rc \
-DBUILD_STATIC=ON \
-DBUILD_PLUGINS_STATIC=ON \
-DTARGET_GLES2=OFF \
-DWITH_SDL2APPLICATION=ON \
-DMAGNUM_BUILD_STATIC=ON \
-DMAGNUM_BUILD_PLUGINS_STATIC=ON \
-DMAGNUM_TARGET_GLES2=OFF \
-DMAGNUM_WITH_SDL2APPLICATION=ON \
-G Xcode
cmake --build .
@endcode
@ -1072,10 +1086,10 @@ Create a build directory and run `cmake` and the build command in it. Set
ABI. Check the [CMake Android cross-compiling documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android)
for further information. You can omit specifying `CORRADE_RC_EXECUTABLE` if
@ref building-cross-corrade-rc "natively-built corrade-rc" is accessible
through `PATH`. Note that `BUILD_STATIC` is implicitly enabled, because
through `PATH`. Note that `MAGNUM_BUILD_STATIC` is implicitly enabled, because
manually loading all depending shared libraries using JNI would be too
inconvenient. The engine is built for OpenGL ES 2.0 by default, switch to 3.0
by disabling `TARGET_GLES2`.
by disabling `MAGNUM_TARGET_GLES2`.
If you set `CMAKE_INSTALL_PREFIX` to `/usr` subdirectory of the particular
Android platform sysroot (as shown below), Magnum's buildsystem will also pick
@ -36,10 +36,10 @@ required to follow them to the point.
@section developers-library Checklist for adding / removing a library
1. Add a `WITH_LIBRARYNAME` CMake option to:
1. Add a `MAGNUM_WITH_LIBRARYNAME` CMake option to:
- root `CMakeLists.txt` (if it has some inter-library dependencies,
update the others / convert them to @cmake cmake_dependent_option() @ce,
adding `NOT WITH_LIBRARYNAME` to their condition --- note the
adding `NOT MAGNUM_WITH_LIBRARYNAME` to their condition --- note the
conditions are ANDed so they need to be specified in reverse)
- the list in `doc/building.dox` (and similar files in other repos)
2. Update `FindMagnum.cmake` (or similar in other repos):
@ -73,17 +73,17 @@ required to follow them to the point.
- verify that target installation is done in proper places (separate
`RUNTIME` / `LIBRARY` / `ARCHIVE` destinations)
- verify that @cmake set_target_properties(MagnumLibraryName PROPERTIES VERSION ${MAGNUM_LIBRARY_VERSION} SOVERSION ${MAGNUM_LIBRARY_SOVERSION}) @ce
is done in case `BUILD_STATIC` is *not* set
is done in case `MAGNUM_BUILD_STATIC` is *not* set
- verify that @cmake set_target_properties(MagnumLibraryName PROPERTIES POSITION_INDEPENDENT_CODE ON) @ce
is done in case `BUILD_STATIC_PIC` is set
is done in case `MAGNUM_BUILD_STATIC_PIC` is set
- verify that @cmake add_library(Magnum::LibraryName ALIAS MagnumLibraryName) @ce
(or equivalent) is added to make the library visible for CMake
subprojects
6. Create a new `src/Magnum/LibraryName/Test/` directory:
- add a `CMakeLists.txt` with pre-populated license header, add your name
to it
- conditionally @cmake add_subdirectory() @ce it if `BUILD_TESTS` is
enabled
- conditionally @cmake add_subdirectory() @ce it if `MAGNUM_BUILD_TESTS`
is enabled
7. Create a new `src/Magnum/LibraryName/LibraryName.h` header for forward
declarations (if needed), add a file-level doc block with
<tt>Forward declarations for the \@ref Magnum::LibraryName namespace</tt>
@ -95,18 +95,19 @@ required to follow them to the point.
target name
- if the library is combined from an `OBJECT` library, add its name to
the above @cpp #ifdef @ce as well (and then explicitly add
@cmake target_compile_definitions(MagnumLibraryNameObjects PRIVATE "MagnumLibraryNameObjects_EXPORTS") @ce to `CMakeLists.txt` in case `BUILD_STATIC` is not set)
set(MAGNUM_WITH_SDL2APPLICATION ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL)
@endcode
@ -135,10 +135,10 @@ If you are lucky, you may already have Magnum packages ready for your platform:
If not, follow the full installation guides for @ref building-corrade "Corrade"
and @ref building "Magnum" to build & install everything; don't forget to
enable `WITH_SDL2APPLICATION` when building Magnum so the bootstrap project can
correctly find and use it. This is "the hard way" and it's recommended only if
you have at least some prior experience with building projects from source
using CMake.
enable `MAGNUM_WITH_SDL2APPLICATION` when building Magnum so the bootstrap
project can correctly find and use it. This is "the hard way" and it's
recommended only if you have at least some prior experience with building
projects from source using CMake.
Compared to @ref getting-started-setup-subproject "Option A", you don't need to
clone the subprojects and modify the `CMakeLists.txt` file, however you'll need
@ -316,8 +316,9 @@ want to try it with other toolkits such as [GLFW](https://www.glfw.org/) or
[Qt](https://www.qt.io/) there are similar projects in other branches of the
[bootstrap repository](https://github.com/mosra/magnum-bootstrap). If you
download [base-glfw.zip](https://github.com/mosra/magnum-bootstrap/archive/base-glfw.zip), you get a GLFW-based project. It's mostly the same, with only minor
differences. Enable `WITH_GLFWAPPLICATION` instead of `WITH_SDL2APPLICATION`,
on Linux or Mac install one of the following packages:
differences. Enable `MAGNUM_WITH_GLFWAPPLICATION` instead of
`MAGNUM_WITH_SDL2APPLICATION`, on Linux or Mac install one of the following
packages:
@code{.sh}
sudo pacman -S glfw-x11 # on ArchLinux
@ -333,7 +334,7 @@ or [glfw-3.3.bin.WIN64.zip](https://github.com/glfw/glfw/releases/download/3.3/g
list(APPEND_MAGNUM_REASON_FAILURE_MESSAGE"${_component} is not built by default. Make sure you enabled WITH_${_COMPONENT} when building Magnum.")
list(APPEND_MAGNUM_REASON_FAILURE_MESSAGE"${_component} is not built by default. Make sure you enabled MAGNUM_WITH_${_COMPONENT} when building Magnum.")
message(FATAL_ERROR"AndroidApplication is available only when targeting Android. Set WITH_ANDROIDAPPLICATION to OFF to skip building it.")
message(FATAL_ERROR"AndroidApplication is available only when targeting Android. Set MAGNUM_WITH_ANDROIDAPPLICATION to OFF to skip building it.")
endif()
find_package(EGLREQUIRED)
@ -180,9 +180,9 @@ if(WITH_ANDROIDAPPLICATION)
endif()
#Emscriptenapplication
if(WITH_EMSCRIPTENAPPLICATION)
if(MAGNUM_WITH_EMSCRIPTENAPPLICATION)
if(NOTCORRADE_TARGET_EMSCRIPTEN)
message(FATAL_ERROR"EmscriptenApplication is available only when targeting Emscripten. Set WITH_EMSCRIPTENAPPLICATION to OFF to skip building it.")
message(FATAL_ERROR"EmscriptenApplication is available only when targeting Emscripten. Set MAGNUM_WITH_EMSCRIPTENAPPLICATION to OFF to skip building it.")
@ -821,10 +821,10 @@ if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT)
endif()
#EGLcontext
if(NEED_EGLCONTEXTORWITH_EGLCONTEXT)
if(NEED_EGLCONTEXTORMAGNUM_WITH_EGLCONTEXT)
find_package(EGL)
if(NOTEGL_FOUND)
message(FATAL_ERROR"EGL library, required by some contexts, was not found. Set WITH_*APPLICATION and/or WITH_EGLCONTEXT to OFF to skip building them.")
message(FATAL_ERROR"EGL library, required by some contexts, was not found. Set MAGNUM_WITH_*APPLICATION and/or MAGNUM_WITH_EGLCONTEXT to OFF to skip building them.")
message(FATAL_ERROR"magnum-distancefieldconverter is not available on this platform. Set WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.")
message(FATAL_ERROR"magnum-distancefieldconverter is not available on this platform. Set MAGNUM_WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.")