mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
Detect ZeroMQ version at build time; hide NSIS dependencies in new cmake folder.
This commit is contained in:
parent
b42e45adb8
commit
56bb3df1f6
@ -4,10 +4,7 @@ cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
project (ZeroMQ)
|
||||
|
||||
# TODO: Extract from include/zmq.h
|
||||
set (ZMQ_VERSION_MAJOR "3")
|
||||
set (ZMQ_VERSION_MINOR "2")
|
||||
set (ZMQ_VERSION_PATCH "0")
|
||||
include (${CMAKE_SOURCE_DIR}/cmake/Modules/TestZMQVersion.cmake)
|
||||
|
||||
# WARNING: Windows Python will override Cygwin yet not work with Asciidoc.
|
||||
#find_package (PythonInterp REQUIRED)
|
||||
@ -198,9 +195,9 @@ add_custom_command(
|
||||
list(APPEND sources ${CMAKE_BINARY_DIR}/platform.hpp)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set (nsis-template ${CMAKE_SOURCE_DIR}/NSIS.template64.in)
|
||||
set (nsis-template ${CMAKE_SOURCE_DIR}/cmake/NSIS.template64.in)
|
||||
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set (nsis-template ${CMAKE_SOURCE_DIR}/NSIS.template32.in)
|
||||
set (nsis-template ${CMAKE_SOURCE_DIR}/cmake/NSIS.template32.in)
|
||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/NSIS.template.in
|
||||
|
27
cmake/Modules/TestZMQVersion.cmake
Normal file
27
cmake/Modules/TestZMQVersion.cmake
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
MESSAGE(STATUS "Detecting ZMQ")
|
||||
SET(TRY_RUN_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/zmq_run.dir)
|
||||
|
||||
TRY_RUN(RUN_RESULT COMPILE_RESULT
|
||||
${TRY_RUN_DIR}
|
||||
${CMAKE_SOURCE_DIR}/cmake/Modules/zmq_version.cpp
|
||||
CMAKE_FLAGS
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_SOURCE_DIR}/include"
|
||||
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
|
||||
RUN_OUTPUT_VARIABLE RUN_OUTPUT)
|
||||
|
||||
IF(COMPILE_RESULT)
|
||||
IF(RUN_RESULT MATCHES "FAILED_TO_RUN")
|
||||
MESSAGE(STATUS "Detecting ZMQ - failed")
|
||||
ELSE()
|
||||
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1" ZMQ_VERSION_MAJOR "${RUN_OUTPUT}")
|
||||
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\2" ZMQ_VERSION_MINOR "${RUN_OUTPUT}")
|
||||
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\3" ZMQ_VERSION_PATCH "${RUN_OUTPUT}")
|
||||
MESSAGE(STATUS "Detecting ZMQ - ${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Check for ZMQ version - not found")
|
||||
MESSAGE(STATUS "Detecting ZMQ - failed")
|
||||
ENDIF()
|
||||
|
||||
|
31
cmake/Modules/zmq_version.cpp
Normal file
31
cmake/Modules/zmq_version.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright (c) 2007-2012 iMatix Corporation
|
||||
Copyright (c) 2009-2011 250bpm s.r.o.
|
||||
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
|
||||
|
||||
This file is part of 0MQ.
|
||||
|
||||
0MQ is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
0MQ is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "zmq.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
printf ("%d.%d.%d\n", ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user