Browse Source

Compiling with -fvisibility=hidden.

Reusing macros MAGNUM_EXPORT and friends already used for Windows
builds. For exported classes added MAGNUM_LOCAL to private members which
are not referenced from any inline function. Added explicit
MAGNUM_EXPORT to private members which are referenced. CMake provides
its own macro <target>_EXPORTS, using that instead of
set_target_properties().
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
952f8ebb27
  1. 9
      src/CMakeLists.txt
  2. 2
      src/Camera.h
  3. 2
      src/IndexedMesh.h
  4. 2
      src/Light.h
  5. 2
      src/Math/Math.h
  6. 6
      src/Mesh.h
  7. 4
      src/MeshTools/CMakeLists.txt
  8. 1
      src/MeshTools/FlipNormals.h
  9. 3
      src/MeshTools/GenerateFlatNormals.h
  10. 28
      src/MeshTools/MeshToolsVisibility.h
  11. 2
      src/MeshTools/Tipsify.h
  12. 1
      src/Physics/AbstractShape.h
  13. 4
      src/Physics/CMakeLists.txt
  14. 28
      src/Physics/PhysicsVisibility.h
  15. 3
      src/Shaders/PhongShader.h
  16. 28
      src/Shaders/ShadersVisibility.h
  17. 2
      src/Trade/AbstractImporter.h
  18. 30
      src/Visibility.h
  19. 48
      src/utilities.h

9
src/CMakeLists.txt

@ -1,4 +1,4 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++0x")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++0x -fvisibility=hidden")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CORRADE_INCLUDE_DIR})
@ -33,10 +33,6 @@ set(Magnum_SRCS
add_library(Magnum SHARED ${Magnum_SRCS})
if(WIN32)
set_target_properties(Magnum PROPERTIES COMPILE_FLAGS -DMAGNUM_EXPORTING)
endif()
target_link_libraries(Magnum ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY} ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARY})
install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
@ -46,9 +42,6 @@ if(BUILD_TESTS)
# Library with graceful assert for testing
add_library(MagnumTestLib SHARED ${Magnum_SRCS})
if(WIN32)
set_target_properties(MagnumTestLib PROPERTIES COMPILE_FLAGS -DMAGNUM_EXPORTING)
endif()
set_target_properties(MagnumTestLib PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT)
target_link_libraries(MagnumTestLib ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY} ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARY})

2
src/Camera.h

@ -180,7 +180,7 @@ class MAGNUM_EXPORT Camera: public Object {
Math::Vector2<GLsizei> _viewport;
AspectRatioPolicy _aspectRatioPolicy;
void fixAspectRatio();
MAGNUM_LOCAL void fixAspectRatio();
};
}

2
src/IndexedMesh.h

