Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
310 lines (274 sloc) 8.85 KB
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Please refer to the README for information about making permanent changes. #
################################################################################
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 2.8)
project(filemq)
enable_language(C)
enable_testing()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
########################################################################
# determine version
########################################################################
foreach(which MAJOR MINOR PATCH)
file(
STRINGS
"${SOURCE_DIR}/include/filemq_library.h"
FILEMQ_VERSION_STRING REGEX
"#define FILEMQ_VERSION_${which}"
)
string(
REGEX MATCH
"#define FILEMQ_VERSION_${which} ([0-9_]+)"
FILEMQ_REGEX_MATCH
"${FILEMQ_VERSION_STRING}"
)
if (NOT FILEMQ_REGEX_MATCH)
message(
FATAL_ERROR
"failed to parse FILEMQ_VERSION_${which} from filemq.h"
)
endif()
set(FILEMQ_${which}_VERSION ${CMAKE_MATCH_1})
endforeach(which)
set(
FILEMQ_VERSION
${FILEMQ_MAJOR_VERSION}.${FILEMQ_MINOR_VERSION}.${FILEMQ_PATCH_VERSION}
)
########################################################################
# options
########################################################################
if (EXISTS ".git")
OPTION (WITH_DRAFTS "Build and install draft classes and methods" ON)
else ()
OPTION (WITH_DRAFTS "Build and install draft classes and methods" OFF)
endif ()
IF (WITH_DRAFTS)
ADD_DEFINITIONS (-DWITH_DRAFTS)
ENDIF (WITH_DRAFTS)
########################################################################
# platform.h
########################################################################
include(CheckIncludeFile)
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H)
CHECK_INCLUDE_FILE("net/if_media.h" HAVE_NET_IF_MEDIA_H)
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS("freeifaddrs" HAVE_FREEIFADDRS)
include(CheckIncludeFiles)
check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H)
if (NOT HAVE_NET_IF_H)
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H)
endif()
file(WRITE "${SOURCE_DIR}/src/platform.h.in" "
#cmakedefine HAVE_LINUX_WIRELESS_H
#cmakedefine HAVE_NET_IF_H
#cmakedefine HAVE_NET_IF_MEDIA_H
#cmakedefine HAVE_GETIFADDRS
#cmakedefine HAVE_FREEIFADDRS
")
configure_file("${SOURCE_DIR}/src/platform.h.in" "${SOURCE_DIR}/src/platform.h")
#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC)
enable_language(CXX)
file(GLOB sources "${SOURCE_DIR}/src/*.c")
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()
# required libraries for mingw
if (MINGW)
set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi)
endif()
# required libraries for cygwin
if (CYGWIN)
set(MORE_LIBRARIES -luuid)
endif()
list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}")
set(OPTIONAL_LIBRARIES)
########################################################################
# LIBSODIUM dependency
########################################################################
find_package(libsodium)
IF (LIBSODIUM_FOUND)
include_directories(${LIBSODIUM_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${LIBSODIUM_LIBRARIES})
add_definitions(-DHAVE_LIBSODIUM)
list(APPEND OPTIONAL_LIBRARIES ${LIBSODIUM_LIBRARIES})
ENDIF (LIBSODIUM_FOUND)
########################################################################
# LIBZMQ dependency
########################################################################
find_package(libzmq REQUIRED)
IF (LIBZMQ_FOUND)
include_directories(${LIBZMQ_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES})
ELSE (LIBZMQ_FOUND)
message( FATAL_ERROR "libzmq not found." )
ENDIF (LIBZMQ_FOUND)
########################################################################
# CZMQ dependency
########################################################################
find_package(czmq REQUIRED)
IF (CZMQ_FOUND)
include_directories(${CZMQ_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${CZMQ_LIBRARIES})
ELSE (CZMQ_FOUND)
message( FATAL_ERROR "czmq not found." )
ENDIF (CZMQ_FOUND)
########################################################################
# includes
########################################################################
set (filemq_headers
include/filemq_library.h
include/filemq.h
)
IF (WITH_DRAFTS)
list(APPEND filemq_headers
include/fmq_msg.h
include/fmq_server.h
include/fmq_client.h
)
ENDIF (WITH_DRAFTS)
source_group ("Header Files" FILES ${filemq_headers})
install(FILES ${filemq_headers} DESTINATION include)
########################################################################
# library
########################################################################
include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include")
set (filemq_sources
)
IF (WITH_DRAFTS)
list(APPEND filemq_sources
src/fmq_msg.c
src/fmq_server.c
src/fmq_client.c
)
ENDIF (WITH_DRAFTS)
source_group("Source Files" FILES ${filemq_sources})
if (NOT DEFINED BUILD_SHARED_LIBS)
SET(BUILD_SHARED_LIBS ON)
endif()
add_library(filemq ${filemq_sources})
set_target_properties(filemq
PROPERTIES DEFINE_SYMBOL "LIBFILEMQ_EXPORTS"
)
set_target_properties(filemq
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
target_link_libraries(filemq
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
)
install(TARGETS filemq
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file
RUNTIME DESTINATION bin # .dll file
)
########################################################################
# pkgconfig
########################################################################
set(VERSION "${FILEMQ_VERSION}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib${LIB_SUFFIX}")
set(includedir "\${prefix}/include")
IF (WITH_DRAFTS)
set(pkg_config_defines "-DWITH_DRAFTS=1")
ELSE (WITH_DRAFTS)
set(pkg_config_defines "")
ENDIF (WITH_DRAFTS)
configure_file(
"${SOURCE_DIR}/src/libfilemq.pc.in"
"${SOURCE_DIR}/src/libfilemq.pc"
@ONLY)
install(
FILES "${SOURCE_DIR}/src/libfilemq.pc"
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
)
########################################################################
# executables
########################################################################
add_executable(
filemq_server
"${SOURCE_DIR}/src/filemq_server.c"
)
target_link_libraries(
filemq_server
filemq
${LIBZMQ_LIBRARIES}
${CZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
set_target_properties(
filemq_server
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
add_executable(
filemq_client
"${SOURCE_DIR}/src/filemq_client.c"
)
target_link_libraries(
filemq_client
filemq
${LIBZMQ_LIBRARIES}
${CZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
set_target_properties(
filemq_client
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
add_executable(
filemq_selftest
"${SOURCE_DIR}/src/filemq_selftest.c"
)
target_link_libraries(
filemq_selftest
filemq
${LIBZMQ_LIBRARIES}
${CZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
set_target_properties(
filemq_selftest
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${SOURCE_DIR}/src"
)
########################################################################
# tests
########################################################################
set(CLASSTEST_TIMEOUT 5 CACHE STRING "Timeout of the selftest of a class")
set(TOTAL_TIMEOUT 20 CACHE STRING "Timout of the total testsuite")
set(TEST_CLASSES
)
IF (WITH_DRAFTS)
list(APPEND TEST_CLASSES
fmq_msg
fmq_server
fmq_client
)
ENDIF (WITH_DRAFTS)
foreach(TEST_CLASS ${TEST_CLASSES})
add_test(
NAME ${TEST_CLASS}
COMMAND filemq_selftest --continue --verbose --test ${TEST_CLASS}
)
set_tests_properties(
${TEST_CLASS}
PROPERTIES TIMEOUT ${CLASSTEST_TIMEOUT}
)
endforeach(TEST_CLASS)
########################################################################
# summary
########################################################################
message(STATUS "version: ${FILEMQ_VERSION}")
message(STATUS "install: ${CMAKE_INSTALL_PREFIX}")
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Please refer to the README for information about making permanent changes. #
################################################################################