Browse Source

Modularization of building and installation process.

By default everything except contexts is built, features can be
enabled/disables using WITH_* CMake options.
pull/279/head
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) cmake_minimum_required(VERSION 2.8.8)
project(Magnum) project(Magnum)
include(CMakeDependentOption)
option(TARGET_GLES "Build for OpenGL ES 2 instead of desktop OpenGL" OFF) 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) 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) if(BUILD_TESTS)
find_package(Qt4) find_package(Qt4)
@ -25,8 +45,3 @@ include(FindMagnum)
add_subdirectory(modules) add_subdirectory(modules)
add_subdirectory(src) 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** which are tested to support everything needed: **GCC** >= 4.6 and **Clang**
>= 3.1. >= 3.1.
* **CMake** >= 2.8.8 (needed for `OBJECT` library target) * **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 * **GLEW** - OpenGL extension wrangler
* **Corrade** - Plugin management and utility library. You can get it at * **Corrade** - Plugin management and utility library. You can get it at
http://mosra.cz/blog/corrade.php http://mosra.cz/blog/corrade.php
@ -41,11 +42,14 @@ Minimal dependencies
Compilation, installation 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 mkdir -p build && cd build
cd build cmake .. \
cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make -DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_GLUTCONTEXT=ON
make
make install make install
Building and running unit tests Building and running unit tests

44
doc/building.dox

