|
| 1 | +################################################################################ |
| 2 | +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # |
| 3 | +# Please refer to the README for information about making permanent changes. # |
| 4 | +################################################################################ |
| 5 | + |
| 6 | +######################################################################## |
| 7 | +# Project setup |
| 8 | +######################################################################## |
| 9 | +cmake_minimum_required(VERSION 2.8) |
| 10 | +project(filemq) |
| 11 | +enable_language(C) |
| 12 | +enable_testing() |
| 13 | + |
| 14 | +set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 15 | +set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 16 | + |
| 17 | +######################################################################## |
| 18 | +# determine version |
| 19 | +######################################################################## |
| 20 | +foreach(which MAJOR MINOR PATCH) |
| 21 | + file(STRINGS "${SOURCE_DIR}/include/filemq_library.h" FILEMQ_VERSION_STRING REGEX "#define FILEMQ_VERSION_${which}") |
| 22 | + string(REGEX MATCH "#define FILEMQ_VERSION_${which} ([0-9_]+)" FILEMQ_REGEX_MATCH "${FILEMQ_VERSION_STRING}") |
| 23 | + if (NOT FILEMQ_REGEX_MATCH) |
| 24 | + message(FATAL_ERROR "failed to parse FILEMQ_VERSION_${which} from filemq.h") |
| 25 | + endif() |
| 26 | + set(FILEMQ_${which}_VERSION ${CMAKE_MATCH_1}) |
| 27 | +endforeach(which) |
| 28 | + |
| 29 | +set(FILEMQ_VERSION ${FILEMQ_MAJOR_VERSION}.${FILEMQ_MINOR_VERSION}.${FILEMQ_PATCH_VERSION}) |
| 30 | + |
| 31 | +######################################################################## |
| 32 | +# platform.h |
| 33 | +######################################################################## |
| 34 | +include(CheckIncludeFile) |
| 35 | +CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H) |
| 36 | +CHECK_INCLUDE_FILE("net/if_media.h" HAVE_NET_IF_MEDIA_H) |
| 37 | + |
| 38 | +include(CheckFunctionExists) |
| 39 | +CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS) |
| 40 | +CHECK_FUNCTION_EXISTS("freeifaddrs" HAVE_FREEIFADDRS) |
| 41 | + |
| 42 | +include(CheckIncludeFiles) |
| 43 | +check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H) |
| 44 | +if (NOT HAVE_NET_IF_H) |
| 45 | + CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H) |
| 46 | +endif() |
| 47 | + |
| 48 | +file(WRITE ${BINARY_DIR}/platform.h.in " |
| 49 | +#cmakedefine HAVE_LINUX_WIRELESS_H |
| 50 | +#cmakedefine HAVE_NET_IF_H |
| 51 | +#cmakedefine HAVE_NET_IF_MEDIA_H |
| 52 | +#cmakedefine HAVE_GETIFADDRS |
| 53 | +#cmakedefine HAVE_FREEIFADDRS |
| 54 | +") |
| 55 | + |
| 56 | +configure_file(${BINARY_DIR}/platform.h.in ${BINARY_DIR}/platform.h) |
| 57 | + |
| 58 | +#The MSVC C compiler is too out of date, |
| 59 | +#so the sources have to be compiled as c++ |
| 60 | +if (MSVC) |
| 61 | + enable_language(CXX) |
| 62 | + file(GLOB sources ${SOURCE_DIR}/src/*.c) |
| 63 | + set_source_files_properties(${sources} PROPERTIES LANGUAGE CXX) |
| 64 | + set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi) |
| 65 | +endif() |
| 66 | + |
| 67 | +# required libraries for mingw |
| 68 | +if (MINGW) |
| 69 | + set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi) |
| 70 | +endif() |
| 71 | + |
| 72 | + |
| 73 | +list(APPEND CMAKE_MODULE_PATH ${SOURCE_DIR}) |
| 74 | + |
| 75 | +######################################################################## |
| 76 | +# ZMQ dependency |
| 77 | +######################################################################## |
| 78 | +find_package(ZeroMQ REQUIRED) |
| 79 | +include_directories(${ZEROMQ_INCLUDE_DIRS}) |
| 80 | +list(APPEND MORE_LIBRARIES ${ZEROMQ_LIBRARIES}) |
| 81 | + |
| 82 | +######################################################################## |
| 83 | +# CZMQ dependency |
| 84 | +######################################################################## |
| 85 | +find_package(CZMQ REQUIRED) |
| 86 | +include_directories(${CZMQ_INCLUDE_DIRS}) |
| 87 | +list(APPEND MORE_LIBRARIES ${CZMQ_LIBRARIES}) |
| 88 | + |
| 89 | +######################################################################## |
| 90 | +# includes |
| 91 | +######################################################################## |
| 92 | +set (filemq_headers |
| 93 | + include/filemq_library.h |
| 94 | + include/filemq.h |
| 95 | + include/fmq_msg.h |
| 96 | + include/fmq_server.h |
| 97 | + include/fmq_client.h |
| 98 | +) |
| 99 | +source_group ("Header Files" FILES ${filemq_headers}) |
| 100 | +install(FILES ${filemq_headers} DESTINATION include) |
| 101 | + |
| 102 | +######################################################################## |
| 103 | +# library |
| 104 | +######################################################################## |
| 105 | +include_directories(${BINARY_DIR}) |
| 106 | +include_directories(${SOURCE_DIR}/include) |
| 107 | +set (filemq_sources |
| 108 | + src/fmq_msg.c |
| 109 | + src/fmq_server.c |
| 110 | + src/fmq_client.c |
| 111 | +) |
| 112 | +source_group ("Source Files" FILES ${filemq_sources}) |
| 113 | +add_library(filemq SHARED ${filemq_sources}) |
| 114 | +set_target_properties(filemq PROPERTIES DEFINE_SYMBOL "LIBFILEMQ_EXPORTS") |
| 115 | +target_link_libraries(filemq ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}) |
| 116 | + |
| 117 | +install(TARGETS filemq |
| 118 | + LIBRARY DESTINATION lib${LIB_SUFFIX} # .so file |
| 119 | + ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file |
| 120 | + RUNTIME DESTINATION bin # .dll file |
| 121 | +) |
| 122 | + |
| 123 | +######################################################################## |
| 124 | +# pkgconfig |
| 125 | +######################################################################## |
| 126 | +set(VERSION "${FILEMQ_VERSION}") |
| 127 | +set(prefix "${CMAKE_INSTALL_PREFIX}") |
| 128 | +set(exec_prefix "\${prefix}") |
| 129 | +set(libdir "\${prefix}/lib${LIB_SUFFIX}") |
| 130 | +set(includedir "\${prefix}/include") |
| 131 | +configure_file( |
| 132 | + ${SOURCE_DIR}/src/libfilemq.pc.in |
| 133 | + ${BINARY_DIR}/libfilemq.pc |
| 134 | +@ONLY) |
| 135 | + |
| 136 | +install( |
| 137 | + FILES ${BINARY_DIR}/libfilemq.pc |
| 138 | + DESTINATION lib${LIB_SUFFIX}/pkgconfig |
| 139 | +) |
| 140 | + |
| 141 | +######################################################################## |
| 142 | +# tests |
| 143 | +######################################################################## |
| 144 | +add_executable(filemq_selftest ${SOURCE_DIR}/src/filemq_selftest.c) |
| 145 | +target_link_libraries(filemq_selftest filemq ${ZEROMQ_LIBRARIES}) |
| 146 | +add_test(filemq_selftest filemq_selftest) |
| 147 | + |
| 148 | +######################################################################## |
| 149 | +# summary |
| 150 | +######################################################################## |
| 151 | +message(STATUS "version: ${FILEMQ_VERSION}") |
| 152 | +message(STATUS "install: ${CMAKE_INSTALL_PREFIX}") |
| 153 | + |
| 154 | +################################################################################ |
| 155 | +# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # |
| 156 | +# Please refer to the README for information about making permanent changes. # |
| 157 | +################################################################################ |
0 commit comments