Browse Source

Modularization of building and installation process.

By default everything except contexts is built, features can be
enabled/disables using WITH_* CMake options.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
6bd43a9f95
  1. 25
      CMakeLists.txt
  2. 14
      README.md
  3. 44
      doc/building.dox
  4. 51
      src/CMakeLists.txt
  5. 42
      src/Contexts/CMakeLists.txt
  6. 12
      src/Math/CMakeLists.txt
  7. 5
      src/Math/Geometry/CMakeLists.txt
  8. 12
      src/MeshTools/CMakeLists.txt
  9. 14
      src/Physics/CMakeLists.txt
  10. 7
      src/Primitives/CMakeLists.txt
  11. 3
      src/Shaders/CMakeLists.txt
  12. 13
      src/Trade/CMakeLists.txt

25
CMakeLists.txt

@ -2,10 +2,30 @@
cmake_minimum_required(VERSION 2.8.8)
project(Magnum)
include(CMakeDependentOption)
option(TARGET_GLES "Build for OpenGL ES 2 instead of desktop OpenGL" OFF)
# Parts of the library
option(WITH_EVERYTHING "Build everything (doesn't include contexts)" ON)
option(WITH_MESHTOOLS "Build MeshTools library" OFF)
option(WITH_PHYSICS "Build Physics library" OFF)
option(WITH_PRIMITIVES "Builf Primitives library" OFF)
option(WITH_SHADERS "Build Shaders library" OFF)
cmake_dependent_option(WITH_EGLCONTEXT "Build EglContext library" OFF "TARGET_GLES" OFF)
cmake_dependent_option(WITH_GLUTCONTEXT "Build GlutContext library" OFF "NOT TARGET_GLES" OFF)
option(WITH_SDL2CONTEXT "Build Sdl2Context library" OFF)
option(BUILD_TESTS "Build unit tests (requires Qt4)." OFF)
if(WITH_EVERYTHING)
set(WITH_MESHTOOLS ON)
set(WITH_PHYSICS ON)
set(WITH_PRIMITIVES ON)
set(WITH_SHADERS ON)
endif()
if(BUILD_TESTS)
find_package(Qt4)
@ -25,8 +45,3 @@ include(FindMagnum)
add_subdirectory(modules)
add_subdirectory(src)
install(DIRECTORY src/ DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}
FILES_MATCHING PATTERN "*.h"
PATTERN "*/Test" EXCLUDE
PATTERN "src/Contexts" EXCLUDE)

14
README.md

@ -33,7 +33,8 @@ Minimal dependencies
which are tested to support everything needed: **GCC** >= 4.6 and **Clang**
>= 3.1.
* **CMake** >= 2.8.8 (needed for `OBJECT` library target)
* **OpenGL headers**, on Linux most probably shipped with Mesa
* **OpenGL** headers, on Linux most probably shipped with Mesa or
**OpenGL ES 2** headers, if targeting OpenGL ES.
* **GLEW** - OpenGL extension wrangler
* **Corrade** - Plugin management and utility library. You can get it at
http://mosra.cz/blog/corrade.php
@ -41,11 +42,14 @@ Minimal dependencies
Compilation, installation
-------------------------
The library can be built and installed using these four commands:
The library (for example with GLUT context) can be built and installed using
these four commands:
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make
mkdir -p build && cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_GLUTCONTEXT=ON
make
make install
Building and running unit tests

44
doc/building.dox

