diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31565244c..587bd8a3d 100644 --- a/src/CMakeLists.txt +++ b/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}) diff --git a/src/Camera.h b/src/Camera.h index bcdd39bdc..e3ff67ff8 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -180,7 +180,7 @@ class MAGNUM_EXPORT Camera: public Object { Math::Vector2 _viewport; AspectRatioPolicy _aspectRatioPolicy; - void fixAspectRatio(); + MAGNUM_LOCAL void fixAspectRatio(); }; } diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h index a55422a10..bac05586b 100644 --- a/src/IndexedMesh.h +++ b/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; diff --git a/src/Light.h b/src/Light.h index ae1a71b60..99bc0b564 100644 --- a/src/Light.h +++ b/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; diff --git a/src/Math/Math.h b/src/Math/Math.h index d1b7e830a..adae76dc9 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -17,7 +17,7 @@ #include -#include "utilities.h" +#include "Visibility.h" /** @file * @brief Math constants and utilities diff --git a/src/Mesh.h b/src/Mesh.h index 54f46b55c..c61079c3f 100644 --- a/src/Mesh.h +++ b/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 _attributes; - void bindAttribute(Buffer* buffer, GLuint attribute, GLint size, Type type); + MAGNUM_EXPORT void bindAttribute(Buffer* buffer, GLuint attribute, GLint size, Type type); }; } diff --git a/src/MeshTools/CMakeLists.txt b/src/MeshTools/CMakeLists.txt index c2295ab07..a8e99d968 100644 --- a/src/MeshTools/CMakeLists.txt +++ b/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}) diff --git a/src/MeshTools/FlipNormals.h b/src/MeshTools/FlipNormals.h index c4fb6d6ea..39ad881fa 100644 --- a/src/MeshTools/FlipNormals.h +++ b/src/MeshTools/FlipNormals.h @@ -20,6 +20,7 @@ */ #include "Magnum.h" +#include "MeshToolsVisibility.h" namespace Magnum { namespace MeshTools { diff --git a/src/MeshTools/GenerateFlatNormals.h b/src/MeshTools/GenerateFlatNormals.h index 2e113c640..92be1db28 100644 --- a/src/MeshTools/GenerateFlatNormals.h +++ b/src/MeshTools/GenerateFlatNormals.h @@ -22,6 +22,7 @@ #include #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> generateFlatNormals(const std::vector& indices, const std::vector& vertices); +std::tuple, std::vector> MESHTOOLS_EXPORT generateFlatNormals(const std::vector& indices, const std::vector& vertices); }} diff --git a/src/MeshTools/MeshToolsVisibility.h b/src/MeshTools/MeshToolsVisibility.h new file mode 100644 index 000000000..9d0f795be --- /dev/null +++ b/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š + + 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 diff --git a/src/MeshTools/Tipsify.h b/src/MeshTools/Tipsify.h index d387f0e2b..1b0077cc9 100644 --- a/src/MeshTools/Tipsify.h +++ b/src/MeshTools/Tipsify.h @@ -22,7 +22,7 @@ #include #include -#include "utilities.h" +#include "MeshToolsVisibility.h" namespace Magnum { namespace MeshTools { diff --git a/src/Physics/AbstractShape.h b/src/Physics/AbstractShape.h index 21199173e..03d7dc703 100644 --- a/src/Physics/AbstractShape.h +++ b/src/Physics/AbstractShape.h @@ -20,6 +20,7 @@ */ #include "Magnum.h" +#include "PhysicsVisibility.h" namespace Magnum { namespace Physics { diff --git a/src/Physics/CMakeLists.txt b/src/Physics/CMakeLists.txt index b9ec1a570..0f3833d7a 100644 --- a/src/Physics/CMakeLists.txt +++ b/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}) diff --git a/src/Physics/PhysicsVisibility.h b/src/Physics/PhysicsVisibility.h new file mode 100644 index 000000000..2add2c9f3 --- /dev/null +++ b/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š + + 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 diff --git a/src/Shaders/PhongShader.h b/src/Shaders/PhongShader.h index dac986dfc..dad97184e 100644 --- a/src/Shaders/PhongShader.h +++ b/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 */ diff --git a/src/Shaders/ShadersVisibility.h b/src/Shaders/ShadersVisibility.h new file mode 100644 index 000000000..cda87d06b --- /dev/null +++ b/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š + + 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 diff --git a/src/Trade/AbstractImporter.h b/src/Trade/AbstractImporter.h index dea239f6a..96612482d 100644 --- a/src/Trade/AbstractImporter.h +++ b/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 diff --git a/src/Visibility.h b/src/Visibility.h new file mode 100644 index 000000000..a10d6b1c8 --- /dev/null +++ b/src/Visibility.h @@ -0,0 +1,30 @@ +#ifndef Magnum_Visibility_h +#define Magnum_Visibility_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + 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 diff --git a/src/utilities.h b/src/utilities.h deleted file mode 100644 index 41955cf98..000000000 --- a/src/utilities.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef Magnum_utilities_h -#define Magnum_utilities_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - 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