浏览代码

Merge pull request #832 from assimp/no-boost

Removed usage of Boost static assert.
Kim Kulling 9 年之前
父节点
当前提交
49d60dc856

+ 4 - 1
CMakeLists.txt

@@ -20,6 +20,7 @@ set(ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used f
 
 # Needed for openddl_parser config, no use of c++11 at this moment
 add_definitions( -DOPENDDL_NO_USE_CPP11 )
+set_property( GLOBAL PROPERTY CXX_STANDARD 11 )
 
 # Get the current working branch
 execute_process(
@@ -69,10 +70,12 @@ if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
   endif()
   # hide all not-exported symbols
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall" )
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -std=c++0x" )
 elseif(MSVC)
   # enable multi-core compilation with MSVC
   add_compile_options(/MP)
+elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" )
 endif()
 
 INCLUDE (FindPkgConfig)

+ 5 - 6
code/AssbinExporter.cpp

@@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "../include/assimp/Exporter.hpp"
 #include "ProcessHelper.h"
 #include "Exceptional.h"
-#include <boost/static_assert.hpp>
 
 #ifdef ASSIMP_BUILD_NO_OWN_ZLIB
 #   include <zlib.h>
@@ -103,7 +102,7 @@ inline size_t Write<unsigned int>(IOStream * stream, const unsigned int& w)
 template <>
 inline size_t Write<uint16_t>(IOStream * stream, const uint16_t& w)
 {
-    BOOST_STATIC_ASSERT(sizeof(uint16_t)==2);
+    static_assert(sizeof(uint16_t)==2, "sizeof(uint16_t)==2");
     stream->Write(&w,2,1);
     return 2;
 }
@@ -113,7 +112,7 @@ inline size_t Write<uint16_t>(IOStream * stream, const uint16_t& w)
 template <>
 inline size_t Write<float>(IOStream * stream, const float& f)
 {
-    BOOST_STATIC_ASSERT(sizeof(float)==4);
+    static_assert(sizeof(float)==4, "sizeof(float)==4");
     stream->Write(&f,4,1);
     return 4;
 }
@@ -123,7 +122,7 @@ inline size_t Write<float>(IOStream * stream, const float& f)
 template <>
 inline size_t Write<double>(IOStream * stream, const double& f)
 {
-    BOOST_STATIC_ASSERT(sizeof(double)==8);
+    static_assert(sizeof(double)==8, "sizeof(double)==8");
     stream->Write(&f,8,1);
     return 8;
 }
@@ -472,7 +471,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size)
                         uint32_t tmp = f.mNumIndices;
                         hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
                         for (unsigned int i = 0; i < f.mNumIndices; ++i) {
-                            BOOST_STATIC_ASSERT(AI_MAX_VERTICES <= 0xffffffff);
+                            static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff");
                             tmp = static_cast<uint32_t>( f.mIndices[i] );
                             hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
                         }
@@ -486,7 +485,7 @@ inline size_t WriteArray(IOStream * stream, const T* in, unsigned int size)
                 for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
                     const aiFace& f = mesh->mFaces[i];
 
-                    BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
+                    static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
                     Write<uint16_t>(&chunk,f.mNumIndices);
 
                     for (unsigned int a = 0; a < f.mNumIndices;++a) {

+ 1 - 2
code/AssbinLoader.cpp

@@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "../include/assimp/mesh.h"
 #include "../include/assimp/anim.h"
 #include "../include/assimp/scene.h"
-#include <boost/static_assert.hpp>
 
 #ifdef ASSIMP_BUILD_NO_OWN_ZLIB
 #   include <zlib.h>
@@ -351,7 +350,7 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
         for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
             aiFace& f = mesh->mFaces[i];
 
-            BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
+            static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
             f.mNumIndices = Read<uint16_t>(stream);
             f.mIndices = new unsigned int[f.mNumIndices];
 

+ 3 - 3
code/DefaultIOStream.cpp

@@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "../include/assimp/ai_assert.h"
 #include "DefaultIOStream.h"
-#include <boost/static_assert.hpp>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -86,8 +85,9 @@ aiReturn DefaultIOStream::Seek(size_t pOffset,
     }
 
     // Just to check whether our enum maps one to one with the CRT constants
-    BOOST_STATIC_ASSERT(aiOrigin_CUR == SEEK_CUR &&
-        aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET);
+    static_assert(aiOrigin_CUR == SEEK_CUR &&
+        aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET, "aiOrigin_CUR == SEEK_CUR && \
+        aiOrigin_END == SEEK_END && aiOrigin_SET == SEEK_SET");
 
     // do the seek
     return (0 == ::fseek(mFile, (long)pOffset,(int)pOrigin) ? AI_SUCCESS : AI_FAILURE);

+ 3 - 4
code/JoinVerticesProcess.cpp

@@ -51,7 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "Vertex.h"
 #include "TinyFormatter.h"
 #include <stdio.h>
-#include <boost/static_assert.hpp>
 
 using namespace Assimp;
 // ------------------------------------------------------------------------------------------------
@@ -117,8 +116,8 @@ void JoinVerticesProcess::Execute( aiScene* pScene)
 // Unites identical vertices in the given mesh
 int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
 {
-    BOOST_STATIC_ASSERT( AI_MAX_NUMBER_OF_COLOR_SETS    == 8);
-    BOOST_STATIC_ASSERT( AI_MAX_NUMBER_OF_TEXTURECOORDS == 8);
+    static_assert( AI_MAX_NUMBER_OF_COLOR_SETS    == 8, "AI_MAX_NUMBER_OF_COLOR_SETS    == 8");
+	static_assert( AI_MAX_NUMBER_OF_TEXTURECOORDS == 8, "AI_MAX_NUMBER_OF_TEXTURECOORDS == 8");
 
     // Return early if we don't have any positions
     if (!pMesh->HasPositions() || !pMesh->HasFaces()) {
@@ -134,7 +133,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
     //  whether a new vertex was created for the index (true) or if it was replaced by an existing
     //  unique vertex (false). This saves an additional std::vector<bool> and greatly enhances
     //  branching performance.
-    BOOST_STATIC_ASSERT(AI_MAX_VERTICES == 0x7fffffff);
+    static_assert(AI_MAX_VERTICES == 0x7fffffff, "AI_MAX_VERTICES == 0x7fffffff");
     std::vector<unsigned int> replaceIndex( pMesh->mNumVertices, 0xffffffff);
 
     // A little helper to find locally close vertices faster.

+ 1 - 2
code/LWOMaterial.cpp

@@ -48,7 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // internal headers
 #include "LWOLoader.h"
 #include "ByteSwapper.h"
-#include <boost/static_assert.hpp>
 
 
 using namespace Assimp;
@@ -160,7 +159,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
                 trafo.mScaling.x = (*it).wrapAmountW;
                 trafo.mScaling.y = (*it).wrapAmountH;
 
-                BOOST_STATIC_ASSERT(sizeof(aiUVTransform)/sizeof(float) == 5);
+                static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5");
                 pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur));
             }
             DefaultLogger::get()->debug("LWO2: Setting up non-UV mapping");

