Detect ZeroMQ version at build time; hide NSIS dependencies in new cmake folder.

This commit is contained in:
Steve-o 2012-10-12 15:36:34 +00:00 committed by Steven McCoy
parent b42e45adb8
commit 56bb3df1f6
5 changed files with 61 additions and 6 deletions

View File

@ -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

View 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()

View 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;
}