@ -1,3 +1,4 @@
namespace Magnum {
/** @page building Downloading and building
@brief Guide how to download and build %Magnum on different platforms.
@ -15,7 +16,7 @@ Minimal set of tools and libraries required for building is:
>= 3.1.
- **CMake** >= 2.8.8 (needed for `OBJECT` library target)
- **OpenGL** headers, on Linux most probably shipped with Mesa or
**OpenGL ES 2** headers, if targetting OpenGL ES 2.
**OpenGL ES 2** headers, if targeting OpenGL ES (see below).
- **GLEW** - OpenGL extension wrangler
- **Corrade** - Plugin management and utility library. You can get it at
http://github.com/mosra/corrade or at http://mosra.cz/blog/corrade.php.
@ -36,19 +37,45 @@ subdirectory:
git submodule update
@section building-compilation Compilation, installation
The library can be built and installed using these four commands:
The library (for example with GLUT context) can be built and installed using
these four commands. See below for more information about optional features.
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make
mkdir -p build && cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_GLUTCONTEXT=ON
make
make install
By default the engine is built for desktop OpenGL. If you want to target
OpenGL ES 2, pass `-DTARGET_GLES=True` to CMake.
If you want to build with another compiler (e.g. Clang), pass
`-DCMAKE_CXX_COMPILER=clang++` to CMake.
@subsection building-optional Enabling or disabling features
By default the engine is built for desktop OpenGL. If you want to target
OpenGL ES, set `TARGET_GLES` to `ON` or pass `-DTARGET_GLES=ON` to CMake. Note
that some features are available for desktop OpenGL only, see @ref requires-gl.
By default the engine is built with everything except
@ref Contexts "context libraries". Using `WITH_*` CMake parameters you can
specify which parts will be built and which not:
- `WITH_EVERYTHING` - Defaults to `ON`, builds everything except contexts. If
set to `OFF`, only the main library is built and you can select additional
libraries with the following:
- `WITH_MESHTOOLS` - MeshTools library.
- `WITH_PHYSICS` - Physics library.
- `WITH_PRIMITIVES` - Primitives library.
- `WITH_SHADERS` - Shaders library.
None of the context libraries is built by default, regardless to
`WITH_EVERYTHING` is enabled or not:
- `WITH_EGLCONTEXT` - X/EGL context, available only if targeting OpenGL ES
(see above). Requires **X11** and **EGL** libraries.
- `WITH_GLUTCONTEXT` - GLUT context, available only if targeting desktop
OpenGL. Requires **GLUT** library.
- `WITH_SDL2CONTEXT` - SDL2 context. Requires **SDL2** library.
@subsection building-tests Building and running unit tests
If you want to build also unit tests (which are not built by default), pass
`-DBUILD_TESTS=True` to CMake. Unit tests use QtTest framework (you need at
@ -114,3 +141,4 @@ You may need to modify the `basic-mingw32.cmake` file and
`CMAKE_INSTALL_PREFIX` to suit your distribution filesystem hierarchy. If
everything goes well, in `build-win/` subdirectories will be the DLLs.
*/
}

51
src/CMakeLists.txt

@ -28,6 +28,34 @@ set(Magnum_SRCS
Trade/AbstractImporter.cpp
Trade/MeshData.cpp)
set(Magnum_HEADERS
AbstractImage.h
AbstractShaderProgram.h
AbstractTexture.h
BufferedImage.h
BufferedTexture.h
Buffer.h
Camera.h
CubeMapTextureArray.h
CubeMapTexture.h
Framebuffer.h
Image.h
ImageWrapper.h
IndexedMesh.h
Light.h
Magnum.h
Mesh.h
Object.h
Query.h
Renderbuffer.h
Scene.h
Set.h
Shader.h
SizeTraits.h
Texture.h
TypeTraits.h
magnumVisibility.h)
add_library(MagnumObjects OBJECT ${Magnum_SRCS})
# Files shared between main library and math unit test library
@ -56,20 +84,33 @@ else()
endif()
install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${Magnum_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR})
# Install also configure file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR})
add_subdirectory(Contexts)
add_subdirectory(Math)
add_subdirectory(MeshTools)
add_subdirectory(Physics)
add_subdirectory(Primitives)
add_subdirectory(Shaders)
add_subdirectory(Trade)
if(WITH_MESHTOOLS)
add_subdirectory(MeshTools)
endif()
if(WITH_PHYSICS)
add_subdirectory(Physics)
endif()
if(WITH_PRIMITIVES)
add_subdirectory(Primitives)
endif()
if(WITH_SHADERS)
add_subdirectory(Shaders)
endif()
if(BUILD_TESTS)
enable_testing()
include_directories(${QT_INCLUDE_DIR})
# Library with graceful assert for testing

42
src/Contexts/CMakeLists.txt