+ 1 - 2
code/STEPFile.h

@@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define INCLUDED_AI_STEPFILE_H
 
 #include <boost/noncopyable.hpp>
-#include <boost/static_assert.hpp>
 #include <boost/foreach.hpp>
 #include <bitset>
 #include <memory>
@@ -722,7 +721,7 @@ namespace STEP {
 
 
         ListOf() {
-            BOOST_STATIC_ASSERT(min_cnt <= max_cnt || !max_cnt);
+            static_assert(min_cnt <= max_cnt || !max_cnt, "min_cnt <= max_cnt || !max_cnt");
         }
 
     };

+ 2 - 3
code/SpatialSort.cpp

@@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /** @file Implementation of the helper class to quickly find vertices close to a given position */
 
 #include "SpatialSort.h"
-#include <boost/static_assert.hpp>
 #include "../include/assimp/ai_assert.h"
 
 using namespace Assimp;
@@ -192,14 +191,14 @@ namespace {
         // If this assertion fails, signed int is not big enough to store a float on your platform.
         //  Please correct the declaration of BinFloat a few lines above - but do it in a portable,
         //  #ifdef'd manner!
-        BOOST_STATIC_ASSERT( sizeof(BinFloat) >= sizeof(float));
+        static_assert( sizeof(BinFloat) >= sizeof(float), "sizeof(BinFloat) >= sizeof(float)");
 
         #if defined( _MSC_VER)
             // If this assertion fails, Visual C++ has finally moved to ILP64. This means that this
             //  code has just become legacy code! Find out the current value of _MSC_VER and modify
             //  the #if above so it evaluates false on the current and all upcoming VC versions (or
             //  on the current platform, if LP64 or LLP64 are still used on other platforms).
-            BOOST_STATIC_ASSERT( sizeof(BinFloat) == sizeof(float));
+            static_assert( sizeof(BinFloat) == sizeof(float), "sizeof(BinFloat) == sizeof(float)");
 
             // This works best on Visual C++, but other compilers have their problems with it.
             const BinFloat binValue = reinterpret_cast<BinFloat const &>(pValue);

+ 4 - 5
tools/assimp_cmd/WriteDumb.cpp

@@ -58,7 +58,6 @@ const char* AICMD_MSG_DUMP_HELP =
 ;
 
 #include "../../code/assbin_chunks.h"
-#include <boost/static_assert.hpp>
 
 FILE* out = NULL;
 bool shortened = false;
@@ -151,7 +150,7 @@ inline uint32_t Write<uint16_t>(const uint16_t& w)
 template <>
 inline uint32_t Write<float>(const float& f)
 {
-	BOOST_STATIC_ASSERT(sizeof(float)==4);
+	static_assert(sizeof(float)==4, "sizeof(float)==4");
 	fwrite(&f,4,1,out);
 	return 4;
 }
@@ -161,7 +160,7 @@ inline uint32_t Write<float>(const float& f)
 template <>
 inline uint32_t Write<double>(const double& f)
 {
-	BOOST_STATIC_ASSERT(sizeof(double)==8);
+	static_assert(sizeof(double)==8, "sizeof(double)==8");
 	fwrite(&f,8,1,out);
 	return 8;
 }
@@ -424,7 +423,7 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh)
 				uint32_t tmp = f.mNumIndices;
 				hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
 				for (unsigned int i = 0; i < f.mNumIndices; ++i) {
-					BOOST_STATIC_ASSERT(AI_MAX_VERTICES <= 0xffffffff);
+					static_assert(AI_MAX_VERTICES <= 0xffffffff, "AI_MAX_VERTICES <= 0xffffffff");
 					tmp = static_cast<uint32_t>( f.mIndices[i] );
 					hash = SuperFastHash(reinterpret_cast<const char*>(&tmp),sizeof tmp,hash);
 				}
@@ -438,7 +437,7 @@ uint32_t WriteBinaryMesh(const aiMesh* mesh)
 		for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
 			const aiFace& f = mesh->mFaces[i];
 
-			BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff);
+			static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
 			len += Write<uint16_t>(f.mNumIndices);
 
 			for (unsigned int a = 0; a < f.mNumIndices;++a) {