summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt86
-rw-r--r--Changelog-Trunk.txt2
2 files changed, 81 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f0f547fb..660df46d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -198,7 +198,7 @@ endif()
#
# Test typecast to union
#
-message( STATUS "Check if we can typecast to union" )
+message( STATUS "Check for typecast to union" )
set( SOURCECODE
"typedef union Foonion{\n"
" int i;\n"
@@ -207,15 +207,15 @@ set( SOURCECODE
"} Foonion;\n"
"int get_i(Foonion onion){ return onion.i; }\n"
"int main(int argc, char** argv){\n"
- "int i = 0;\n"
- "return get_i(((Foonion)(int)i));\n"
+ " int i = 0;\n"
+ " return get_i(((Foonion)(int)i));\n"
"}\n"
)
CHECK_C_SOURCE_COMPILES( "${SOURCECODE}" HAVE_TYPECAST_TO_UNION )
if( HAVE_TYPECAST_TO_UNION )
- message( STATUS "Check typecast to union - yes" )
+ message( STATUS "Check for typecast to union - yes" )
else()
- message( STATUS "Check typecast to union - no" )
+ message( STATUS "Check for typecast to union - no" )
set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDB_MANUAL_CAST_TO_UNION" )
endif()
@@ -236,8 +236,8 @@ set( SOURCECODE
"#include <time.h>\n"
"#include <unistd.h>\n"
"int main(int argc, char** argv){\n"
- "struct timespec tval;\n"
- "return clock_gettime(CLOCK_MONOTONIC, &tval);\n"
+ " struct timespec tval;\n"
+ " return clock_gettime(CLOCK_MONOTONIC, &tval);\n"
"}\n"
)
find_library( RT_LIBRARY rt )# (optional, rt on Debian)
@@ -285,6 +285,78 @@ if( ENABLE_RDTSC )
endif()
+#
+# Enable builtin memory manager (default=default)
+#
+set( MEMMGR_OPTIONS "default;yes;no" )
+set( ENABLE_MEMMGR "default" CACHE STRING "enable the builtin memory manager? (${MEMMGR_OPTIONS})" )
+set_property( CACHE ENABLE_MEMMGR PROPERTY STRINGS ${MEMMGR_OPTIONS} )
+if( ENABLE_MEMMGR STREQUAL "default" )
+ # use source code default
+elseif( ENABLE_MEMMGR STREQUAL "yes" )
+ set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DUSE_MEMMGR" )
+ message( STATUS "Enabled builtin memory manager" )
+elseif( ENABLE_MEMMGR STREQUAL "no" )
+ set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DNO_MEMMGR" )
+ message( STATUS "Disabled builtin memory manager" )
+else()
+ message( FATAL_ERROR "invalid option ENABLE_MEMMGR=${ENABLE_MEMMGR} (valid options: ${MEMMGR_OPTIONS})" )
+endif()
+
+
+#
+# Enable memory library (default=system)
+#
+set( MEMORY_OPTIONS "system;memwatch;dmalloc;gcollect" )
+set( ENABLE_MEMORY "system" CACHE STRING "enable memory library: ${MEMORY_OPTIONS} (default=system)" )
+set_property( CACHE ENABLE_MEMORY PROPERTY STRINGS ${MEMORY_OPTIONS} )
+if( ENABLE_MEMORY STREQUAL "system" )
+ # use system functions
+
+elseif( ENABLE_MEMORY STREQUAL "memwatch" )
+ CHECK_INCLUDE_FILE( memwatch.h HAVE_MEMWATCH_H )
+ find_library( MEMWATCH_LIBRARY memwatch )
+ mark_as_advanced( MEMWATCH_LIBRARY )
+ if( HAVE_MEMWATCH_H AND MEMWATCH_LIBRARY )
+ message( STATUS "Adding global library: ${MEMWATCH_LIBRARY}" )
+ set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${MEMWATCH_LIBRARY} )
+ set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DMEMWATCH" )
+ message( STATUS "Enabled the memory library memwatch" )
+ else()
+ message( FATAL_ERROR "Failed to enable the memory library memwatch" )
+ endif()
+
+elseif( ENABLE_MEMORY STREQUAL "dmalloc" )
+ CHECK_INCLUDE_FILE( dmalloc.h HAVE_DMALLOC_H )
+ find_library( DMALLOC_LIBRARY dmalloc )
+ mark_as_advanced( DMALLOC_LIBRARY )
+ if( HAVE_DMALLOC_H AND DMALLOC_LIBRARY )
+ message( STATUS "Adding global library: ${DMALLOC_LIBRARY}" )
+ set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${DMALLOC_LIBRARY} )
+ set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DDMALLOC -DDMALLOC_FUNC_CHECK" )
+ message( STATUS "Enabled the memory library dmalloc" )
+ else()
+ message( FATAL_ERROR "Failed to enable the memory library dmalloc" )
+ endif()
+
+elseif( ENABLE_MEMORY STREQUAL "gcollect" )
+ CHECK_INCLUDE_FILE( gc.h HAVE_GC_H )
+ find_library( GC_LIBRARY gc )
+ mark_as_advanced( GC_LIBRARY )
+ if( HAVE_GC_H AND GC_LIBRARY )
+ message( STATUS "Adding global library: ${GC_LIBRARY}" )
+ set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${GC_LIBRARY} )
+ set_property( CACHE GLOBAL_DEFINITIONS PROPERTY VALUE "${GLOBAL_DEFINITIONS} -DGCOLLECT" )
+ message( STATUS "Enabled the memory library gcollect" )
+ else()
+ message( FATAL_ERROR "Failed to enable the memory library gcollect" )
+ endif()
+
+else()
+ message( FATAL_ERROR "invalid option ENABLE_MEMORY=${ENABLE_MEMORY} (valid options: ${MEMORY_OPTIONS})" )
+endif()
+
+
#####################################################################
# package stuff
#
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index c39b7cf93..011e2a136 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -8,6 +8,8 @@ Date Added
* Fixed DMALLOC usage. (missing options on CYGWIN and verify memory)
* Renamed malloc_verify to malloc_verify_ptr to avoid conflict with DMALLOC.
* Changed itemtype from inline to static inline to avoid error with the SunOS compiler.
+ * CMake: added option ENABLE_MEMMGR. (builtin memory manager)
+ * CMake: added option ENABLE_MEMORY. (memory library)
2011/07/15
* Changed the warning message of when setrlimit fails to be more explicit. [FlavioJS]
* CMake: added tests for big endian, typecast to union and monotonic clock.