1 Star 0 Fork 0

virqin/czmq

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 18.36 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 2.8.8)
project(czmq)
enable_language(C)
enable_testing()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# Select flags
SET(CMAKE_C_FLAGS_RELEASE "-O3")
# Will be used to add flags to pkg-config useful when apps want to statically link
set(pkg_config_libs_private "")
########################################################################
# options
########################################################################
if (NOT CMAKE_BUILD_TYPE)
if (EXISTS "${SOURCE_DIR}/.git")
set (CMAKE_BUILD_TYPE Debug)
else ()
# http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/
# http://stackoverflow.com/questions/6797395/cmake-execute-process-always-fails-with-no-such-file-or-directory-when-i-cal
execute_process(
COMMAND git rev-parse --show-toplevel
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_root
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "git workspace root [${git_result}]: ${git_root}")
if ( "${git_result}" == "0" )
set (CMAKE_BUILD_TYPE Debug)
else ()
set (CMAKE_BUILD_TYPE Release)
endif ()
endif ()
endif ()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON)
else ()
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF)
endif ()
IF (ENABLE_DRAFTS)
ADD_DEFINITIONS (-DCZMQ_BUILD_DRAFT_API)
ENDIF (ENABLE_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()
# specific case of windows UWP
if( "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND "${CMAKE_SYSTEM_VERSION}" STREQUAL "10.0")
ADD_DEFINITIONS(-DZMQ_HAVE_WINDOWS_UWP)
ADD_DEFINITIONS(-D_WIN32_WINNT=_WIN32_WINNT_WIN10)
endif()
# required libraries for mingw
if (MINGW)
set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi)
endif()
# required libraries for cygwin
if (CYGWIN)
set(MORE_LIBRARIES)
endif()
list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}")
set(OPTIONAL_LIBRARIES)
########################################################################
# LIBZMQ dependency
########################################################################
find_package(libzmq REQUIRED)
IF (LIBZMQ_FOUND)
include_directories(${LIBZMQ_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES})
set(pkg_config_libs_private "${pkg_config_libs_private} -lzmq")
ELSE (LIBZMQ_FOUND)
message( FATAL_ERROR "libzmq not found." )
ENDIF (LIBZMQ_FOUND)
########################################################################
# UUID dependency
########################################################################
find_package(uuid)
IF (UUID_FOUND)
include_directories(${UUID_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${UUID_LIBRARIES})
set(pkg_config_libs_private "${pkg_config_libs_private} -luuid")
add_definitions(-DHAVE_UUID)
list(APPEND OPTIONAL_LIBRARIES ${UUID_LIBRARIES})
ENDIF (UUID_FOUND)
########################################################################
# SYSTEMD dependency
########################################################################
find_package(systemd)
IF (SYSTEMD_FOUND)
include_directories(${SYSTEMD_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${SYSTEMD_LIBRARIES})
set(pkg_config_libs_private "${pkg_config_libs_private} -lsystemd")
add_definitions(-DHAVE_LIBSYSTEMD)
list(APPEND OPTIONAL_LIBRARIES ${SYSTEMD_LIBRARIES})
ENDIF (SYSTEMD_FOUND)
########################################################################
# LZ4 dependency
########################################################################
find_package(lz4)
IF (LZ4_FOUND)
include_directories(${LZ4_INCLUDE_DIRS})
list(APPEND MORE_LIBRARIES ${LZ4_LIBRARIES})
set(pkg_config_libs_private "${pkg_config_libs_private} -llz4")
add_definitions(-DHAVE_LIBLZ4)
list(APPEND OPTIONAL_LIBRARIES ${LZ4_LIBRARIES})
ENDIF (LZ4_FOUND)
########################################################################
# version
########################################################################
set(CZMQ_VERSION_MAJOR 4)
set(CZMQ_VERSION_MINOR 1)
set(CZMQ_VERSION_PATCH 1)
set(CZMQ_VERSION "${CZMQ_VERSION_MAJOR}.${CZMQ_VERSION_MINOR}.${CZMQ_VERSION_PATCH}")
message(STATUS "Detected CZMQ Version - ${CZMQ_VERSION}")
########################################################################
# includes
########################################################################
set (czmq_headers
include/czmq_library.h
include/czmq_prelude.h
include/czmq.h
include/zactor.h
include/zarmour.h
include/zcert.h
include/zcertstore.h
include/zchunk.h
include/zclock.h
include/zconfig.h
include/zdigest.h
include/zdir.h
include/zdir_patch.h
include/zfile.h
include/zframe.h
include/zhash.h
include/zhashx.h
include/ziflist.h
include/zlist.h
include/zlistx.h
include/zloop.h
include/zmsg.h
include/zpoller.h
include/zsock.h
include/zstr.h
include/zsys.h
include/zuuid.h
include/zauth.h
include/zbeacon.h
include/zgossip.h
include/zmonitor.h
include/zproxy.h
include/zrex.h
src/zgossip_msg.h
src/zsock_option.inc
src/zgossip_engine.inc
src/zhash_primes.inc
src/foreign/sha1/sha1.inc_c
src/foreign/sha1/sha1.h
src/foreign/slre/slre.inc_c
src/foreign/slre/slre.h
src/foreign/slre/readme.txt
)
IF (ENABLE_DRAFTS)
list(APPEND czmq_headers
include/zargs.h
include/zproc.h
include/ztimerset.h
include/ztrie.h
)
ENDIF (ENABLE_DRAFTS)
source_group ("Header Files" FILES ${czmq_headers})
install(FILES ${czmq_headers} DESTINATION include)
########################################################################
# library
########################################################################
include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include")
set (czmq_sources
src/zactor.c
src/zarmour.c
src/zcert.c
src/zcertstore.c
src/zchunk.c
src/zclock.c
src/zconfig.c
src/zdigest.c
src/zdir.c
src/zdir_patch.c
src/zfile.c
src/zframe.c
src/zhash.c
src/zhashx.c
src/ziflist.c
src/zlist.c
src/zlistx.c
src/zloop.c
src/zmsg.c
src/zpoller.c
src/zsock.c
src/zstr.c
src/zsys.c
src/zuuid.c
src/zauth.c
src/zbeacon.c
src/zgossip.c
src/zmonitor.c
src/zproxy.c
src/zrex.c
src/zgossip_msg.c
)
IF (ENABLE_DRAFTS)
list (APPEND czmq_sources
src/zargs.c
src/zproc.c
src/ztimerset.c
src/ztrie.c
)
ENDIF (ENABLE_DRAFTS)
IF (ENABLE_DRAFTS)
list (APPEND czmq_sources
src/czmq_private_selftest.c
)
ENDIF (ENABLE_DRAFTS)
source_group("Source Files" FILES ${czmq_sources})
option(CZMQ_BUILD_SHARED "Whether or not to build the shared object" ON)
option(CZMQ_BUILD_STATIC "Whether or not to build the static archive" ON)
if (NOT CZMQ_BUILD_SHARED AND NOT CZMQ_BUILD_STATIC)
message(FATAL_ERROR "Neither static nor shared library build enabled")
endif()
IF (NOT MSVC)
# avoid building everything twice for shared + static
# only on *nix, as Windows needs different preprocessor defines in static builds
add_library (objects OBJECT ${czmq_sources})
set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON)
ENDIF (NOT MSVC)
# shared
if (CZMQ_BUILD_SHARED)
IF (MSVC)
add_library(czmq SHARED ${czmq_sources})
ELSE (MSVC)
add_library(czmq SHARED $<TARGET_OBJECTS:objects>)
ENDIF (MSVC)
set_target_properties (czmq PROPERTIES
PUBLIC_HEADER "${public_headers}"
DEFINE_SYMBOL "CZMQ_EXPORTS"
SOVERSION "4"
VERSION "${CZMQ_VERSION}"
COMPILE_DEFINITIONS "DLL_EXPORT"
OUTPUT_NAME "czmq"
PREFIX "lib"
)
target_link_libraries(czmq
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
)
install(TARGETS czmq
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file
RUNTIME DESTINATION bin # .dll file
)
target_include_directories(czmq
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
)
endif()
# static
if (CZMQ_BUILD_STATIC)
IF (MSVC)
add_library(czmq-static STATIC ${czmq_sources})
ELSE (MSVC)
add_library(czmq-static STATIC $<TARGET_OBJECTS:objects>)
ENDIF (MSVC)
set_target_properties(czmq-static PROPERTIES
PUBLIC_HEADER "${public_headers}"
COMPILE_DEFINITIONS "CZMQ_STATIC"
OUTPUT_NAME "czmq"
PREFIX "lib"
)
target_link_libraries(czmq-static
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}
)
install(TARGETS czmq-static
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file
RUNTIME DESTINATION bin # .dll file
)
target_include_directories(czmq-static
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_compile_definitions(czmq-static
PUBLIC CZMQ_STATIC
)
endif()
include(${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists-local.txt) # Optional project-local hook
########################################################################
# pkgconfig
########################################################################
set (VERSION "4.1.1")
set (prefix "${CMAKE_INSTALL_PREFIX}")
set (exec_prefix "\${prefix}")
set (libdir "\${prefix}/lib${LIB_SUFFIX}")
set (includedir "\${prefix}/include")
IF (ENABLE_DRAFTS)
set (pkg_config_defines "-DCZMQ_BUILD_DRAFT_API=1")
ELSE (ENABLE_DRAFTS)
set (pkg_config_defines "")
ENDIF (ENABLE_DRAFTS)
configure_file(
"${SOURCE_DIR}/src/libczmq.pc.in"
"${SOURCE_DIR}/src/libczmq.pc"
@ONLY)
install(
FILES "${SOURCE_DIR}/src/libczmq.pc"
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
)
########################################################################
# executables
########################################################################
add_executable(
zmakecert
"${SOURCE_DIR}/src/zmakecert.c"
)
if (TARGET czmq)
target_link_libraries(
zmakecert
czmq
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
if (NOT TARGET czmq AND TARGET czmq-static)
target_link_libraries(
zmakecert
czmq-static
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
install(TARGETS zmakecert
RUNTIME DESTINATION bin
)
add_executable(
zsp
"${SOURCE_DIR}/src/zsp.c"
)
if (TARGET czmq)
target_link_libraries(
zsp
czmq
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
if (NOT TARGET czmq AND TARGET czmq-static)
target_link_libraries(
zsp
czmq-static
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
add_executable(
test_randof
"${SOURCE_DIR}/src/test_randof.c"
)
if (TARGET czmq)
target_link_libraries(
test_randof
czmq
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
if (NOT TARGET czmq AND TARGET czmq-static)
target_link_libraries(
test_randof
czmq-static
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
add_executable(
czmq_selftest
"${SOURCE_DIR}/src/czmq_selftest.c"
)
if (TARGET czmq)
target_link_libraries(
czmq_selftest
czmq
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
if (NOT TARGET czmq AND TARGET czmq-static)
target_link_libraries(
czmq_selftest
czmq-static
${LIBZMQ_LIBRARIES}
${OPTIONAL_LIBRARIES}
)
endif()
########################################################################
# tests
########################################################################
set(CLASSTEST_TIMEOUT 60 CACHE STRING "Timeout of the selftest of a class")
set(TOTAL_TIMEOUT 600 CACHE STRING "Timout of the total testsuite")
if(UNIX)
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-reachable=yes
--error-exitcode=1
--suppressions=src/.valgrind.supp")
endif()
set(TEST_CLASSES
zactor
zarmour
zcert
zcertstore
zchunk
zclock
zconfig
zdigest
zdir
zdir_patch
zfile
zframe
zhash
zhashx
ziflist
zlist
zlistx
zloop
zmsg
zpoller
zsock
zstr
zsys
zuuid
zauth
zbeacon
zgossip
zmonitor
zproxy
zrex
)
IF (ENABLE_DRAFTS)
list (APPEND TEST_CLASSES
zargs
zproc
ztimerset
ztrie
)
ENDIF (ENABLE_DRAFTS)
IF (ENABLE_DRAFTS)
list (APPEND TEST_CLASSES
private_classes
)
ENDIF (ENABLE_DRAFTS)
add_custom_target(
copy-selftest-ro ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/selftest-ro ${CMAKE_BINARY_DIR}/src/selftest-ro
)
add_custom_target(
make-selftest-rw ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/src/selftest-rw
)
set_directory_properties(
PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/src/selftest-ro;${CMAKE_BINARY_DIR}/src/selftest-rw"
)
foreach(TEST_CLASS ${TEST_CLASSES})
add_test(
NAME ${TEST_CLASS}
COMMAND czmq_selftest --continue --verbose --test ${TEST_CLASS}
)
set_tests_properties(
${TEST_CLASS}
PROPERTIES TIMEOUT ${CLASSTEST_TIMEOUT}
)
set_tests_properties(
${TEST_CLASS}
PROPERTIES DEPENDS "copy-selftest-ro;make-selftest-rw"
)
endforeach(TEST_CLASS)
include(CTest)
########################################################################
# cleanup
########################################################################
add_custom_target (distclean @echo Cleaning for source distribution)
set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt
${CMAKE_BINARY_DIR}/cmake_install.cmake
${CMAKE_BINARY_DIR}/Makefile
${CMAKE_BINARY_DIR}/CMakeFiles
${CMAKE_BINARY_DIR}/CTestTestfile.cmake
${CMAKE_BINARY_DIR}/DartConfiguration.tcl
${CMAKE_BINARY_DIR}/Testing
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_BINARY_DIR}/src/platform.h
${CMAKE_BINARY_DIR}/src/libczmq.pc
${CMAKE_BINARY_DIR}/src/libczmq.so
${CMAKE_BINARY_DIR}/src/czmq_selftest
${CMAKE_BINARY_DIR}/src/zmakecert
${CMAKE_BINARY_DIR}/src/zsp
${CMAKE_BINARY_DIR}/src/test_randof
${CMAKE_BINARY_DIR}/src/czmq_selftest
)
add_custom_command(
DEPENDS clean
COMMENT "distribution clean"
COMMAND rm
ARGS -rf CMakeTmp ${cmake_generated}
TARGET distclean
)
########################################################################
# summary
########################################################################
message ("")
message (STATUS "******************* Configuration Summary *******************")
message (STATUS "General:")
message (STATUS " Version : ${VERSION}")
message (STATUS " System : ${CMAKE_SYSTEM_NAME}")
message (STATUS " C compiler : ${CMAKE_C_COMPILER}")
message (STATUS " Debug C flags : ${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS}")
message (STATUS " Release C flags : ${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS}")
message (STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message (STATUS " Static build : ${CZMQ_BUILD_STATIC}")
message (STATUS " Shared build : ${CZMQ_BUILD_SHARED}")
IF (ENABLE_DRAFTS)
message (STATUS " Draft API : Yes")
ELSE (ENABLE_DRAFTS)
message (STATUS " Draft API : No")
ENDIF (ENABLE_DRAFTS)
message (STATUS "")
message (STATUS "Dependencies:")
include(FeatureSummary)
feature_summary (WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
message (STATUS "")
message (STATUS "Install:")
message (STATUS " Install prefix :" "${CMAKE_INSTALL_PREFIX}")
message (STATUS "")
message (STATUS "************************* Options ***************************")
message (STATUS "Options:")
message (STATUS " Use the Draft API (default = yes):")
message (STATUS " -DENABLE-DRAFTS=[yes|no]")
message (STATUS "")
message (STATUS "*************************************************************")
message (STATUS "Configuration complete! Now procced with:")
message (STATUS " 'make' compile the project")
message (STATUS " 'make test' run the project's selftest")
message (STATUS " 'make install' install the project to ${CMAKE_INSTALL_PREFIX}")
message (STATUS "")
message (STATUS "Further options are:")
message (STATUS " 'ctest -T memcheck' run the project's selftest with")
message (STATUS " valgrind to check for memory leaks")
message (STATUS "")
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/virqin/czmq.git
git@gitee.com:virqin/czmq.git
virqin
czmq
czmq
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385