@ -1,36 +1,40 @@
install(FILES AbstractContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
# GLUT context
if(NOT TARGET_GLES)
if(WITH_GLUTCONTEXT)
find_package(GLUT)
if(GLUT_FOUND)
add_library(MagnumGlutContext STATIC GlutContext.cpp)
install(FILES GlutContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumGlutContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
message(WARNING "GLUT library was not found. GLUT context library will not be generated.")
message(FATAL_ERROR "GLUT library, required by GlutContext, was not found. Set WITH_GLUTCONTEXT to OFF to skip building it.")
endif()
endif()
# SDL2 context
find_package(SDL2)
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
add_library(MagnumSdl2Context STATIC Sdl2Context.cpp)
install(FILES Sdl2Context.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumSdl2Context DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
message(WARNING "SDL2 library was not found. SDL2 context library will not be generated.")
if(WITH_SDL2CONTEXT)
find_package(SDL2)
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
add_library(MagnumSdl2Context STATIC Sdl2Context.cpp)
install(FILES Sdl2Context.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumSdl2Context DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
message(FATAL_ERROR "SDL2 library, required by Sdl2Context, was not found. Set WITH_SDL2CONTEXT to OFF to skip building it.")
endif()
endif()
# X/EGL context
find_package(OpenGLES2)
find_package(EGL)
find_package(X11)
if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND)
add_library(MagnumEglContext STATIC EglContext.cpp)
install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
message(WARNING "OpenGL ES 2, EGL or X11 libraries were not found. EGL context library will not be generated.")
if(WITH_EGLCONTEXT)
find_package(OpenGLES2)
find_package(EGL)
find_package(X11)
if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND)
add_library(MagnumEglContext STATIC EglContext.cpp)
install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
message(FATAL_ERROR "OpenGL ES 2, EGL or X11 libraries, required by EglContext, were not found. Set WITH_EGLCONTEXT to OFF to skip building it.")
endif()
endif()

12
src/Math/CMakeLists.txt

@ -1,5 +1,17 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(MagnumMath_HEADERS
Math.h
MathTypeTraits.h
Matrix.h
Matrix3.h
Matrix4.h
Vector.h
Vector2.h
Vector3.h
Vector4.h)
install(FILES ${MagnumMath_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math)
add_subdirectory(Geometry)
if(BUILD_TESTS)

5
src/Math/Geometry/CMakeLists.txt

@ -1,5 +1,10 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(MagnumMathGeometry_HEADERS
Distance.h
Intersection.h)
install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(Test)

12
src/MeshTools/CMakeLists.txt

@ -1,6 +1,17 @@
# Files shared between main library and unit test library
set(MagnumMeshTools_SRCS
Tipsify.cpp)
set(MagnumMeshTools_HEADERS
Clean.h
CombineIndexedArrays.h
CompressIndices.h
FlipNormals.h
GenerateFlatNormals.h
Interleave.h
Subdivide.h
Tipsify.h
magnumMeshToolsVisibility.h)
add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS})
# Set shared library flags for the objects, as they will be part of shared lib
@ -19,6 +30,7 @@ add_library(MagnumMeshTools SHARED
target_link_libraries(MagnumMeshTools Magnum)
install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumMeshTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/MeshTools)
if(BUILD_TESTS)
enable_testing()

14
src/Physics/CMakeLists.txt

@ -6,12 +6,26 @@ set(MagnumPhysics_SRCS
Plane.cpp
ShapeGroup.cpp
Sphere.cpp)
set(MagnumPhysics_HEADERS
AbstractShape.h
AxisAlignedBox.h
Box.h
Capsule.h
Line.h
LineSegment.h
Plane.h
Point.h
ShapeGroup.h
Sphere.h
magnumPhysicsVisibility.h)
add_library(MagnumPhysics SHARED ${MagnumPhysics_SRCS})
target_link_libraries(MagnumPhysics Magnum)
install(TARGETS MagnumPhysics DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumPhysics_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Physics)
if(BUILD_TESTS)
enable_testing()

7
src/Primitives/CMakeLists.txt

@ -4,11 +4,18 @@ set(MagnumPrimitives_SRCS
Icosphere.cpp
Plane.cpp
UVSphere.cpp)
set(MagnumPrimitives_HEADERS
Capsule.h
Cube.h
Icosphere.h
Plane.h
UVSphere.h)
add_library(MagnumPrimitives STATIC ${MagnumPrimitives_SRCS})
target_link_libraries(MagnumPrimitives Magnum)
install(TARGETS MagnumPrimitives DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumPrimitives_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Primitives)
if(BUILD_TESTS)
enable_testing()

3
src/Shaders/CMakeLists.txt

@ -2,9 +2,12 @@ corrade_add_resource(MagnumShaders_RCS MagnumShaders PhongShader.frag PhongShade
set(MagnumShaders_SRCS
PhongShader.cpp
${MagnumShaders_RCS})
set(MagnumShaders_HEADERS
PhongShader.h)
add_library(MagnumShaders SHARED ${MagnumShaders_SRCS})
target_link_libraries(MagnumShaders Magnum)
install(TARGETS MagnumShaders DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumShaders_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Shaders)

13
src/Trade/CMakeLists.txt

@ -0,0 +1,13 @@
set(MagnumTrade_HEADERS
AbstractImporter.h
AbstractMaterialData.h
CameraData.h
ImageData.h
LightData.h
MeshData.h
MeshObjectData.h
ObjectData.h
PhongMaterialData.h
SceneData.h
TextureData.h)
install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade)
Loading…
Cancel
Save