@ -1,3 +1,4 @@
namespace Magnum {
/** @page building Downloading and building /** @page building Downloading and building
@brief Guide how to download and build %Magnum on different platforms. @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. >= 3.1.
- **CMake** >= 2.8.8 (needed for `OBJECT` library target) - **CMake** >= 2.8.8 (needed for `OBJECT` library target)
- **OpenGL** headers, on Linux most probably shipped with Mesa or - **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 - **GLEW** - OpenGL extension wrangler
- **Corrade** - Plugin management and utility library. You can get it at - **Corrade** - Plugin management and utility library. You can get it at
http://github.com/mosra/corrade or at http://mosra.cz/blog/corrade.php. http://github.com/mosra/corrade or at http://mosra.cz/blog/corrade.php.
@ -36,19 +37,45 @@ subdirectory:
git submodule update git submodule update
@section building-compilation Compilation, installation @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 mkdir -p build && cd build
cd build cmake .. \
cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make -DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_GLUTCONTEXT=ON
make
make install 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 If you want to build with another compiler (e.g. Clang), pass
`-DCMAKE_CXX_COMPILER=clang++` to CMake. `-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 @subsection building-tests Building and running unit tests
If you want to build also unit tests (which are not built by default), pass 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 `-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 `CMAKE_INSTALL_PREFIX` to suit your distribution filesystem hierarchy. If
everything goes well, in `build-win/` subdirectories will be the DLLs. 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/AbstractImporter.cpp
Trade/MeshData.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}) add_library(MagnumObjects OBJECT ${Magnum_SRCS})
# Files shared between main library and math unit test library # Files shared between main library and math unit test library
@ -56,20 +84,33 @@ else()
endif() endif()
install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${Magnum_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR})
# Install also configure file # Install also configure file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR})
add_subdirectory(Contexts) add_subdirectory(Contexts)
add_subdirectory(Math) add_subdirectory(Math)
add_subdirectory(MeshTools) add_subdirectory(Trade)
add_subdirectory(Physics)
add_subdirectory(Primitives) if(WITH_MESHTOOLS)
add_subdirectory(Shaders) 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) if(BUILD_TESTS)
enable_testing() enable_testing()
include_directories(${QT_INCLUDE_DIR}) include_directories(${QT_INCLUDE_DIR})
# Library with graceful assert for testing # 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) install(FILES AbstractContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
# GLUT context # GLUT context
if(NOT TARGET_GLES) if(WITH_GLUTCONTEXT)
find_package(GLUT) find_package(GLUT)
if(GLUT_FOUND) if(GLUT_FOUND)
add_library(MagnumGlutContext STATIC GlutContext.cpp) add_library(MagnumGlutContext STATIC GlutContext.cpp)
install(FILES GlutContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) install(FILES GlutContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
install(TARGETS MagnumGlutContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(TARGETS MagnumGlutContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else() 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()
endif() endif()
# SDL2 context # SDL2 context
find_package(SDL2) if(WITH_SDL2CONTEXT)
if(SDL2_FOUND) find_package(SDL2)
include_directories(${SDL2_INCLUDE_DIR}) if(SDL2_FOUND)
add_library(MagnumSdl2Context STATIC Sdl2Context.cpp) include_directories(${SDL2_INCLUDE_DIR})
install(FILES Sdl2Context.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) add_library(MagnumSdl2Context STATIC Sdl2Context.cpp)
install(TARGETS MagnumSdl2Context DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(FILES Sdl2Context.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
else() install(TARGETS MagnumSdl2Context DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
message(WARNING "SDL2 library was not found. SDL2 context library will not be generated.") else()
message(FATAL_ERROR "SDL2 library, required by Sdl2Context, was not found. Set WITH_SDL2CONTEXT to OFF to skip building it.")
endif()
endif() endif()
# X/EGL context # X/EGL context
find_package(OpenGLES2) if(WITH_EGLCONTEXT)
find_package(EGL) find_package(OpenGLES2)
find_package(X11) find_package(EGL)
if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND) find_package(X11)
add_library(MagnumEglContext STATIC EglContext.cpp) if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND)
install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) add_library(MagnumEglContext STATIC EglContext.cpp)
install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts)
else() install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
message(WARNING "OpenGL ES 2, EGL or X11 libraries were not found. EGL context library will not be generated.") 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() endif()

12
src/Math/CMakeLists.txt

@ -1,5 +1,17 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 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) add_subdirectory(Geometry)
if(BUILD_TESTS) if(BUILD_TESTS)

5
src/Math/Geometry/CMakeLists.txt

@ -1,5 +1,10 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 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) if(BUILD_TESTS)
enable_testing() enable_testing()
add_subdirectory(Test) add_subdirectory(Test)

12
src/MeshTools/CMakeLists.txt

@ -1,6 +1,17 @@
# Files shared between main library and unit test library # Files shared between main library and unit test library
set(MagnumMeshTools_SRCS set(MagnumMeshTools_SRCS
Tipsify.cpp) 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}) add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS})
# Set shared library flags for the objects, as they will be part of shared lib # 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) target_link_libraries(MagnumMeshTools Magnum)
install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumMeshTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/MeshTools)
if(BUILD_TESTS) if(BUILD_TESTS)
enable_testing() enable_testing()

14
src/Physics/CMakeLists.txt

@ -6,12 +6,26 @@ set(MagnumPhysics_SRCS
Plane.cpp Plane.cpp
ShapeGroup.cpp ShapeGroup.cpp
Sphere.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}) add_library(MagnumPhysics SHARED ${MagnumPhysics_SRCS})
target_link_libraries(MagnumPhysics Magnum) target_link_libraries(MagnumPhysics Magnum)
install(TARGETS MagnumPhysics DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(TARGETS MagnumPhysics DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumPhysics_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Physics)
if(BUILD_TESTS) if(BUILD_TESTS)
enable_testing() enable_testing()

7
src/Primitives/CMakeLists.txt

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

3
src/Shaders/CMakeLists.txt

@ -2,9 +2,12 @@ corrade_add_resource(MagnumShaders_RCS MagnumShaders PhongShader.frag PhongShade
set(MagnumShaders_SRCS set(MagnumShaders_SRCS
PhongShader.cpp PhongShader.cpp
${MagnumShaders_RCS}) ${MagnumShaders_RCS})
set(MagnumShaders_HEADERS
PhongShader.h)
add_library(MagnumShaders SHARED ${MagnumShaders_SRCS}) add_library(MagnumShaders SHARED ${MagnumShaders_SRCS})
target_link_libraries(MagnumShaders Magnum) target_link_libraries(MagnumShaders Magnum)
install(TARGETS MagnumShaders DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) 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