CMakeLists.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. #
  2. # Copyright (c) 2012 Martin Sustrik All rights reserved.
  3. # Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
  4. # Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
  5. # Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
  6. # Copyright 2017 Garrett D'Amore <garrett@damore.org>
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy
  9. # of this software and associated documentation files (the "Software"),
  10. # to deal in the Software without restriction, including without limitation
  11. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. # and/or sell copies of the Software, and to permit persons to whom
  13. # the Software is furnished to do so, subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included
  16. # in all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  24. # IN THE SOFTWARE.
  25. #
  26. cmake_minimum_required (VERSION 2.8.12)
  27. project (nanomsg C)
  28. include (CheckFunctionExists)
  29. include (CheckSymbolExists)
  30. include (CheckStructHasMember)
  31. include (CheckLibraryExists)
  32. include (CheckCSourceCompiles)
  33. include (GNUInstallDirs)
  34. if (POLICY CMP0042)
  35. # Newer cmake on MacOS should use @rpath
  36. cmake_policy (SET CMP0042 NEW)
  37. endif ()
  38. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  39. list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
  40. if ("${isSystemDir}" STREQUAL "-1")
  41. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  42. endif ("${isSystemDir}" STREQUAL "-1")
  43. set (NN_DESCRIPTION "High-Performance Scalability Protocols")
  44. set (ISSUE_REPORT_MSG "Please consider opening an issue at https://github.com/nanomsg/nanomsg")
  45. # Determine library versions.
  46. file (READ src/nn.h NN_HDR_STR)
  47. string (REGEX REPLACE ".*#define +NN_VERSION_CURRENT +([0-9]+).*" "\\1" NN_VERSION_CURRENT "${NN_HDR_STR}")
  48. string (REGEX REPLACE ".*#define +NN_VERSION_REVISION +([0-9]+).*" "\\1" NN_VERSION_REVISION "${NN_HDR_STR}")
  49. string (REGEX REPLACE ".*#define +NN_VERSION_AGE +([0-9]+).*" "\\1" NN_VERSION_AGE "${NN_HDR_STR}")
  50. if ((NN_VERSION_CURRENT STREQUAL "") OR (NN_VERSION_REVISION STREQUAL "") OR (NN_VERSION_AGE STREQUAL ""))
  51. message (FATAL_ERROR "Could not read ABI version from nn.h")
  52. else ()
  53. set (NN_ABI_VERSION "${NN_VERSION_CURRENT}")
  54. set (NN_LIB_VERSION "${NN_VERSION_CURRENT}.${NN_VERSION_REVISION}.${NN_VERSION_AGE}")
  55. message (STATUS "Detected nanomsg ABI v${NN_ABI_VERSION} (v${NN_LIB_VERSION})")
  56. endif ()
  57. # Determine package version.
  58. find_package (Git QUIET)
  59. if (DEFINED ENV{TRAVIS_TAG})
  60. set (NN_PACKAGE_VERSION "$ENV{TRAVIS_TAG}")
  61. elseif (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
  62. # Working off a git repo, using git versioning
  63. # Get version from last tag
  64. execute_process (
  65. COMMAND "${GIT_EXECUTABLE}" describe --always# | sed -e "s:v::"
  66. WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  67. OUTPUT_VARIABLE NN_PACKAGE_VERSION
  68. OUTPUT_STRIP_TRAILING_WHITESPACE)
  69. # If the sources have been changed locally, add -dirty to the version.
  70. execute_process (
  71. COMMAND "${GIT_EXECUTABLE}" diff --quiet
  72. WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  73. RESULT_VARIABLE res)
  74. if (res EQUAL 1)
  75. set (NN_PACKAGE_VERSION "${NN_PACKAGE_VERSION}-dirty")
  76. endif()
  77. elseif (EXISTS ${PROJECT_SOURCE_DIR}/.version)
  78. # If git is not available (e.g. when building from source package)
  79. # we can extract the package version from .version file.
  80. file (STRINGS .version NN_PACKAGE_VERSION)
  81. else ()
  82. set (NN_PACKAGE_VERSION "Unknown")
  83. endif()
  84. # User-defined options.
  85. option (NN_STATIC_LIB "Build static library instead of shared library." OFF)
  86. option (NN_ENABLE_DOC "Enable building documentation." ON)
  87. option (NN_ENABLE_COVERAGE "Enable coverage reporting." OFF)
  88. option (NN_ENABLE_GETADDRINFO_A "Enable/disable use of getaddrinfo_a in place of getaddrinfo." ON)
  89. option (NN_TESTS "Build and run nanomsg tests" ON)
  90. option (NN_TOOLS "Build nanomsg tools" ON)
  91. option (NN_ENABLE_NANOCAT "Enable building nanocat utility." ${NN_TOOLS})
  92. set (NN_MAX_SOCKETS 512 CACHE STRING "max number of nanomsg sockets that can be created")
  93. # Platform checks.
  94. if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
  95. set(NN_WARN_FLAGS "-Wall -Wextra")
  96. elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
  97. set(NN_WARN_FLAGS "-Wall -Wextra")
  98. elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
  99. set(NN_WARN_FLAGS "-Wall -Wextra")
  100. endif()
  101. if (NN_ENABLE_COVERAGE)
  102. # NB: This only works for GCC and Clang 3.0 and newer. If your stuff
  103. # is older than that, you will need to find something newer. For
  104. # correct reporting, we always turn off all optimizations.
  105. if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
  106. set(NN_COVERAGE_FLAGS "-g -O0 --coverage")
  107. elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
  108. set(NN_COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
  109. elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
  110. set(NN_COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
  111. else()
  112. message(FATAL_ERROR "Unable to enable coverage for your compiler.")
  113. endif()
  114. endif()
  115. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NN_WARN_FLAGS} ${NN_COVERAGE_FLAGS}")
  116. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NN_WARN_FLAGS} ${NN_COVERAGE_FLAGS}")
  117. find_package (Threads REQUIRED)
  118. message(STATUS "OS System is ${CMAKE_SYSTEM_NAME}")
  119. message(STATUS "OS Version is ${CMAKE_SYSTEM_VERSION}")
  120. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  121. add_definitions (-DNN_HAVE_LINUX)
  122. if (CMAKE_SYSTEM_VERSION MATCHES "Microsoft")
  123. add_definitions (-DNN_HAVE_WSL)
  124. endif()
  125. elseif (CMAKE_SYSTEM_NAME MATCHES "Android")
  126. add_definitions (-DNN_HAVE_ANDROID)
  127. add_definitions (-DNN_HAVE_LINUX)
  128. elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  129. add_definitions (-DNN_HAVE_OSX)
  130. elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
  131. set (NN_HAVE_WINSOCK 1)
  132. add_definitions (-DNN_HAVE_WINDOWS)
  133. add_definitions (-D_CRT_SECURE_NO_WARNINGS)
  134. # Target Windows Vista and later
  135. add_definitions (-D_WIN32_WINNT=0x0600)
  136. list (APPEND CMAKE_REQUIRED_DEFINITIONS -D_WIN32_WINNT=0x0600)
  137. elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
  138. add_definitions (-DNN_HAVE_FREEBSD)
  139. elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
  140. add_definitions (-DNN_HAVE_NETBSD)
  141. elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
  142. add_definitions (-DNN_HAVE_OPENBSD)
  143. elseif (CMAKE_SYSTEM_NAME MATCHES "Solaris|SunOS")
  144. add_definitions (-DNN_HAVE_SOLARIS)
  145. elseif (CMAKE_SYSTEM_NAME MATCHES "HP-UX")
  146. add_definitions (-DNN_HAVE_HPUX)
  147. elseif (CMAKE_SYSTEM_NAME MATCHES "QNX")
  148. add_definitions (-DNN_HAVE_QNX)
  149. else ()
  150. message (AUTHOR_WARNING "WARNING: This platform may or may not be supported: ${CMAKE_SYSTEM_NAME}")
  151. message (AUTHOR_WARNING "${ISSUE_REPORT_MSG}")
  152. endif ()
  153. if (NN_STATIC_LIB)
  154. add_definitions (-DNN_STATIC_LIB)
  155. endif ()
  156. macro (nn_check_func SYM DEF)
  157. check_function_exists (${SYM} ${DEF})
  158. if (${DEF})
  159. add_definitions (-D${DEF}=1)
  160. endif ()
  161. endmacro (nn_check_func)
  162. macro (nn_check_sym SYM HDR DEF)
  163. check_symbol_exists (${SYM} ${HDR} ${DEF})
  164. if (${DEF})
  165. add_definitions (-D${DEF}=1)
  166. endif ()
  167. endmacro (nn_check_sym)
  168. macro (nn_check_lib LIB SYM DEF)
  169. check_library_exists (${LIB} ${SYM} "" ${DEF})
  170. if (${DEF})
  171. add_definitions (-D${DEF}=1)
  172. set(NN_REQUIRED_LIBRARIES ${NN_REQUIRED_LIBRARIES} ${LIB})
  173. endif ()
  174. endmacro (nn_check_lib)
  175. macro (nn_check_struct_member STR MEM HDR DEF)
  176. check_struct_has_member ("struct ${STR}" ${MEM} ${HDR} ${DEF})
  177. if (${DEF})
  178. add_definitions (-D${DEF}=1)
  179. endif ()
  180. endmacro (nn_check_struct_member)
  181. if (WIN32)
  182. # Windows is a special snowflake.
  183. set(NN_REQUIRED_LIBRARIES ${NN_REQUIRED_LIBRARIES} ws2_32)
  184. set(NN_REQUIRED_LIBRARIES ${NN_REQUIRED_LIBRARIES} mswsock)
  185. set(NN_REQUIRED_LIBRARIES ${NN_REQUIRED_LIBRARIES} advapi32)
  186. nn_check_sym (InitializeConditionVariable windows.h NN_HAVE_CONDVAR)
  187. if (NOT NN_HAVE_CONDVAR)
  188. message (FATAL_ERROR
  189. "Modern Windows API support is missing. "
  190. "Versions of Windows prior to Vista are not supported. "
  191. "Further, the 32-bit MinGW environment is not supported. "
  192. "Ensure you have at least Windows Vista or newer, and are "
  193. "using either Visual Studio 2010 or newer or MinGW-W64.")
  194. endif()
  195. else ()
  196. # Unconditionally declare the following feature test macros. These are
  197. # needed for some platforms (glibc and SunOS/illumos) and should be harmless
  198. # on the others.
  199. add_definitions (-D_GNU_SOURCE)
  200. add_definitions (-D_REENTRANT)
  201. add_definitions (-D_THREAD_SAFE)
  202. add_definitions (-D_POSIX_PTHREAD_SEMANTICS)
  203. nn_check_func (gethrtime NN_HAVE_GETHRTIME)
  204. nn_check_func (socketpair NN_HAVE_SOCKETPAIR)
  205. nn_check_func (eventfd NN_HAVE_EVENTFD)
  206. nn_check_func (pipe NN_HAVE_PIPE)
  207. nn_check_func (pipe2 NN_HAVE_PIPE2)
  208. nn_check_func (accept4 NN_HAVE_ACCEPT4)
  209. nn_check_func (epoll_create NN_HAVE_EPOLL)
  210. nn_check_func (kqueue NN_HAVE_KQUEUE)
  211. nn_check_func (poll NN_HAVE_POLL)
  212. nn_check_lib (anl getaddrinfo_a NN_HAVE_GETADDRINFO_A)
  213. nn_check_lib (rt clock_gettime NN_HAVE_CLOCK_GETTIME)
  214. nn_check_lib (rt sem_wait NN_HAVE_SEMAPHORE_RT)
  215. nn_check_lib (pthread sem_wait NN_HAVE_SEMAPHORE_PTHREAD)
  216. nn_check_lib (nsl gethostbyname NN_HAVE_LIBNSL)
  217. nn_check_lib (socket socket NN_HAVE_LIBSOCKET)
  218. nn_check_sym (CLOCK_MONOTONIC time.h NN_HAVE_CLOCK_MONOTONIC)
  219. nn_check_sym (atomic_cas_32 atomic.h NN_HAVE_ATOMIC_SOLARIS)
  220. nn_check_sym (AF_UNIX sys/socket.h NN_HAVE_UNIX_SOCKETS)
  221. nn_check_sym (backtrace_symbols_fd execinfo.h NN_HAVE_BACKTRACE)
  222. nn_check_struct_member(msghdr msg_control sys/socket.h NN_HAVE_MSG_CONTROL)
  223. if (NN_HAVE_SEMAPHORE_RT OR NN_HAVE_SEMAPHORE_PTHREAD)
  224. if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
  225. # macOS doesn't have unnamed semaphores
  226. add_definitions (-DNN_HAVE_SEMAPHORE)
  227. endif()
  228. endif ()
  229. endif ()
  230. if (NOT NN_ENABLE_GETADDRINFO_A)
  231. add_definitions (-DNN_DISABLE_GETADDRINFO_A)
  232. endif ()
  233. check_c_source_compiles ("
  234. #include <stdint.h>
  235. int main()
  236. {
  237. volatile uint32_t n = 0;
  238. __sync_fetch_and_add (&n, 1);
  239. __sync_fetch_and_sub (&n, 1);
  240. return 0;
  241. }
  242. " NN_HAVE_GCC_ATOMIC_BUILTINS)
  243. if (NN_HAVE_GCC_ATOMIC_BUILTINS)
  244. add_definitions (-DNN_HAVE_GCC_ATOMIC_BUILTINS)
  245. endif ()
  246. add_definitions(-DNN_MAX_SOCKETS=${NN_MAX_SOCKETS})
  247. add_subdirectory (src)
  248. # Build the tools
  249. if (NN_ENABLE_NANOCAT)
  250. add_executable (nanocat tools/nanocat.c tools/options.c)
  251. target_link_libraries (nanocat ${PROJECT_NAME})
  252. endif ()
  253. if (NN_ENABLE_DOC)
  254. find_program (ASCIIDOCTOR_EXE asciidoctor)
  255. if (NOT ASCIIDOCTOR_EXE)
  256. message (WARNING "Could not find asciidoctor: skipping docs")
  257. set (NN_ENABLE_DOC OFF)
  258. else ()
  259. message (STATUS "Using asciidoctor at ${ASCIIDOCTOR_EXE}")
  260. endif ()
  261. endif ()
  262. # Build the documenation
  263. if (NN_ENABLE_DOC)
  264. set (NN_DOCDIR ${CMAKE_CURRENT_SOURCE_DIR}/doc)
  265. set (NN_STYLESHEET ${NN_DOCDIR}/stylesheet.css)
  266. set (NN_TITLE ${PROJECT_NAME} ${NN_PACKAGE_VERSION})
  267. set (NN_A2M ${ASCIIDOCTOR_EXE} -b manpage -amanmanual='${NN_TITLE}')
  268. set (NN_A2H ${ASCIIDOCTOR_EXE} -d manpage -b html5 -a stylesheeet=${NN_STYLESHEET} -aversion-label=${PROJECT_NAME} -arevnumber=${NN_PACKAGE_VERSION})
  269. macro (add_libnanomsg_man NAME SECT)
  270. add_custom_command (
  271. OUTPUT ${NAME}.${SECT}
  272. COMMAND ${NN_A2M} -o ${NAME}.${SECT} ${NN_DOCDIR}/${NAME}.adoc
  273. MAIN_DEPENDENCY ${NN_DOCDIR}/${NAME}.adoc
  274. )
  275. add_custom_command (
  276. OUTPUT ${NAME}.html
  277. COMMAND ${NN_A2H} -o ${NAME}.html ${NN_DOCDIR}/${NAME}.adoc
  278. DEPENDS ${NN_STYLESHEET}
  279. MAIN_DEPENDENCY ${NN_DOCDIR}/${NAME}.adoc
  280. )
  281. set(NN_MANS ${NN_MANS} ${NAME}.${SECT})
  282. set(NN_HTMLS ${NN_HTMLS} ${NAME}.html)
  283. install (
  284. FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.html
  285. DESTINATION ${CMAKE_INSTALL_DOCDIR}
  286. )
  287. install (
  288. FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.${SECT}
  289. DESTINATION ${CMAKE_INSTALL_MANDIR}/man${SECT}
  290. )
  291. endmacro (add_libnanomsg_man)
  292. if (NN_ENABLE_NANOCAT)
  293. add_libnanomsg_man (nanocat 1)
  294. endif ()
  295. add_libnanomsg_man (nn_errno 3)
  296. add_libnanomsg_man (nn_strerror 3)
  297. add_libnanomsg_man (nn_symbol 3)
  298. add_libnanomsg_man (nn_symbol_info 3)
  299. add_libnanomsg_man (nn_allocmsg 3)
  300. add_libnanomsg_man (nn_reallocmsg 3)
  301. add_libnanomsg_man (nn_freemsg 3)
  302. add_libnanomsg_man (nn_socket 3)
  303. add_libnanomsg_man (nn_close 3)
  304. add_libnanomsg_man (nn_get_statistic 3)
  305. add_libnanomsg_man (nn_getsockopt 3)
  306. add_libnanomsg_man (nn_setsockopt 3)
  307. add_libnanomsg_man (nn_bind 3)
  308. add_libnanomsg_man (nn_connect 3)
  309. add_libnanomsg_man (nn_shutdown 3)
  310. add_libnanomsg_man (nn_send 3)
  311. add_libnanomsg_man (nn_recv 3)
  312. add_libnanomsg_man (nn_sendmsg 3)
  313. add_libnanomsg_man (nn_recvmsg 3)
  314. add_libnanomsg_man (nn_device 3)
  315. add_libnanomsg_man (nn_cmsg 3)
  316. add_libnanomsg_man (nn_poll 3)
  317. add_libnanomsg_man (nn_term 3)
  318. add_libnanomsg_man (nanomsg 7)
  319. add_libnanomsg_man (nn_pair 7)
  320. add_libnanomsg_man (nn_reqrep 7)
  321. add_libnanomsg_man (nn_pubsub 7)
  322. add_libnanomsg_man (nn_survey 7)
  323. add_libnanomsg_man (nn_pipeline 7)
  324. add_libnanomsg_man (nn_bus 7)
  325. add_libnanomsg_man (nn_inproc 7)
  326. add_libnanomsg_man (nn_ipc 7)
  327. add_libnanomsg_man (nn_tcp 7)
  328. add_libnanomsg_man (nn_ws 7)
  329. add_libnanomsg_man (nn_env 7)
  330. add_custom_target (man ALL DEPENDS ${NN_MANS})
  331. add_custom_target (html ALL DEPENDS ${NN_HTMLS})
  332. endif ()
  333. # Build unit tests.
  334. if (NN_TESTS)
  335. enable_testing ()
  336. set (all_tests "")
  337. set (TEST_PORT 12100)
  338. macro (add_libnanomsg_test NAME TIMEOUT)
  339. list (APPEND all_tests ${NAME})
  340. add_executable (${NAME} tests/${NAME}.c)
  341. target_link_libraries (${NAME} ${PROJECT_NAME})
  342. add_test (NAME ${NAME} COMMAND ${NAME} ${TEST_PORT})
  343. set_tests_properties (${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
  344. math (EXPR TEST_PORT "${TEST_PORT}+10")
  345. endmacro (add_libnanomsg_test)
  346. # Transport tests.
  347. add_libnanomsg_test (inproc 5)
  348. add_libnanomsg_test (inproc_shutdown 10)
  349. add_libnanomsg_test (ipc 5)
  350. add_libnanomsg_test (ipc_shutdown 40)
  351. add_libnanomsg_test (ipc_stress 5)
  352. add_libnanomsg_test (tcp 20)
  353. add_libnanomsg_test (tcp_shutdown 120)
  354. add_libnanomsg_test (ws 20)
  355. # Protocol tests.
  356. add_libnanomsg_test (pair 5)
  357. add_libnanomsg_test (pubsub 5)
  358. add_libnanomsg_test (reqrep 5)
  359. add_libnanomsg_test (pipeline 5)
  360. add_libnanomsg_test (survey 5)
  361. add_libnanomsg_test (bus 5)
  362. # Feature tests.
  363. add_libnanomsg_test (async_shutdown 30)
  364. add_libnanomsg_test (block 5)
  365. add_libnanomsg_test (term 5)
  366. add_libnanomsg_test (timeo 5)
  367. add_libnanomsg_test (iovec 5)
  368. add_libnanomsg_test (msg 5)
  369. add_libnanomsg_test (prio 5)
  370. add_libnanomsg_test (poll 5)
  371. add_libnanomsg_test (device 5)
  372. add_libnanomsg_test (device4 5)
  373. add_libnanomsg_test (device5 5)
  374. add_libnanomsg_test (device6 5)
  375. add_libnanomsg_test (device7 30)
  376. add_libnanomsg_test (emfile 5)
  377. add_libnanomsg_test (domain 5)
  378. add_libnanomsg_test (trie 5)
  379. add_libnanomsg_test (list 5)
  380. add_libnanomsg_test (hash 5)
  381. add_libnanomsg_test (stats 5)
  382. add_libnanomsg_test (symbol 5)
  383. add_libnanomsg_test (separation 5)
  384. add_libnanomsg_test (zerocopy 5)
  385. add_libnanomsg_test (shutdown 5)
  386. add_libnanomsg_test (cmsg 5)
  387. add_libnanomsg_test (bug328 5)
  388. add_libnanomsg_test (bug777 5)
  389. add_libnanomsg_test (ws_async_shutdown 10)
  390. add_libnanomsg_test (reqttl 10)
  391. add_libnanomsg_test (surveyttl 10)
  392. # Platform-specific tests
  393. if (WIN32)
  394. add_libnanomsg_test (win_sec_attr 5)
  395. endif()
  396. # Build the performance tests.
  397. macro (add_libnanomsg_perf NAME)
  398. add_executable (${NAME} perf/${NAME}.c)
  399. target_link_libraries (${NAME} ${PROJECT_NAME})
  400. endmacro (add_libnanomsg_perf)
  401. add_libnanomsg_perf (inproc_lat)
  402. add_libnanomsg_perf (inproc_thr)
  403. add_libnanomsg_perf (local_lat)
  404. add_libnanomsg_perf (remote_lat)
  405. add_libnanomsg_perf (local_thr)
  406. add_libnanomsg_perf (remote_thr)
  407. endif ()
  408. install (TARGETS LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
  409. install (TARGETS ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
  410. install (FILES src/nn.h DESTINATION include/nanomsg)
  411. install (FILES src/inproc.h DESTINATION include/nanomsg)
  412. install (FILES src/ipc.h DESTINATION include/nanomsg)
  413. install (FILES src/tcp.h DESTINATION include/nanomsg)
  414. install (FILES src/ws.h DESTINATION include/nanomsg)
  415. install (FILES src/pair.h DESTINATION include/nanomsg)
  416. install (FILES src/pubsub.h DESTINATION include/nanomsg)
  417. install (FILES src/reqrep.h DESTINATION include/nanomsg)
  418. install (FILES src/pipeline.h DESTINATION include/nanomsg)
  419. install (FILES src/survey.h DESTINATION include/nanomsg)
  420. install (FILES src/bus.h DESTINATION include/nanomsg)
  421. if (NN_ENABLE_NANOCAT)
  422. install (TARGETS nanocat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  423. endif()
  424. set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
  425. set (CPACK_PACKAGE_VERSION ${NN_PACKAGE_VERSION})
  426. set (CPACK_SOURCE_GENERATOR "TBZ2;TGZ;ZIP")
  427. set (CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
  428. set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${NN_PACKAGE_VERSION}")
  429. add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
  430. include (CPack)