From b475389cc9272ebd6f69db3537e8d94f3aba476d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 29 May 2014 21:52:30 +0200 Subject: [PATCH 1/6] Math: make the constructors in test also constexpr. --- src/Magnum/Math/Test/MatrixTest.cpp | 4 ++-- src/Magnum/Math/Test/RectangularMatrixTest.cpp | 4 ++-- src/Magnum/Math/Test/VectorTest.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 2caf3a2fe..e61036340 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/src/Magnum/Math/Test/MatrixTest.cpp @@ -283,12 +283,12 @@ void MatrixTest::invertedOrthogonal() { template class BasicVec2: public Math::Vector<2, T> { public: - template BasicVec2(U&&... args): Math::Vector<2, T>{std::forward(args)...} {} + template constexpr BasicVec2(U&&... args): Math::Vector<2, T>{std::forward(args)...} {} }; template class BasicMat2: public Math::Matrix<2, T> { public: - template BasicMat2(U&&... args): Math::Matrix<2, T>{std::forward(args)...} {} + template constexpr BasicMat2(U&&... args): Math::Matrix<2, T>{std::forward(args)...} {} MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(2, BasicMat2, BasicVec2) }; diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index e0f524f23..b9917fff6 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/src/Magnum/Math/Test/RectangularMatrixTest.cpp @@ -413,7 +413,7 @@ void RectangularMatrixTest::vector() { template class BasicMat: public Math::RectangularMatrix { public: - template BasicMat(U&&... args): Math::RectangularMatrix{std::forward(args)...} {} + template constexpr BasicMat(U&&... args): Math::RectangularMatrix{std::forward(args)...} {} MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(size, size, BasicMat) }; @@ -422,7 +422,7 @@ MAGNUM_MATRIX_OPERATOR_IMPLEMENTATION(BasicMat) template class BasicMat2x2: public BasicMat<2, T> { public: - template BasicMat2x2(U&&... args): BasicMat<2, T>{std::forward(args)...} {} + template constexpr BasicMat2x2(U&&... args): BasicMat<2, T>{std::forward(args)...} {} MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(2, 2, BasicMat2x2) }; diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 60a984106..90c5adfdd 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -439,7 +439,7 @@ void VectorTest::angle() { template class BasicVec2: public Math::Vector<2, T> { public: - template BasicVec2(U&&... args): Math::Vector<2, T>{std::forward(args)...} {} + template constexpr BasicVec2(U&&... args): Math::Vector<2, T>{std::forward(args)...} {} MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(2, BasicVec2) }; From dcd89bac0a2151987d5b5fb4a181ff204ab08165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 29 May 2014 22:29:34 +0200 Subject: [PATCH 2/6] Math: no need to use class here. --- src/Magnum/Math/Matrix.h | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Magnum/Math/Matrix.h b/src/Magnum/Math/Matrix.h index ec8a7372b..fa05b1e1b 100644 --- a/src/Magnum/Math/Matrix.h +++ b/src/Magnum/Math/Matrix.h @@ -34,7 +34,7 @@ namespace Magnum { namespace Math { namespace Implementation { - template class MatrixDeterminant; + template struct MatrixDeterminant; } /** @@ -248,9 +248,8 @@ template inline Corrade::Utility::Debug operator<<(Co namespace Implementation { -template class MatrixDeterminant { - public: - T operator()(const Matrix& m); +template struct MatrixDeterminant { + T operator()(const Matrix& m); }; template T MatrixDeterminant::operator()(const Matrix& m) { @@ -262,18 +261,16 @@ template T MatrixDeterminant::operator()(con return out; } -template class MatrixDeterminant<2, T> { - public: - constexpr T operator()(const Matrix<2, T>& m) const { - return m[0][0]*m[1][1] - m[1][0]*m[0][1]; - } +template struct MatrixDeterminant<2, T> { + constexpr T operator()(const Matrix<2, T>& m) const { + return m[0][0]*m[1][1] - m[1][0]*m[0][1]; + } }; -template class MatrixDeterminant<1, T> { - public: - constexpr T operator()(const Matrix<1, T>& m) const { - return m[0][0]; - } +template struct MatrixDeterminant<1, T> { + constexpr T operator()(const Matrix<1, T>& m) const { + return m[0][0]; + } }; } From 4275f0ce9dde397a7ddcf77860a0676879feda07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 3 Jun 2014 00:23:37 +0200 Subject: [PATCH 3/6] package: added MinGW-w64 Jenkins CI configuration. Also mentioned forgotten NaCl configuration in docs. --- doc/building.dox | 10 ++- package/ci/jenkins-mingw-w64.xml | 137 +++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 package/ci/jenkins-mingw-w64.xml diff --git a/doc/building.dox b/doc/building.dox index 3d7c70870..4a3d318b6 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -502,13 +502,15 @@ library with every combination of them. You can add/remove the axes in Magnum-GLTests depend on active X11 session, thus they should be run from Jenkins instance running on graphical user session. -There is also MinGW32 and Emscripten configuration, add or update them with the -commands below. See @ref building-crosscompiling for more information about -setting up the crosscompilers and `toolchains/` submodule. For Emscripten you -need also **Node.js** installed to run the tests. +There is also MinGW32, MinGW-w64, Emscripten and NaCl configuration, add or +update them with the commands below. See @ref building-crosscompiling for more +information about setting up the crosscompilers and `toolchains/` submodule. +For Emscripten you need also **Node.js** installed to run the tests. java -jar jenkins-cli.jar -s http://your-jenkins-server Magnum-MinGW32 < jenkins-mingw32.xml + java -jar jenkins-cli.jar -s http://your-jenkins-server Magnum-MinGW-w64 < jenkins-mingw-w64.xml java -jar jenkins-cli.jar -s http://your-jenkins-server Magnum-Emscripten < jenkins-emscripten.xml + java -jar jenkins-cli.jar -s http://your-jenkins-server Magnum-NaCl < jenkins-nacl.xml */ } diff --git a/package/ci/jenkins-mingw-w64.xml b/package/ci/jenkins-mingw-w64.xml new file mode 100644 index 000000000..544e3cd18 --- /dev/null +++ b/package/ci/jenkins-mingw-w64.xml @@ -0,0 +1,137 @@ + + + + + + -1 + 10 + -1 + -1 + + false + + + 2 + + + git://github.com/mosra/magnum.git + + + + + */master + + + false + + + + true + + + + + true + false + false + false + + false + Magnum + + + arch + + 32 + 64 + + + + libraries + + static + dynamic + + + + compatibility + + + deprecated + + + + + + + + + + + + + Errors while running CTest + false + true + true + + + + + true + + + + + UNSTABLE + 1 + YELLOW + true + + + . + From 7e2cdf3136aa07fe1e7f8236fa6a014f3b14325a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 4 Jun 2014 21:11:30 +0200 Subject: [PATCH 4/6] modules: updated FindCorrade.cmake. --- modules/FindCorrade.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index a34fa3931..2a54a7861 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -19,6 +19,13 @@ # chosen based on actual build configuration of the project (i.e. Debug build # is linked to debug libraries, Release build to release libraries). # +# On multi-configuration build systems (such as Visual Studio or XCode) the +# preprocessor variable CORRADE_IS_DEBUG_BUILD is defined if given build +# configuration is Debug (not Corrade itself, but build configuration of the +# project using it). Useful e.g. for selecting proper plugin directory. On +# single-configuration build systems (such as Makefiles) this information is +# not needed and thus the variable is not defined in any case. +# # Corrade configures the compiler to use C++11 standard. Additionally you can # use CORRADE_CXX_FLAGS to enable additional pedantic set of warnings and # enable hidden visibility by default. @@ -31,6 +38,7 @@ # CORRADE_BUILD_STATIC - Defined if compiled as static libraries # CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor # (Linux, BSD, OS X) +# CORRADE_TARGET_APPLE - Defined if compiled for OS X # CORRADE_TARGET_WINDOWS - Defined if compiled for Windows # CORRADE_TARGET_NACL - Defined if compiled for Google Chrome # Native Client @@ -206,6 +214,10 @@ string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_UNIX" _TARGET_UNIX) if(NOT _TARGET_UNIX EQUAL -1) set(CORRADE_TARGET_UNIX 1) endif() +string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_APPLE" _TARGET_APPLE) +if(NOT _TARGET_APPLE EQUAL -1) + set(CORRADE_TARGET_APPLE 1) +endif() string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_WINDOWS" _TARGET_WINDOWS) if(NOT _TARGET_WINDOWS EQUAL -1) set(CORRADE_TARGET_WINDOWS 1) From e41f4c4fb98edc07e3f6cddb81f520264e666ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 4 Jun 2014 21:15:34 +0200 Subject: [PATCH 5/6] modules: expose separate plugin directories for debug and release builds. --- doc/cmake.dox | 40 +++++++++++++++++------------ doc/plugins.dox | 19 ++++++++++++-- modules/FindMagnum.cmake | 55 +++++++++++++++++++++++++++------------- 3 files changed, 79 insertions(+), 35 deletions(-) diff --git a/doc/cmake.dox b/doc/cmake.dox index b41db7848..b6ab4f3a9 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -51,19 +51,28 @@ variables: - `MAGNUM_FOUND` -- Whether the library was found - `MAGNUM_LIBRARIES` -- %Magnum library and dependent libraries - `MAGNUM_INCLUDE_DIRS` -- Root include dir and include dirs of dependencies +- `MAGNUM_PLUGINS_DEBUG_DIR` -- Base directory with dynamic plugins for debug + builds, defaults to `magnum-d/` subdirectory of dir where %Magnum library + was found +- `MAGNUM_PLUGINS_RELEASE_DIR` -- Base directory with dynamic plugins for + release builds, defaults to `magnum/` subdirectory of dir where %Magnum + library was found - `MAGNUM_PLUGINS_DIR` -- Base directory with dynamic plugins, defaults to - `magnum/` subdirectory of dir where Magnum library was found (or - `magnum-d/` in debug build). . You can modify it (e.g. set it to `.` when - deploying on Windows with plugins stored relatively to the executable), - the following `MAGNUM_PLUGINS_*_DIR` variables depend on it. -- `MAGNUM_PLUGINS_FONT_DIR` -- Directory with dynamic font plugins -- `MAGNUM_PLUGINS_FONTCONVERTER_DIR` -- Directory with dynamic font converter - plugins -- `MAGNUM_PLUGINS_IMAGECONVERTER_DIR` -- Directory with dynamic image - converter plugins -- `MAGNUM_PLUGINS_IMPORTER_DIR` -- Directory with dynamic importer plugins -- `MAGNUM_PLUGINS_AUDIOIMPORTER_DIR` -- Directory with dynamic audio importer + `MAGNUM_PLUGINS_RELEASE_DIR` in release builds and multi-configuration + builds or to `MAGNUM_PLUGINS_DEBUG_DIR` in debug builds. You can modify all + three variable (e.g. set them to `.` when deploying on Windows with plugins + stored relatively to the executable), the following `MAGNUM_PLUGINS_*_DIR` + variables depend on it. +- `MAGNUM_PLUGINS_FONT[|_DEBUG|_RELEASE]_DIR` -- Directory with dynamic font plugins +- `MAGNUM_PLUGINS_FONTCONVERTER[|_DEBUG|_RELEASE]_DIR` -- Directory with + dynamic font converter plugins +- `MAGNUM_PLUGINS_IMAGECONVERTER[|_DEBUG|_RELEASE]_DIR` -- Directory with + dynamic image converter plugins +- `MAGNUM_PLUGINS_IMPORTER[|_DEBUG|_RELEASE]_DIR` -- Directory with dynamic + importer plugins +- `MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR` -- Directory with + dynamic audio importer plugins However, this command will try to find only the base library, not the optional components. The base library depends on %Corrade and OpenGL libraries (or @@ -141,11 +150,10 @@ library (or plugin) is found. If both debug and release libraries (or plugins) are found, proper version is chosen based on actual build configuration of the project (i.e. `Debug` build is linked to debug libraries, `Release` build to release libraries). Note that this autodetection might fail for the -`MAGNUM_PLUGINS_DIR` variable, i.e. you might need to switch it manually to -`magnum-d/` or `magnum/` subdirectory based on whether you want to dynamically -load plugins with or without debug information. You can also make use of -`CMAKE_BUILD_TYPE` or `CMAKE_CFG_INTDIR` CMake variables for compile-time -decision. +`MAGNUM_PLUGINS_DIR` variable, especially on multi-configuration build systems. +You can make use of @ref corrade-cmake "CORRADE_IS_DEBUG_BUILD" preprocessor +variable along with `MAGNUM_PLUGINS_*_DEBUG_DIR` / `MAGNUM_PLUGINS_*_RELEASE_DIR` +variables to decide in preprocessing step. Features of found %Magnum library are exposed in these CMake variables, they are also available as preprocessor variables if including Magnum.h: diff --git a/doc/plugins.dox b/doc/plugins.dox index 95ab27ca7..f2c3b0a8e 100644 --- a/doc/plugins.dox +++ b/doc/plugins.dox @@ -96,9 +96,24 @@ to these: #define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DIR}" @endcode +In case you are using multi-configuration build system (such as Visual Studio +or XCode), CMake cannot provide separate plugin directory for debug and release +build and you have to do it on your own in preprocessing step using +@ref corrade-cmake "CORRADE_IS_DEBUG_BUILD" variable. This will ensure that you +use debug plugin directory for debug build on multi-configuration build sytems +and fall back to autodetection for the rest: +@code +#ifdef CORRADE_IS_DEBUG_BUILD +#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}" +#else +#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DIR}" +#endif +@endcode + Then process the file in your `CMakeLists.txt`. The result -(`${MAGNUM_PLUGINS_IMPORTER_DIR}` gets replaced with the actual value) is put -into build directory, so don't forget to add it to include path: +(`${MAGNUM_PLUGINS_IMPORTER_DIR}` / `${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}` gets +replaced with the actual value) is put into build directory, so don't forget to +add it to include path: @code configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index a75f53977..559bc6247 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -7,19 +7,28 @@ # MAGNUM_LIBRARIES - Magnum library and dependent libraries # MAGNUM_INCLUDE_DIRS - Root include dir and include dirs of # dependencies +# MAGNUM_PLUGINS_DEBUG_DIR - Base directory with dynamic plugins for +# debug builds, defaults to magnum-d/ subdirectory of dir where Magnum +# library was found +# MAGNUM_PLUGINS_RELEASE_DIR - Base directory with dynamic plugins for +# release builds, defaults to magnum/ subdirectory of dir where Magnum +# library was found # MAGNUM_PLUGINS_DIR - Base directory with dynamic plugins, defaults -# to magnum/ subdirectory of dir where Magnum library was found (or magnum-d/ -# in debug build). You can modify it (e.g. set it to `.` when deploying on -# Windows with plugins stored relatively to the executable), the following -# MAGNUM_PLUGINS_*_DIR variables depend on it. -# MAGNUM_PLUGINS_FONT_DIR - Directory with dynamic font plugins -# MAGNUM_PLUGINS_FONTCONVERTER_DIR - Directory with dynamic font converter -# plugins -# MAGNUM_PLUGINS_IMAGECONVERTER_DIR - Directory with dynamic image converter -# plugins -# MAGNUM_PLUGINS_IMPORTER_DIR - Directory with dynamic importer plugins -# MAGNUM_PLUGINS_AUDIOIMPORTER_DIR - Directory with dynamic audio importer +# to MAGNUM_PLUGINS_RELEASE_DIR in release builds and multi-configuration +# builds or to MAGNUM_PLUGINS_DEBUG_DIR in debug builds. You can modify all +# three variable (e.g. set them to . when deploying on Windows with plugins +# stored relatively to the executable), the following MAGNUM_PLUGINS_*_DIR +# variables depend on it. +# MAGNUM_PLUGINS_FONT[|_DEBUG|_RELEASE]_DIR - Directory with dynamic font # plugins +# MAGNUM_PLUGINS_FONTCONVERTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic +# font converter plugins +# MAGNUM_PLUGINS_IMAGECONVERTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic +# image converter plugins +# MAGNUM_PLUGINS_IMPORTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic +# importer plugins +# MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic +# audio importer plugins # This command will try to find only the base library, not the optional # components. The base library depends on Corrade and OpenGL libraries (or # OpenGL ES libraries). Additional dependencies are specified by the @@ -69,11 +78,10 @@ # plugins) are found, proper version is chosen based on actual build # configuration of the project (i.e. Debug build is linked to debug libraries, # Release build to release libraries). Note that this autodetection might fail -# for the MAGNUM_PLUGINS_DIR variable, i.e. you might need to switch it -# manually to magnum-d/ or magnum/ subdirectory based on whether you want -# to dynamically load plugins with or without debug information. You can also -# make use of CMAKE_BUILD_TYPE or CMAKE_CFG_INTDIR CMake variables for -# compile-time decision. +# for the MAGNUM_PLUGINS_DIR variable, especially on multi-configuration build +# systems. You can make use of CORRADE_IS_DEBUG_BUILD preprocessor variable +# along with MAGNUM_PLUGINS_*_DEBUG_DIR / MAGNUM_PLUGINS_*_RELEASE_DIR +# variables to decide in preprocessing step. # # Features of found Magnum library are exposed in these variables: # MAGNUM_BUILD_DEPRECATED - Defined if compiled with deprecated APIs @@ -156,7 +164,6 @@ if(MAGNUM_LIBRARY_DEBUG AND MAGNUM_LIBRARY_RELEASE) debug ${MAGNUM_LIBRARY_DEBUG} optimized ${MAGNUM_LIBRARY_RELEASE}) get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_DEBUG} PATH) - # TODO: how to handle this with MSVC and other multi-configuration tools? if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(_MAGNUM_PLUGINS_DIR_SUFFIX "-d") endif() @@ -516,12 +523,26 @@ if(MAGNUM_BUILD_DEPRECATED) endif() # Get base plugin directory from main library location +set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d + CACHE PATH "Base directory where to look for Magnum plugins for debug builds") +set(MAGNUM_PLUGINS_RELEASE_DIR ${_MAGNUM_LIBRARY_PATH}/magnum + CACHE PATH "Base directory where to look for Magnum plugins for release builds") set(MAGNUM_PLUGINS_DIR ${_MAGNUM_LIBRARY_PATH}/magnum${_MAGNUM_PLUGINS_DIR_SUFFIX} CACHE PATH "Base directory where to look for Magnum plugins") # Plugin directories set(MAGNUM_PLUGINS_FONT_DIR ${MAGNUM_PLUGINS_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fonts) set(MAGNUM_PLUGINS_FONTCONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/fontconverters) +set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fontconverters) +set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fontconverters) set(MAGNUM_PLUGINS_IMAGECONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/imageconverters) set(MAGNUM_PLUGINS_IMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/importers) set(MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) From c7b23a884fabea1298ac4e68d7fa4e8da6ab31a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 4 Jun 2014 21:47:41 +0200 Subject: [PATCH 6/6] Be consistent and use our own platform definitions. --- CMakeLists.txt | 10 +++++----- modules/FindMagnum.cmake | 2 +- src/Magnum/Audio/Audio.cpp | 2 +- src/Magnum/CMakeLists.txt | 2 +- src/Magnum/MeshTools/CMakeLists.txt | 2 +- src/Magnum/Platform/CMakeLists.txt | 8 ++++---- src/Magnum/Platform/Sdl2Application.cpp | 4 ++-- src/Magnum/Platform/magnum-info.cpp | 10 +++++++--- src/Magnum/SceneGraph/CMakeLists.txt | 2 +- src/Magnum/Text/CMakeLists.txt | 6 +++--- src/Magnum/Text/fontconverter.cpp | 2 +- src/Magnum/TextureTools/CMakeLists.txt | 6 +++--- src/Magnum/TextureTools/distancefieldconverter.cpp | 2 +- src/MagnumPlugins/MagnumFont/CMakeLists.txt | 4 ++-- src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt | 4 ++-- src/MagnumPlugins/ObjImporter/CMakeLists.txt | 2 +- src/MagnumPlugins/TgaImageConverter/CMakeLists.txt | 2 +- src/MagnumPlugins/TgaImporter/CMakeLists.txt | 2 +- src/MagnumPlugins/WavAudioImporter/CMakeLists.txt | 2 +- 19 files changed, 39 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbfe3073..c2c38630d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,8 +58,12 @@ if(CORRADE_TARGET_NACL) elseif(CORRADE_TARGET_ANDROID) option(WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF) +# OS X-specific application libraries +elseif(CORRADE_TARGET_APPLE) + cmake_dependent_option(WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON) + # X11, GLX and EGL-specific application libraries -elseif(CORRADE_TARGET_UNIX AND NOT APPLE) +elseif(CORRADE_TARGET_UNIX) option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF) cmake_dependent_option(WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON) cmake_dependent_option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF "TARGET_GLES" OFF) @@ -67,10 +71,6 @@ elseif(CORRADE_TARGET_UNIX AND NOT APPLE) # Windows-specific application libraries elseif(CORRADE_TARGET_WINDOWS) cmake_dependent_option(WITH_WINDOWLESSWGLAPPLICATION "Build WindowlessWglApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON) - -# OS X-specific application libraries -elseif(APPLE) - cmake_dependent_option(WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON) endif() # Platform-independent (almost) application libraries diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 559bc6247..22b5d029e 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -230,7 +230,7 @@ endif() # ${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(WIN32 OR MAGNUM_BUILD_STATIC) +if(CORRADE_TARGET_WINDOWS OR MAGNUM_BUILD_STATIC) set(_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY ${MAGNUM_LIBRARIES}) endif() diff --git a/src/Magnum/Audio/Audio.cpp b/src/Magnum/Audio/Audio.cpp index 4eb4ebbcb..90e4ea522 100644 --- a/src/Magnum/Audio/Audio.cpp +++ b/src/Magnum/Audio/Audio.cpp @@ -33,7 +33,7 @@ namespace Magnum { namespace Audio { /* Verify types */ static_assert(std::is_same::value, "ALubyte is not the same as UnsignedByte"); /** @todo Why `ALbyte` is defined as `char` and not `signed char` on OSX? */ -#ifndef __APPLE__ +#ifndef CORRADE_TARGET_APPLE static_assert(std::is_same::value, "ALbyte is not the same as Byte"); #else static_assert(std::is_signed::value && sizeof(ALbyte) == 1, "ALbyte does not have the same characteristics as Byte"); diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 765addc03..c3b0cf490 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -242,7 +242,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumMathTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index 67f9a9a82..e700d6f0f 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -91,7 +91,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumMeshToolsTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index e22996b88..09087aca0 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -232,14 +232,14 @@ endif() # Magnum Info if(WITH_MAGNUMINFO) add_executable(magnum-info magnum-info.cpp) - if(UNIX AND NOT CORRADE_TARGET_NACL AND NOT APPLE) - target_link_libraries(magnum-info MagnumWindowlessGlxApplication ${X11_LIBRARIES}) + if(CORRADE_TARGET_APPLE) + target_link_libraries(magnum-info MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_NACL) target_link_libraries(magnum-info MagnumWindowlessNaClApplication ppapi_cpp ppapi) + elseif(CORRADE_TARGET_UNIX) + target_link_libraries(magnum-info MagnumWindowlessGlxApplication ${X11_LIBRARIES}) elseif(CORRADE_TARGET_WINDOWS) target_link_libraries(magnum-info MagnumWindowlessWglApplication) - elseif(APPLE) - target_link_libraries(magnum-info MagnumWindowlessCglApplication) else() message(FATAL_ERROR "magnum-info is not available on this platform. Set WITH_MAGNUMINFO to OFF to skip building it.") endif() diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 7b7f91256..026ca4a76 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -143,7 +143,7 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { in Apple's GL drivers, thus we would be forever stuck on 2.1 without the new features. In practice SDL fails to create 2.1 context on recent OS X versions. */ - #elif defined(__APPLE__) + #elif defined(CORRADE_TARGET_APPLE) else { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); @@ -161,7 +161,7 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { } /* Fall back to GL 2.1, if 3.2 context creation fails on OS X */ - #ifdef __APPLE__ + #ifdef CORRADE_TARGET_APPLE if(!(context = SDL_GL_CreateContext(window))){ Warning() << "Platform::Sdl2Application::tryCreateContext(): cannot create core context:" << SDL_GetError() << "(falling back to compatibility context)"; SDL_DestroyWindow(window); diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index 94277c581..bc24d5ebe 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -52,7 +52,7 @@ #ifdef CORRADE_TARGET_NACL #include "Magnum/Platform/WindowlessNaClApplication.h" -#elif defined(__APPLE__) +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) #include "Magnum/Platform/WindowlessGlxApplication.h" @@ -102,10 +102,14 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifdef CORRADE_TARGET_NACL Debug() << "Used application: Platform::WindowlessNaClApplication"; - #elif defined(__APPLE__) + #elif defined(CORRADE_TARGET_APPLE) Debug() << "Used application: Platform::WindowlessCglApplication"; - #else + #elif defined(CORRADE_TARGET_UNIX) Debug() << "Used application: Platform::WindowlessGlxApplication"; + #elif defined(CORRADE_TARGET_WINDOWS) + Debug() << "Used application: Platform::WindowlessWglApplication"; + #else + #error No windowless application available on this platform #endif Debug() << "Compilation flags:"; #ifdef CORRADE_GCC47_COMPATIBILITY diff --git a/src/Magnum/SceneGraph/CMakeLists.txt b/src/Magnum/SceneGraph/CMakeLists.txt index 4b4c42b4b..f9166bec9 100644 --- a/src/Magnum/SceneGraph/CMakeLists.txt +++ b/src/Magnum/SceneGraph/CMakeLists.txt @@ -104,7 +104,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumSceneGraphTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index d5082cc06..50e59a4a8 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -67,11 +67,11 @@ if(WITH_FONTCONVERTER) add_executable(magnum-fontconverter fontconverter.cpp) - if(APPLE) + if(CORRADE_TARGET_APPLE) target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessCglApplication) - elseif(UNIX AND NOT TARGET_GLES) + elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES}) - elseif(WIN32) + elseif(CORRADE_TARGET_WINDOWS) target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-fontconverter is not available on this platform. Set WITH_FONTCONVERTER to OFF to suppress this warning.") diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index c5d0bed7d..690c87784 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -32,7 +32,7 @@ #include "Magnum/Text/DistanceFieldGlyphCache.h" #include "Magnum/Trade/AbstractImageConverter.h" -#ifdef __APPLE__ +#ifdef CORRADE_TARGET_APPLE #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) #include "Magnum/Platform/WindowlessGlxApplication.h" diff --git a/src/Magnum/TextureTools/CMakeLists.txt b/src/Magnum/TextureTools/CMakeLists.txt index 43ff501c6..d5ad0a28d 100644 --- a/src/Magnum/TextureTools/CMakeLists.txt +++ b/src/Magnum/TextureTools/CMakeLists.txt @@ -56,11 +56,11 @@ if(WITH_DISTANCEFIELDCONVERTER) add_executable(magnum-distancefieldconverter distancefieldconverter.cpp) - if(APPLE) + if(CORRADE_TARGET_APPLE) target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessCglApplication Magnum) - elseif(UNIX AND NOT TARGET_GLES) + elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) target_link_libraries(magnum-distancefieldconverter MagnumTextureTools Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES}) - elseif(WIN32) + elseif(CORRADE_TARGET_WINDOWS) target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessWglApplication Magnum) else() message(FATAL_ERROR "magnum-distancefieldconverter is not available on this platform. Set WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.") diff --git a/src/Magnum/TextureTools/distancefieldconverter.cpp b/src/Magnum/TextureTools/distancefieldconverter.cpp index d35514467..e15448bf4 100644 --- a/src/Magnum/TextureTools/distancefieldconverter.cpp +++ b/src/Magnum/TextureTools/distancefieldconverter.cpp @@ -37,7 +37,7 @@ #include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/ImageData.h" -#ifdef __APPLE__ +#ifdef CORRADE_TARGET_APPLE #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) #include "Magnum/Platform/WindowlessGlxApplication.h" diff --git a/src/MagnumPlugins/MagnumFont/CMakeLists.txt b/src/MagnumPlugins/MagnumFont/CMakeLists.txt index deaf8383e..a6c112d60 100644 --- a/src/MagnumPlugins/MagnumFont/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFont/CMakeLists.txt @@ -38,7 +38,7 @@ add_plugin(MagnumFont ${MAGNUM_PLUGINS_FONT_DEBUG_INSTALL_DIR} ${MAGNUM_PLUGINS_ pluginRegistration.cpp) target_link_libraries(MagnumFont Magnum MagnumText) -if(WIN32) +if(CORRADE_TARGET_WINDOWS) target_link_libraries(MagnumFont TgaImporter) endif() @@ -51,7 +51,7 @@ if(BUILD_GL_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumMagnumFontTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt index 49bf22a76..d6ef7f848 100644 --- a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt @@ -38,7 +38,7 @@ add_plugin(MagnumFontConverter ${MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_INSTALL_DIR} pluginRegistration.cpp) target_link_libraries(MagnumFontConverter Magnum MagnumText) -if(WIN32) +if(CORRADE_TARGET_WINDOWS) target_link_libraries(MagnumFontConverter TgaImageConverter) endif() @@ -51,7 +51,7 @@ if(BUILD_GL_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumMagnumFontConverterTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/MagnumPlugins/ObjImporter/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/CMakeLists.txt index f90a0bd4b..b8a62f5b7 100644 --- a/src/MagnumPlugins/ObjImporter/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/CMakeLists.txt @@ -43,7 +43,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumObjImporterTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt b/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt index 47676f258..08f4ff875 100644 --- a/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt @@ -47,7 +47,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumTgaImageConverterTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/MagnumPlugins/TgaImporter/CMakeLists.txt b/src/MagnumPlugins/TgaImporter/CMakeLists.txt index 7e6685b8a..afb01bc62 100644 --- a/src/MagnumPlugins/TgaImporter/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImporter/CMakeLists.txt @@ -48,7 +48,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumTgaImporterTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} diff --git a/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt b/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt index 27179d2a9..3660b3128 100644 --- a/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt +++ b/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt @@ -54,7 +54,7 @@ if(BUILD_TESTS) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) + if(CORRADE_TARGET_WINDOWS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS MagnumWavAudioImporterTestLib RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}