2008-10-01 20:03:57 +00:00
|
|
|
cmake_minimum_required(VERSION 2.4) # For all I know, 2.0 works too...
|
|
|
|
|
|
|
|
# Make cmake warning go away. They changed the default library search behavior.
|
|
|
|
# The new behavior seems preferable, though it shouldn't affect us either way.
|
|
|
|
|
|
|
|
if(COMMAND cmake_policy)
|
|
|
|
cmake_policy(SET CMP0003 NEW)
|
|
|
|
endif(COMMAND cmake_policy)
|
|
|
|
|
2008-03-02 23:25:31 +00:00
|
|
|
Project(Stasis)
|
|
|
|
|
|
|
|
SET(PACKAGE_VERSION 1)
|
|
|
|
|
|
|
|
SUBDIRS(src test utilities benchmarks examples)
|
2008-09-28 06:39:45 +00:00
|
|
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
SET(FLEX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
SET(BISON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2008-03-02 23:25:31 +00:00
|
|
|
|
|
|
|
# Main decisions
|
|
|
|
SET(BUILD_SHARED_LIBS ON)
|
|
|
|
#ENABLE_TESTING()
|
|
|
|
INCLUDE(CTest)
|
|
|
|
|
2008-09-28 06:39:45 +00:00
|
|
|
FIND_PACKAGE(FLEX)
|
|
|
|
FIND_PACKAGE(BISON)
|
2009-05-13 19:37:57 +00:00
|
|
|
FIND_PACKAGE(Doxygen)
|
|
|
|
if(DOXYGEN_EXECUTABLE)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/doc/developers/html/index.html
|
|
|
|
COMMAND rm -rf ${CMAKE_BINARY_DIR}/doc/developers
|
|
|
|
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/doc/developers
|
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile
|
|
|
|
DEPENDS ${CMAKE_BINARY_DIR}/doc/Doxyfile
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
add_custom_target(
|
|
|
|
docs ALL
|
|
|
|
DEPENDS
|
|
|
|
${CMAKE_BINARY_DIR}/doc/developers/html/index.html
|
|
|
|
)
|
|
|
|
else(DOXYGEN_EXECUTABLE)
|
|
|
|
message(STATUS "doxygen not found; documentation will not be built")
|
|
|
|
endif(DOXYGEN_EXECUTABLE)
|
2008-09-28 06:39:45 +00:00
|
|
|
|
2008-10-09 18:59:45 +00:00
|
|
|
FIND_LIBRARY(HAVE_CONFUSE NAMES confuse)
|
|
|
|
if(NOT HAVE_CONFUSE)
|
2008-11-05 22:33:09 +00:00
|
|
|
message(STATUS "libconfuse not found; sample application 'libdfa' will not be built")
|
2008-10-09 18:59:45 +00:00
|
|
|
endif(NOT HAVE_CONFUSE)
|
|
|
|
|
2008-11-05 22:33:09 +00:00
|
|
|
FIND_LIBRARY(HAVE_FUSE NAMES fuse)
|
|
|
|
if(NOT HAVE_FUSE)
|
|
|
|
message(STATUS "fuse not found; sample application 'stasis_fuse' will not be built")
|
|
|
|
endif(NOT HAVE_FUSE)
|
2008-03-02 23:25:31 +00:00
|
|
|
|
2009-07-26 18:51:45 +00:00
|
|
|
|
|
|
|
INCLUDE(CheckFunctionExists)
|
|
|
|
INCLUDE(CheckCSourceCompiles)
|
|
|
|
CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE)
|
|
|
|
CHECK_FUNCTION_EXISTS(fdatasync HAVE_FDATASYNC)
|
|
|
|
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
argc = O_DIRECT;
|
|
|
|
}
|
|
|
|
" HAVE_O_DIRECT)
|
|
|
|
|
2009-10-02 00:45:10 +00:00
|
|
|
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
getline(0,0,0);
|
|
|
|
}
|
|
|
|
" HAVE_GETLINE)
|
|
|
|
|
2009-10-15 22:46:25 +00:00
|
|
|
CHECK_C_SOURCE_COMPILES("
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
int i;
|
|
|
|
__sync_bool_compare_and_swap(&i, 0, 1);
|
|
|
|
}
|
|
|
|
" HAVE_GCC_ATOMICS)
|
|
|
|
|
2008-03-02 23:25:31 +00:00
|
|
|
MACRO(CREATE_CHECK NAME)
|
2008-03-02 23:34:15 +00:00
|
|
|
ADD_EXECUTABLE(${NAME} ${NAME}.c)
|
2009-04-14 21:55:47 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${NAME} ${COMMON_LIBRARIES})
|
2008-03-02 23:25:31 +00:00
|
|
|
ADD_TEST(${NAME} ${NAME})
|
|
|
|
ENDMACRO(CREATE_CHECK)
|
|
|
|
|
|
|
|
MACRO(CREATE_CHECK_OPT NAME OPT)
|
2008-03-02 23:34:15 +00:00
|
|
|
ADD_EXECUTABLE(${NAME} ${NAME}.c)
|
2009-04-14 21:55:47 +00:00
|
|
|
TARGET_LINK_LIBRARIES(${NAME} ${COMMON_LIBRARIES})
|
2008-03-02 23:25:31 +00:00
|
|
|
ADD_TEST(${NAME} ${NAME} ${OPT})
|
|
|
|
ENDMACRO(CREATE_CHECK_OPT)
|
|
|
|
|
2008-09-30 15:28:32 +00:00
|
|
|
MACRO(CREATE_EXECUTABLE NAME)
|
|
|
|
ADD_EXECUTABLE(${NAME} ${NAME}.c)
|
|
|
|
TARGET_LINK_LIBRARIES(${NAME} ${COMMON_LIBRARIES})
|
|
|
|
ENDMACRO(CREATE_EXECUTABLE)
|
2008-03-02 23:25:31 +00:00
|
|
|
|
|
|
|
# Output the config.h file
|
|
|
|
#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
2009-07-26 18:51:45 +00:00
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/build
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2008-03-02 23:25:31 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
/usr/include)
|
|
|
|
# set linker path for this and all subdirs
|
2009-04-29 20:22:41 +00:00
|
|
|
LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/src/stasis)
|
2008-03-02 23:25:31 +00:00
|
|
|
|
2008-11-07 03:44:41 +00:00
|
|
|
SET(COMMON_LIBRARIES stasis m pthread)
|
2009-08-06 04:55:46 +00:00
|
|
|
SET(CMAKE_C_FLAGS "-g -Wall -pedantic -std=gnu99 -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_C_FLAGS}")
|
|
|
|
SET(CMAKE_CXX_FLAGS "-g -Wall -Wno-variadic-macros -Wno-long-long -pedantic -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_CXX_FLAGS}")
|
2009-04-29 20:22:41 +00:00
|
|
|
|
|
|
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/stasis
|
|
|
|
DESTINATION include/
|
|
|
|
FILES_MATCHING PATTERN "*.h"
|
|
|
|
PATTERN ".svn" EXCLUDE
|
|
|
|
PATTERN ".deps" EXCLUDE)
|
|
|
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/stasis
|
|
|
|
DESTINATION include/
|
|
|
|
FILES_MATCHING PATTERN "*.h"
|
|
|
|
PATTERN ".svn" EXCLUDE
|
|
|
|
PATTERN ".deps" EXCLUDE)
|
2009-07-26 18:51:45 +00:00
|
|
|
|
|
|
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|