290 lines
9.0 KiB
CMake
290 lines
9.0 KiB
CMake
|
#
|
||
|
# CMakeLists.txt for lmdb
|
||
|
#
|
||
|
|
||
|
PROJECT(lmdb)
|
||
|
|
||
|
cmake_minimum_required(VERSION 2.4)
|
||
|
|
||
|
include(CTest)
|
||
|
enable_testing()
|
||
|
#
|
||
|
# cmake2.6: backward compatibility to cmake 2.4
|
||
|
#
|
||
|
if(COMMAND cmake_policy)
|
||
|
cmake_policy(SET CMP0003 OLD)
|
||
|
endif(COMMAND cmake_policy)
|
||
|
|
||
|
if(COMMAND cmake_policy)
|
||
|
cmake_policy(SET CMP0005 OLD)
|
||
|
endif(COMMAND cmake_policy)
|
||
|
|
||
|
INCLUDE (CheckIncludeFiles)
|
||
|
INCLUDE (CheckFunctionExists)
|
||
|
|
||
|
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
||
|
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||
|
|
||
|
INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
|
||
|
SET(VERSION "${LMDB_MAJOR}.${LMDB_MINOR}.${LMDB_PATCH}")
|
||
|
MESSAGE(STATUS "Version ${VERSION}")
|
||
|
SET(PACKAGE_VERSION \"${LMDB_MAJOR}.${LMDB_MINOR}\")
|
||
|
MESSAGE(STATUS "Package Version ${PACKAGE_VERSION}")
|
||
|
# build timestamp
|
||
|
EXECUTE_PROCESS(COMMAND "/bin/date" "+%Y%m%d%H%M" OUTPUT_VARIABLE BUILD_DATE)
|
||
|
STRING(REPLACE "\n" "" PACKAGE_BUILDTS "${BUILD_DATE}")
|
||
|
MESSAGE(STATUS "Package build timestamp ${PACKAGE_BUILDTS}")
|
||
|
|
||
|
# Package architecture
|
||
|
IF ( NOT DEFINED PACKAGE_ARCHITECTURE )
|
||
|
EXECUTE_PROCESS(COMMAND "/bin/uname" "-m" OUTPUT_VARIABLE UNAME_M)
|
||
|
# strip trailing newline
|
||
|
STRING(REPLACE "\n" "" PACKAGE_ARCHITECTURE ${UNAME_M})
|
||
|
ENDIF ( NOT DEFINED PACKAGE_ARCHITECTURE )
|
||
|
MESSAGE(STATUS "Building for ${PACKAGE_ARCHITECTURE}" )
|
||
|
|
||
|
|
||
|
# Library path (lib / lib64 )
|
||
|
|
||
|
IF ( DEFINED LIB )
|
||
|
SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}" )
|
||
|
ELSE ( DEFINED LIB )
|
||
|
IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||
|
SET( LIB_SUFFIX "64" )
|
||
|
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||
|
SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
|
||
|
ENDIF ( DEFINED LIB )
|
||
|
MESSAGE(STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}" )
|
||
|
SET( BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" )
|
||
|
SET( INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" )
|
||
|
IF( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
|
||
|
SET( SYSCONFDIR "/etc" )
|
||
|
ELSE( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
|
||
|
SET( SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc" )
|
||
|
ENDIF( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
|
||
|
|
||
|
|
||
|
#/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||
|
CHECK_INCLUDE_FILES( "sys/time.h" TIME_WITH_SYS_TIME )
|
||
|
IF(NOT TIME_WITH_SYS_TIME)
|
||
|
SET(TIME_WITH_SYS_TIME 0)
|
||
|
ENDIF(NOT TIME_WITH_SYS_TIME)
|
||
|
|
||
|
#/* Define ssize_t to int' if <sys/types.h> does not define. */
|
||
|
SET(SSIZE_T_MISSING 0)
|
||
|
|
||
|
CHECK_FUNCTION_EXISTS( "alloca" HAVE_ALLOCA )
|
||
|
IF (NOT HAVE_ALLOCA)
|
||
|
SET(HAVE_ALLOCA 0)
|
||
|
SET(C_ALLOCA 0)
|
||
|
CHECK_INCLUDE_FILES( "alloca.h" HAVE_ALLOCA_H )
|
||
|
ENDIF (NOT HAVE_ALLOCA)
|
||
|
|
||
|
find_package(Threads REQUIRED)
|
||
|
|
||
|
|
||
|
SET (FUNCS_TO_TEST "bcopy" "crypt" "daemon" "fnmatch" "getaddrinfo" "getnameinfo" "getpid" "gettimeofday" "gmtime_r" "inet_aton" "inet_ntop" "inet_pton" "sleep" "srandom" "strsep" "strtok_r" "syslog" "timegm" "memmove" "unlink" "va_copy" )
|
||
|
FOREACH( FUNC ${FUNCS_TO_TEST})
|
||
|
STRING(TOUPPER ${FUNC} UPNAME)
|
||
|
SET(HAVENAME "HAVE_${UPNAME}")
|
||
|
CHECK_FUNCTION_EXISTS( "${FUNC}" HAVE_FUNC )
|
||
|
IF(HAVE_FUNC)
|
||
|
SET(${HAVENAME} 1)
|
||
|
ELSE(HAVE_FUNC)
|
||
|
SET(${HAVENAME} 0)
|
||
|
ENDIF(HAVE_FUNC)
|
||
|
ENDFOREACH( FUNC ${FUNCS_TO_TEST})
|
||
|
|
||
|
|
||
|
# types
|
||
|
|
||
|
INCLUDE(CheckTypeSize)
|
||
|
|
||
|
#
|
||
|
#/* Define to 1 if you have the ANSI C header files. */
|
||
|
# STDC_HEADERS
|
||
|
SET(STDC_HEADERS 1)
|
||
|
|
||
|
####################################################################
|
||
|
# CONFIGURATION #
|
||
|
####################################################################
|
||
|
|
||
|
ADD_DEFINITIONS( -DHAVE_CONFIG_H )
|
||
|
|
||
|
SET(PACKAGE "lmdb")
|
||
|
SET(PACKAGE_BUGREPORT "\"http://symas.com/mdb\"")
|
||
|
SET(PACKAGE_NAME "\"${PACKAGE}\"")
|
||
|
SET(PACKAGE_STRING "\"LMDB is a tiny database with some great capabilities\"")
|
||
|
SET(PACKAGE_TARNAME "\"${PACKAGE}-${VERSION}.tar.bz2\"")
|
||
|
|
||
|
SET("prefix" ${CMAKE_INSTALL_PREFIX})
|
||
|
SET("includedir" ${CMAKE_INSTALL_PREFIX}/include)
|
||
|
SET("libdir" ${LIB_INSTALL_DIR})
|
||
|
|
||
|
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wunused -Werror" )
|
||
|
SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3" )
|
||
|
|
||
|
####################################################################
|
||
|
# PACKAGING #
|
||
|
####################################################################
|
||
|
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1)
|
||
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LMDB is a tiny database with some great capabilities")
|
||
|
SET(CPACK_PACKAGE_VENDOR "http://symas.com")
|
||
|
SET(CPACK_PACKAGE_VERSION_MAJOR ${LMDB_MAJOR})
|
||
|
SET(CPACK_PACKAGE_VERSION_MINOR ${LMDB_MINOR})
|
||
|
SET(CPACK_PACKAGE_VERSION_PATCH ${LMDB_PATCH})
|
||
|
SET(CPACK_GENERATOR "TBZ2")
|
||
|
SET(CPACK_SOURCE_GENERATOR "TBZ2")
|
||
|
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
|
||
|
MESSAGE(STATUS "Package file ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||
|
|
||
|
# The following components are regex's to match anywhere (unless anchored)
|
||
|
# in absolute path + filename to find files or directories to be excluded
|
||
|
# from source tarball.
|
||
|
SET (CPACK_SOURCE_IGNORE_FILES
|
||
|
#git files
|
||
|
"/.git"
|
||
|
"\\\\.gitignore$"
|
||
|
#svn files
|
||
|
"\\\\.svn/"
|
||
|
"\\\\.cvsignore$"
|
||
|
# temporary files
|
||
|
"\\\\.swp$"
|
||
|
# backup files
|
||
|
"~$"
|
||
|
# eclipse files
|
||
|
"\\\\.cdtproject$"
|
||
|
"\\\\.cproject$"
|
||
|
"\\\\.project$"
|
||
|
"\\\\.settings/"
|
||
|
# others
|
||
|
"\\\\.#"
|
||
|
"/#"
|
||
|
"/build/"
|
||
|
"/_build/"
|
||
|
"/\\\\.git/"
|
||
|
# used before
|
||
|
"/CVS/"
|
||
|
"/\\\\.libs/"
|
||
|
"/\\\\.deps/"
|
||
|
"\\\\.o$"
|
||
|
"\\\\.lo$"
|
||
|
"\\\\.la$"
|
||
|
"Makefile\\\\.in$"
|
||
|
"Makefile$"
|
||
|
# autotool
|
||
|
"/m4/"
|
||
|
"autom4te.cache"
|
||
|
"config.log"
|
||
|
"config.h$"
|
||
|
"configure$"
|
||
|
"config.status"
|
||
|
"depcomp"
|
||
|
"config.guess"
|
||
|
"install.sh"
|
||
|
"libtool"
|
||
|
# generated
|
||
|
"\\\\.bz2$"
|
||
|
"\\\\.class$"
|
||
|
"/bindings/ruby/rdoc/"
|
||
|
)
|
||
|
|
||
|
INCLUDE(CPack)
|
||
|
|
||
|
####################################################################
|
||
|
|
||
|
SET( DOC_INSTALL_DIR
|
||
|
"${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
|
||
|
CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
|
||
|
FORCE
|
||
|
)
|
||
|
|
||
|
IF(HAVE_WARNINGS)
|
||
|
MESSAGE(STATUS " ************ NOTE: ************")
|
||
|
MESSAGE(STATUS " Warnings occurred during cmake configuration... Please see output")
|
||
|
MESSAGE(STATUS " *******************************")
|
||
|
ENDIF(HAVE_WARNINGS)
|
||
|
|
||
|
####################################################################
|
||
|
# RPM SPEC #
|
||
|
####################################################################
|
||
|
|
||
|
SET( AUTOBUILD_COMMAND
|
||
|
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
|
||
|
COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
|
||
|
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/package
|
||
|
COMMAND ${CMAKE_MAKE_PROGRAM} package_source
|
||
|
COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
|
||
|
COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
|
||
|
)
|
||
|
|
||
|
ADD_CUSTOM_TARGET( srcpackage_local
|
||
|
${AUTOBUILD_COMMAND}
|
||
|
)
|
||
|
|
||
|
ADD_CUSTOM_TARGET( srcpackage
|
||
|
${AUTOBUILD_COMMAND}
|
||
|
)
|
||
|
|
||
|
####################################################################
|
||
|
# Library build #
|
||
|
####################################################################
|
||
|
|
||
|
SET( LMDB_HEADERS lmdb.h )
|
||
|
INSTALL(FILES ${LMDB_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
|
||
|
|
||
|
SET( LMDB_SOURCES mdb.c midl.c )
|
||
|
ADD_LIBRARY( lmdb SHARED ${LMDB_SOURCES} )
|
||
|
TARGET_LINK_LIBRARIES( lmdb ${CMAKE_THREAD_LIBS_INIT} )
|
||
|
|
||
|
SET_TARGET_PROPERTIES(lmdb PROPERTIES VERSION 0.0.0 SOVERSION ${LMDB_MAJOR})
|
||
|
INSTALL(TARGETS lmdb DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||
|
|
||
|
####################################################################
|
||
|
# Executables build #
|
||
|
####################################################################
|
||
|
|
||
|
ADD_EXECUTABLE(mdb_stat mdb_stat.c)
|
||
|
TARGET_LINK_LIBRARIES(mdb_stat lmdb)
|
||
|
|
||
|
ADD_EXECUTABLE(mdb_copy mdb_copy.c)
|
||
|
TARGET_LINK_LIBRARIES(mdb_copy lmdb)
|
||
|
|
||
|
install(TARGETS
|
||
|
mdb_stat
|
||
|
mdb_copy
|
||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||
|
|
||
|
####################################################################
|
||
|
# Man pages #
|
||
|
####################################################################
|
||
|
|
||
|
SET( LMDB_MAN mdb_stat.1 mdb_copy.1 )
|
||
|
INSTALL(FILES ${LMDB_MAN} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1")
|
||
|
|
||
|
####################################################################
|
||
|
# Tests build #
|
||
|
# leave out mtest6, only compiles with DEBUG enabled lib #
|
||
|
####################################################################
|
||
|
|
||
|
SET( mtest_SOURCES mtest.c )
|
||
|
SET( mtest2_SOURCES mtest2.c )
|
||
|
SET( mtest3_SOURCES mtest3.c )
|
||
|
SET( mtest4_SOURCES mtest4.c )
|
||
|
SET( mtest5_SOURCES mtest5.c )
|
||
|
ADD_EXECUTABLE( mtest ${mtest_SOURCES} )
|
||
|
ADD_EXECUTABLE( mtest2 ${mtest2_SOURCES} )
|
||
|
ADD_EXECUTABLE( mtest3 ${mtest3_SOURCES} )
|
||
|
ADD_EXECUTABLE( mtest4 ${mtest4_SOURCES} )
|
||
|
ADD_EXECUTABLE( mtest5 ${mtest5_SOURCES} )
|
||
|
TARGET_LINK_LIBRARIES( mtest lmdb )
|
||
|
TARGET_LINK_LIBRARIES( mtest2 lmdb )
|
||
|
TARGET_LINK_LIBRARIES( mtest3 lmdb )
|
||
|
TARGET_LINK_LIBRARIES( mtest4 lmdb )
|
||
|
TARGET_LINK_LIBRARIES( mtest5 lmdb )
|
||
|
ADD_TEST( test_mtest mtest )
|
||
|
ADD_TEST( test_mtest2 mtest2 )
|
||
|
ADD_TEST( test_mtest3 mtest3 )
|
||
|
ADD_TEST( test_mtest4 mtest4 )
|
||
|
ADD_TEST( test_mtest5 mtest5 )
|