@ -77,7 +77,7 @@ class MAGNUM_EXPORT IndexedMesh: public Mesh {
void draw();
protected:
void finalize();
MAGNUM_LOCAL void finalize();
private:
Buffer _indexBuffer;

2
src/Light.h

@ -48,7 +48,7 @@ class MAGNUM_EXPORT Light: public Object {
/**
* Recomputes light position.
*/
void clean(const Matrix4& absoluteTransformation);
MAGNUM_LOCAL void clean(const Matrix4& absoluteTransformation);
private:
Vector4 _position;

2
src/Math/Math.h

@ -17,7 +17,7 @@
#include <cstddef>
#include "utilities.h"
#include "Visibility.h"
/** @file
* @brief Math constants and utilities

6
src/Mesh.h

@ -274,11 +274,11 @@ class MAGNUM_EXPORT Mesh {
* Computes location and stride of each attribute in its buffer. After
* this function is called, no new attribute can be bound.
*/
void finalize();
MAGNUM_LOCAL void finalize();
private:
/** @brief Vertex attribute */
struct Attribute {
struct MAGNUM_LOCAL Attribute {
GLuint attribute; /**< @brief %Attribute ID */
GLint size; /**< @brief How many items of `type` are in the attribute */
Type type; /**< @brief %Attribute item type */
@ -307,7 +307,7 @@ class MAGNUM_EXPORT Mesh {
*/
std::set<GLuint> _attributes;
void bindAttribute(Buffer* buffer, GLuint attribute, GLint size, Type type);
MAGNUM_EXPORT void bindAttribute(Buffer* buffer, GLuint attribute, GLint size, Type type);
};
}

4
src/MeshTools/CMakeLists.txt

@ -6,10 +6,6 @@ set(MagnumMeshTools_SRCS
add_library(MagnumMeshTools SHARED ${MagnumMeshTools_SRCS})
if(WIN32)
set_target_properties(MagnumMeshTools PROPERTIES COMPILE_FLAGS -DMESHTOOLS_EXPORTING)
endif()
target_link_libraries(MagnumMeshTools Magnum)
install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})

1
src/MeshTools/FlipNormals.h

@ -20,6 +20,7 @@
*/
#include "Magnum.h"
#include "MeshToolsVisibility.h"
namespace Magnum { namespace MeshTools {

3
src/MeshTools/GenerateFlatNormals.h

@ -22,6 +22,7 @@
#include <tuple>
#include "Magnum.h"
#include "MeshToolsVisibility.h"
namespace Magnum { namespace MeshTools {
@ -47,7 +48,7 @@ use the same indices.
@attention Index count must be divisible by 3, otherwise zero length result
is generated.
*/
std::tuple<std::vector<unsigned int>, std::vector<Vector3>> generateFlatNormals(const std::vector<unsigned int>& indices, const std::vector<Vector4>& vertices);
std::tuple<std::vector<unsigned int>, std::vector<Vector3>> MESHTOOLS_EXPORT generateFlatNormals(const std::vector<unsigned int>& indices, const std::vector<Vector4>& vertices);
}}

28
src/MeshTools/MeshToolsVisibility.h

@ -0,0 +1,28 @@
#ifndef Magnum_MeshTools_MeshToolsVisibility_h
#define Magnum_MeshTools_MeshToolsVisibility_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
#ifdef _WIN32
#ifdef MagnumMeshTools_EXPORTS
#define MESHTOOLS_EXPORT __declspec(dllexport)
#else
#define MESHTOOLS_EXPORT __declspec(dllimport)
#endif
#else
#define MESHTOOLS_EXPORT __attribute__ ((visibility ("default")))
#endif
#endif

2
src/MeshTools/Tipsify.h

@ -22,7 +22,7 @@
#include <cstddef>
#include <vector>
#include "utilities.h"
#include "MeshToolsVisibility.h"
namespace Magnum { namespace MeshTools {

1
src/Physics/AbstractShape.h

@ -20,6 +20,7 @@
*/
#include "Magnum.h"
#include "PhysicsVisibility.h"
namespace Magnum { namespace Physics {

4
src/Physics/CMakeLists.txt

@ -10,10 +10,6 @@ set(MagnumPhysics_SRCS
add_library(MagnumPhysics SHARED ${MagnumPhysics_SRCS})
if(WIN32)
set_target_properties(MagnumPhysics PROPERTIES COMPILE_FLAGS -DPHYSICS_EXPORTING)
endif()
target_link_libraries(MagnumPhysics Magnum)
install(TARGETS MagnumPhysics DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})

28
src/Physics/PhysicsVisibility.h

@ -0,0 +1,28 @@
#ifndef Magnum_Physics_PhysicsVisibility_h
#define Magnum_Physics_PhysicsVisibility_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
#ifdef _WIN32
#ifdef MagnumPhysics_EXPORTS
#define PHYSICS_EXPORT __declspec(dllexport)
#else
#define PHYSICS_EXPORT __declspec(dllimport)
#endif
#else
#define PHYSICS_EXPORT __attribute__ ((visibility ("default")))
#endif
#endif

3
src/Shaders/PhongShader.h

@ -20,6 +20,7 @@
*/
#include "AbstractShaderProgram.h"
#include "ShadersVisibility.h"
namespace Magnum { namespace Shaders {
@ -29,7 +30,7 @@ namespace Magnum { namespace Shaders {
@requires_gl33 The shader is written in GLSL 3.3, although it should be trivial
to port it to older versions.
*/
class PhongShader: public AbstractShaderProgram {
class SHADERS_EXPORT PhongShader: public AbstractShaderProgram {
public:
typedef Attribute<0, Vector4> Vertex; /**< @brief Vertex position */
typedef Attribute<1, Vector3> Normal; /**< @brief Normal direction */

28
src/Shaders/ShadersVisibility.h

@ -0,0 +1,28 @@
#ifndef Magnum_Shaders_ShadersVisibility_h
#define Magnum_Shaders_ShadersVisibility_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
#ifdef _WIN32
#ifdef MagnumShaders_EXPORTS
#define SHADERS_EXPORT __declspec(dllexport)
#else
#define SHADERS_EXPORT __declspec(dllimport)
#endif
#else
#define SHADERS_EXPORT __attribute__ ((visibility ("default")))
#endif
#endif

2
src/Trade/AbstractImporter.h

@ -59,7 +59,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin {
};
/** @brief Constructor */
AbstractImporter(Corrade::PluginManager::AbstractPluginManager* manager = nullptr, const std::string& plugin = ""): Plugin(manager, plugin) {}
inline AbstractImporter(Corrade::PluginManager::AbstractPluginManager* manager = nullptr, const std::string& plugin = ""): Plugin(manager, plugin) {}
/**
* @brief Features supported by this importer

30
src/Visibility.h

@ -0,0 +1,30 @@
#ifndef Magnum_Visibility_h
#define Magnum_Visibility_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
#ifdef _WIN32
#ifdef Magnum_EXPORTS
#define MAGNUM_EXPORT __declspec(dllexport)
#else
#define MAGNUM_EXPORT __declspec(dllimport)
#endif
#define MAGNUM_LOCAL
#else
#define MAGNUM_EXPORT __attribute__ ((visibility ("default")))
#define MAGNUM_LOCAL __attribute__ ((visibility ("hidden")))
#endif
#endif

48
src/utilities.h

@ -1,48 +0,0 @@
#ifndef Magnum_utilities_h
#define Magnum_utilities_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
This file is part of Magnum.
Magnum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
Magnum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
/** @file
* @brief Various utilities and macros
*/
namespace Magnum {
#ifdef _WIN32
#ifdef MAGNUM_EXPORTING
#define MAGNUM_EXPORT __declspec(dllexport)
#else
#define MAGNUM_EXPORT __declspec(dllimport)
#endif
#ifdef MESHTOOLS_EXPORTING
#define MESHTOOLS_EXPORT __declspec(dllexport)
#else
#define MESHTOOLS_EXPORT __declspec(dllimport)
#endif
#ifdef PHYSICS_EXPORTING
#define PHYSICS_EXPORT __declspec(dllexport)
#else
#define PHYSICS_EXPORT __declspec(dllimport)
#endif
#else
#define MAGNUM_EXPORT
#define MESHTOOLS_EXPORT
#define PHYSICS_EXPORT
#endif
}
#endif
Loading…
Cancel
Save