From 65c63d0a6c3927e0f123f6ec24d5516739fd53b3 Mon Sep 17 00:00:00 2001 From: Alan Wright Date: Thu, 12 Sep 2013 10:34:00 +0100 Subject: [PATCH] Turn off custom allocator by default. closes #40 --- CMakeLists.txt | 25 ++++++++++++++----------- include/Config.h.cmake | 2 +- src/core/CMakeLists.txt | 12 ++++++++---- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec89210..ab1f10d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,9 @@ ENDIF(NOT CMAKE_BUILD_TYPE) OPTION(ENABLE_PACKAGING "create build scripts for creating lucene++ packages" OFF) +OPTION(ENABLE_CUSTOM_ALLOCATOR + "use custom memory allocator" + OFF) OPTION(ENABLE_NEDMALLOC "use nedmalloc for memory allocations" OFF) @@ -75,18 +78,18 @@ OPTION(ENABLE_CYCLIC_CHECK #install path options SET(LIB_DESTINATION "lib" CACHE STRING "Define lib output directory name") +IF ( ENABLE_CUSTOM_ALLOCATOR ) + SET(DEFINE_USE_CUSTOM_ALLOCATOR "define") +ELSE ( ENABLE_CUSTOM_ALLOCATOR ) + SET(DEFINE_USE_CUSTOM_ALLOCATOR "undef") +ENDIF ( ENABLE_CUSTOM_ALLOCATOR ) + IF ( ENABLE_NEDMALLOC ) SET(DEFINE_USE_NEDMALLOC "define") ELSE ( ENABLE_NEDMALLOC ) SET(DEFINE_USE_NEDMALLOC "undef") ENDIF ( ENABLE_NEDMALLOC ) -IF ( ENABLE_STANDARD_ALLOCATOR ) - SET(DEFINE_USE_ALLOCATOR "undef") -ELSE ( ENABLE_STANDARD_ALLOCATOR ) - SET(DEFINE_USE_ALLOCATOR "define") -ENDIF ( ENABLE_STANDARD_ALLOCATOR ) - IF ( ENABLE_CYCLIC_CHECK ) SET(DEFINE_USE_CYCLIC_CHECK "define") ELSE ( ENABLE_CYCLIC_CHECK ) @@ -116,11 +119,11 @@ IF(CYGWIN) ADD_DEFINITIONS(-D__LARGE64_FILES) ENDIF(CYGWIN) -#set ansi mode +#set ansi mode SET(ENABLE_ANSI_MODE OFF) IF(CMAKE_COMPILER_IS_GNUCXX) SET(ENABLE_ANSI_MODE ON) - + #exceptions: IF(MINGW OR CYGWIN) SET(ENABLE_ANSI_MODE OFF) @@ -130,20 +133,20 @@ IF ( CMAKE_COMPILER_IS_GNUCC ) IF( ENABLE_ANSI_MODE ) SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi") ENDIF ( ENABLE_ANSI_MODE ) -ENDIF(CMAKE_COMPILER_IS_GNUCC) +ENDIF(CMAKE_COMPILER_IS_GNUCC) #################################### #find boost #################################### SET(Boost_USE_STATIC_LIBS ${LUCENE_USE_STATIC_BOOST_LIBS}) SET(Boost_USE_MULTITHREADED ON) -#Boost 1.38 required for bug fixes in basic_streambuf. +#Boost 1.38 required for bug fixes in basic_streambuf. #The following line fails in earlier builds, so if altered, may allow older versions of boost: #boost::gregorian::date date = parser.parse_date(paddedDate.c_str(), dateFormat->c_str(), svp); find_package( Boost 1.38.0 COMPONENTS date_time filesystem iostreams regex system thread unit_test_framework REQUIRED) IF (Boost_FOUND) MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}") - SET(LUCENE_BOOST_LIBS + SET(LUCENE_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_RELEASE} ${Boost_IOSTREAMS_LIBRARY_RELEASE} ${Boost_REGEX_LIBRARY_RELEASE} diff --git a/include/Config.h.cmake b/include/Config.h.cmake index ac83b77..13f6460 100644 --- a/include/Config.h.cmake +++ b/include/Config.h.cmake @@ -78,7 +78,7 @@ #@DEFINE_USE_CYCLIC_CHECK@ LPP_USE_CYCLIC_CHECK // Define to use custom allocator (useful in Windows builds and when using nedmalloc) -#@DEFINE_USE_ALLOCATOR@ LPP_USE_ALLOCATOR +#@DEFINE_USE_CUSTOM_ALLOCATOR@ LPP_USE_ALLOCATOR // Define to use nedmalloc memory allocator #@DEFINE_USE_NEDMALLOC@ LPP_USE_NEDMALLOC diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a77c12f..ce91ae9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -20,7 +20,11 @@ file(GLOB_RECURSE HEADERS ${lucene++-base_SOURCE_DIR}/include/*.h file(GLOB_RECURSE lucene_c_sources ${lucene++-lib_SOURCE_DIR}/util/*.c) - + +IF ( ENABLE_CUSTOM_ALLOCATOR ) + ADD_DEFINITIONS(-DLPP_USE_ALLOCATOR) +ENDIF() + IF ( ENABLE_NEDMALLOC ) ADD_DEFINITIONS(-DLPP_USE_NEDMALLOC) ENDIF() @@ -51,12 +55,12 @@ SET_TARGET_PROPERTIES(lucene++ PROPERTIES SOVERSION ${LUCENE++_SOVERSION} COMPILE_FLAGS -DLPP_HAVE_DLL ) -TARGET_LINK_LIBRARIES(lucene++ - lucene++-c +TARGET_LINK_LIBRARIES(lucene++ + lucene++-c ${CMAKE_THREAD_LIBS_INIT} ${LUCENE_BOOST_LIBS} ) install(TARGETS lucene++ - DESTINATION ${LIB_DESTINATION} + DESTINATION ${LIB_DESTINATION} COMPONENT runtime) ################################# -- 1.8.5.2