Skip to content

Commit

Permalink
Merge pull request #542 from dartsim/assimp_missing_symbols
Browse files Browse the repository at this point in the history
Conditional build depending on missing symbols of Assimp package
  • Loading branch information
jslee02 committed Nov 5, 2015
2 parents 8d003b1 + 827a449 commit 7ee9bc3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
47 changes: 46 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,51 @@ endif()
find_package(ASSIMP 3.0.0 QUIET)
if(ASSIMP_FOUND)
message(STATUS "Looking for ASSIMP - ${ASSIMP_VERSION} found")

# Check for missing symbols in ASSIMP (see #451)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${ASSIMP_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ASSIMP_LIBRARIES})

check_cxx_source_compiles(
"
#include <assimp/scene.h>
int main()
{
aiScene* scene = new aiScene;
delete scene;
return 1;
}
"
ASSIMP_AISCENE_CTOR_DTOR_DEFINED)

if(NOT ASSIMP_AISCENE_CTOR_DTOR_DEFINED)
message(WARNING "Installed ASSIMP ${ASSIMP_VERSION} is missing symbols "
"for constructor or destructor of aiScene. DART will use own "
"implementation. Please use ASSIMP that fixed this issue.")
endif(NOT ASSIMP_AISCENE_CTOR_DTOR_DEFINED)

check_cxx_source_compiles(
"
#include <assimp/material.h>
int main()
{
aiMaterial* material = new aiMaterial;
delete material;
return 1;
}
"
ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED)

if(NOT ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED)
message(WARNING "Installed ASSIMP ${ASSIMP_VERSION} is missing symbols "
"for constructor or destructor of aiMaterial. DART will use own "
"implementation. Please use ASSIMP that fixed this issue.")
endif(NOT ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED)

unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)

else()
if(ASSIMP_VERSION)
message(SEND_ERROR "Looking for ASSIMP - ${ASSIMP_VERSION} found, ${PROJECT_NAME} requires 3.0.0 or greater.")
Expand Down Expand Up @@ -410,7 +455,7 @@ endif()
#===============================================================================
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/case_sensitive_filesystem
RESULT_VARIABLE FILESYSTEM_CASE_SENSITIVE_RETURN)
if (${FILESYSTEM_CASE_SENSITIVE_RETURN} EQUAL 0)
if(${FILESYSTEM_CASE_SENSITIVE_RETURN} EQUAL 0)
set(FILESYSTEM_CASE_SENSITIVE TRUE)
else()
set(FILESYSTEM_CASE_SENSITIVE FALSE)
Expand Down
4 changes: 4 additions & 0 deletions dart/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@
#define DART_ROOT_PATH "@CMAKE_SOURCE_DIR@/"
#define DART_DATA_PATH "@CMAKE_SOURCE_DIR@/data/"

// See #451
#cmakedefine ASSIMP_AISCENE_CTOR_DTOR_DEFINED 1
#cmakedefine ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED 1

#endif // #ifndef DART_CONFIG_H_
17 changes: 9 additions & 8 deletions dart/dynamics/MeshShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@
#include <assimp/postprocess.h>
#include <assimp/cimport.h>

#include "dart/config.h"
#include "dart/renderer/RenderInterface.h"
#include "dart/common/Console.h"
#include "dart/dynamics/AssimpInputResourceAdaptor.h"
#include "dart/common/LocalResourceRetriever.h"
#include "dart/common/Uri.h"

// We define our own constructor for aiScene, because it seems to be missing
// from the standard assimp library
#ifndef ASSIMP_AISCENE_CTOR_DTOR_DEFINED
// We define our own constructor and destructor for aiScene, because it seems to
// be missing from the standard assimp library (see #451)
aiScene::aiScene()
: mFlags(0),
mRootNode(nullptr),
Expand All @@ -70,8 +72,6 @@ aiScene::aiScene()

}

// We define our own destructor for aiScene, because it seems to be missing
// from the standard assimp library
aiScene::~aiScene()
{
delete mRootNode;
Expand Down Expand Up @@ -106,9 +106,11 @@ aiScene::~aiScene()
delete mCameras[a];
delete[] mCameras;
}
#endif // #ifndef ASSIMP_AISCENE_CTOR_DTOR_DEFINED

// We define our own constructor for aiMaterial, because it seems to be missing
// from the standard assimp library
// We define our own constructor and destructor for aiMaterial, because it seems
// to be missing from the standard assimp library (see #451)
#ifndef ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED
aiMaterial::aiMaterial()
{
mNumProperties = 0;
Expand All @@ -118,15 +120,14 @@ aiMaterial::aiMaterial()
mProperties[i] = nullptr;
}

// We define our own destructor for aiMaterial, because it seems to be missing
// from the standard assimp library
aiMaterial::~aiMaterial()
{
for(size_t i=0; i<mNumProperties; ++i)
delete mProperties[i];

delete[] mProperties;
}
#endif // #ifndef ASSIMP_AIMATERIAL_CTOR_DTOR_DEFINED

namespace dart {
namespace dynamics {
Expand Down
2 changes: 0 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Build-Depends: debhelper (>= 9),
libeigen3-dev,
libfcl-dev (>= 0.2.7),
libassimp-dev (>= 3),
libassimp-dev (<< 3.0~dfsg-4),
freeglut3-dev,
libxi-dev,
libxmu-dev,
Expand All @@ -32,7 +31,6 @@ Depends: ${misc:Depends},
libdart-core5.1 (= ${binary:Version}),
libeigen3-dev,
libassimp-dev (>= 3),
libassimp-dev (<< 3.0~dfsg-4),
libfcl-dev,
libboost-dev (>= 1.54.0.1ubuntu1)
Description: Dynamic Animation and Robotics Toolkit, core development files
Expand Down

0 comments on commit 7ee9bc3

Please sign in to comment.