mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
Problem: version detection broken, confuses libzmq and cppzmq versions
Solution: Fix version detection and cmake syntax errors Fixes #182
This commit is contained in:
parent
702d2fcf53
commit
7a8cc9d7cf
@ -30,5 +30,4 @@ sudo: required
|
||||
|
||||
# Build and check this project according to the BUILD_TYPE
|
||||
script:
|
||||
- chmod +x ci_build.sh
|
||||
- ./ci_build.sh
|
||||
|
@ -1,7 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(cppzmq)
|
||||
|
||||
find_package(ZeroMQ QUIET)
|
||||
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include (DetectCPPZMQVersion)
|
||||
|
||||
project(cppzmq VERSION ${DETECTED_CPPZMQ_VERSION})
|
||||
|
||||
find_package(ZeroMQ)
|
||||
|
||||
# libzmq autotools install: fallback to pkg-config
|
||||
if(NOT ZeroMQ_FOUND)
|
||||
@ -14,8 +19,7 @@ if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static))
|
||||
message(FATAL_ERROR "ZeroMQ version not supported!")
|
||||
endif()
|
||||
|
||||
set (${PROJECT_NAME}_VERSION ${ZeroMQ_VERSION})
|
||||
message(STATUS "cppzmq v${${PROJECT_NAME}_VERSION}")
|
||||
message(STATUS "cppzmq v${CPPZMQ_VERSION}")
|
||||
|
||||
set(CPPZMQ_HEADERS
|
||||
zmq.hpp
|
||||
@ -43,15 +47,13 @@ install(FILES ${CPPZMQ_HEADERS}
|
||||
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
|
||||
set(CPPZMQ_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for cppzmqConfig.cmake")
|
||||
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||
export(EXPORT ${PROJECT_NAME}-targets
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||
endif()
|
||||
export(EXPORT ${PROJECT_NAME}-targets
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION ${CPPZMQ_CMAKECONFIG_INSTALL_DIR})
|
||||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||
VERSION ${${PROJECT_NAME}_VERSION}
|
||||
VERSION ${CPPZMQ_VERSION}}
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
install(EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}Targets.cmake
|
||||
|
0
ci_build.sh
Normal file → Executable file
0
ci_build.sh
Normal file → Executable file
8
cmake/DetectCPPZMQVersion.cmake
Normal file
8
cmake/DetectCPPZMQVersion.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/zmq.hpp" _CPPZMQ_H_CONTENTS)
|
||||
string(REGEX REPLACE ".*#define CPPZMQ_VERSION_MAJOR ([0-9]+).*" "\\1" DETECTED_CPPZMQ_VERSION_MAJOR "${_CPPZMQ_H_CONTENTS}")
|
||||
string(REGEX REPLACE ".*#define CPPZMQ_VERSION_MINOR ([0-9]+).*" "\\1" DETECTED_CPPZMQ_VERSION_MINOR "${_CPPZMQ_H_CONTENTS}")
|
||||
string(REGEX REPLACE ".*#define CPPZMQ_VERSION_PATCH ([0-9]+).*" "\\1" DETECTED_CPPZMQ_VERSION_PATCH "${_CPPZMQ_H_CONTENTS}")
|
||||
set(DETECTED_CPPZMQ_VERSION "${DETECTED_CPPZMQ_VERSION_MAJOR}.${DETECTED_CPPZMQ_VERSION_MINOR}.${DETECTED_CPPZMQ_VERSION_PATCH}")
|
||||
|
||||
message(STATUS "Detected CPPZMQ Version - ${DETECTED_CPPZMQ_VERSION}")
|
21
version.sh
Executable file
21
version.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This script extracts the 0MQ version from zmq.hpp, which is the master
|
||||
# location for this information.
|
||||
#
|
||||
if [ ! -f zmq.hpp ]; then
|
||||
echo "version.sh: error: zmq.hpp does not exist" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
MAJOR=$(grep '^#define CPPZMQ_VERSION_MAJOR \+[0-9]\+' zmq.hpp)
|
||||
MINOR=$(grep '^#define CPPZMQ_VERSION_MINOR \+[0-9]\+' zmq.hpp)
|
||||
PATCH=$(grep '^#define CPPZMQ_VERSION_PATCH \+[0-9]\+' zmq.hpp)
|
||||
if [ -z "$MAJOR" -o -z "$MINOR" -o -z "$PATCH" ]; then
|
||||
echo "version.sh: error: could not extract version from zmq.hpp" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
MAJOR=$(echo $MAJOR | awk '{ print $3 }')
|
||||
MINOR=$(echo $MINOR | awk '{ print $3 }')
|
||||
PATCH=$(echo $PATCH | awk '{ print $3 }')
|
||||
echo $MAJOR.$MINOR.$PATCH | tr -d '\n\r'
|
||||
|
7
zmq.hpp
7
zmq.hpp
@ -53,6 +53,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/* Version macros for compile-time API version detection */
|
||||
#define CPPZMQ_VERSION_MAJOR 4
|
||||
#define CPPZMQ_VERSION_MINOR 3
|
||||
#define CPPZMQ_VERSION_PATCH 0
|
||||
|
||||
#define CPPZMQ_VERSION \
|
||||
ZMQ_MAKE_VERSION (CPPZMQ_VERSION_MAJOR, CPPZMQ_VERSION_MINOR, CPPZMQ_VERSION_PATCH)
|
||||
|
||||
#ifdef ZMQ_CPP11
|
||||
#include <chrono>
|
||||
|
Loading…
Reference in New Issue
Block a user