* fix bugs in EigenTesting.cmake: it didn't work with -DEIGEN_NO_ASSERTION_CHECKING=ON

* only try...catch if exceptions are enabled
This commit is contained in:
Benoit Jacob 2009-05-15 15:53:26 +00:00
parent 7c14e1eac4
commit 126284d08b
2 changed files with 22 additions and 9 deletions

View File

@ -233,6 +233,20 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset)
#if EIGEN_ALIGN
#ifdef EIGEN_EXCEPTIONS
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void* operator new(size_t size, const std::nothrow_t&) throw() { \
try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \
catch (...) { return 0; } \
return 0; \
}
#else
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void* operator new(size_t size, const std::nothrow_t&) { \
return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \
}
#endif
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \
void *operator new(size_t size) { \
return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \
@ -248,11 +262,7 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset)
static void *operator new(size_t size, void *ptr) { return ::operator new(size,ptr); } \
void operator delete(void * memory, void *ptr) throw() { return ::operator delete(memory,ptr); } \
/* nothrow-new (returns zero instead of std::bad_alloc) */ \
void* operator new(size_t size, const std::nothrow_t&) throw() { \
try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \
catch (...) { return 0; } \
return 0; \
} \
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void operator delete(void *ptr, const std::nothrow_t&) throw() { \
Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); \
} \

View File

@ -6,13 +6,16 @@ option(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions" OFF)
macro(ei_add_target_property target prop value)
get_target_property(previous ${target} ${prop})
# if the property wasn't previously set, ${previous} is now "previous-NOTFOUND" which cmake allows catching with plain if()
if(NOT previous)
set(previous "")
endif(NOT previous)
set_target_properties(${target} PROPERTIES ${prop} "${previous} ${value}")
endmacro(ei_add_target_property)
macro(ei_add_property prop value)
get_property(previous GLOBAL PROPERTY ${prop})
set_property(GLOBAL PROPERTY ${prop} "${previous}${value}")
set_property(GLOBAL PROPERTY ${prop} "${previous} ${value}")
endmacro(ei_add_property)
# Macro to add a test
@ -47,12 +50,12 @@ macro(ei_add_test testname)
option(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF)
if(EIGEN_DEBUG_ASSERTS)
set_target_properties(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_DEBUG_ASSERTS=1")
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1")
endif(EIGEN_DEBUG_ASSERTS)
else(NOT EIGEN_NO_ASSERTION_CHECKING)
set_target_properties(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_NO_ASSERTION_CHECKING=1")
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1")
endif(NOT EIGEN_NO_ASSERTION_CHECKING)