2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindSWIG
|
|
|
|
# --------
|
|
|
|
#
|
|
|
|
# Find SWIG
|
|
|
|
#
|
2005-12-14 21:51:08 +03:00
|
|
|
# This module finds an installed SWIG. It sets the following variables:
|
2008-01-11 00:22:52 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# SWIG_FOUND - set to true if SWIG is found
|
|
|
|
# SWIG_DIR - the directory where swig is installed
|
|
|
|
# SWIG_EXECUTABLE - the path to the swig executable
|
|
|
|
# SWIG_VERSION - the version number of the swig executable
|
2010-08-08 01:18:17 +04:00
|
|
|
#
|
2008-01-11 00:22:52 +03:00
|
|
|
#
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
|
|
|
# The minimum required version of SWIG can be specified using the
|
|
|
|
# standard syntax, e.g. find_package(SWIG 1.1)
|
|
|
|
#
|
|
|
|
# All information is collected from the SWIG_EXECUTABLE so the version
|
|
|
|
# to be found can be changed from the command line by means of setting
|
|
|
|
# SWIG_EXECUTABLE
|
2005-12-14 21:51:08 +03:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2004-2009 Kitware, Inc.
|
2011-03-28 18:05:57 +04:00
|
|
|
# Copyright 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
2009-09-28 19:45:50 +04:00
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_program(SWIG_EXECUTABLE NAMES swig2.0 swig)
|
2004-04-30 20:11:02 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(SWIG_EXECUTABLE)
|
|
|
|
execute_process(COMMAND ${SWIG_EXECUTABLE} -swiglib
|
2008-01-11 00:22:52 +03:00
|
|
|
OUTPUT_VARIABLE SWIG_swiglib_output
|
|
|
|
ERROR_VARIABLE SWIG_swiglib_error
|
|
|
|
RESULT_VARIABLE SWIG_swiglib_result)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(SWIG_swiglib_result)
|
|
|
|
if(SWIG_FIND_REQUIRED)
|
|
|
|
message(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output})
|
2013-11-21 17:00:11 +04:00
|
|
|
find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output} NO_CMAKE_FIND_ROOT_PATH)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(SWIG_DIR)
|
2013-11-21 17:50:21 +04:00
|
|
|
set(SWIG_USE_FILE ${CMAKE_CURRENT_LIST_DIR}/UseSWIG.cmake)
|
2012-08-13 21:47:32 +04:00
|
|
|
execute_process(COMMAND ${SWIG_EXECUTABLE} -version
|
2008-01-11 00:22:52 +03:00
|
|
|
OUTPUT_VARIABLE SWIG_version_output
|
|
|
|
ERROR_VARIABLE SWIG_version_output
|
|
|
|
RESULT_VARIABLE SWIG_version_result)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(SWIG_version_result)
|
|
|
|
message(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -version\" failed with output:\n${SWIG_version_output}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE ".*SWIG Version[^0-9.]*\([0-9.]+\).*" "\\1"
|
2008-01-11 00:22:52 +03:00
|
|
|
SWIG_version_output "${SWIG_version_output}")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(SWIG_VERSION ${SWIG_version_output} CACHE STRING "Swig version" FORCE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2008-01-11 00:22:52 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2010-08-08 01:18:17 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
|
|
|
|
VERSION_VAR SWIG_VERSION )
|
2013-11-21 17:41:44 +04:00
|
|
|
|
|
|
|
mark_as_advanced(SWIG_DIR SWIG_VERSION)
|