2013-10-15 15:17:36 +00:00
|
|
|
#.rst:
|
|
|
|
# FindSWIG
|
|
|
|
# --------
|
|
|
|
#
|
|
|
|
# Find SWIG
|
|
|
|
#
|
2005-12-14 18:51:08 +00:00
|
|
|
# This module finds an installed SWIG. It sets the following variables:
|
2008-01-10 21:22:52 +00:00
|
|
|
#
|
2013-10-15 15:17:36 +00: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-07 21:18:17 +00:00
|
|
|
#
|
2008-01-10 21:22:52 +00:00
|
|
|
#
|
2013-10-15 15:17:36 +00: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 18:51:08 +00:00
|
|
|
|
2009-09-28 15:45:50 +00:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2004-2009 Kitware, Inc.
|
2011-03-28 14:05:57 +00:00
|
|
|
# Copyright 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
2009-09-28 15:45:50 +00: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 00:48:47 +00:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 15:45:50 +00:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(SWIG_EXECUTABLE NAMES swig2.0 swig)
|
2004-04-30 16:11:02 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(SWIG_EXECUTABLE)
|
|
|
|
execute_process(COMMAND ${SWIG_EXECUTABLE} -swiglib
|
2008-01-10 21:22:52 +00:00
|
|
|
OUTPUT_VARIABLE SWIG_swiglib_output
|
|
|
|
ERROR_VARIABLE SWIG_swiglib_error
|
|
|
|
RESULT_VARIABLE SWIG_swiglib_result)
|
|
|
|
|
2012-08-13 17:47:32 +00: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 17:50:14 +00:00
|
|
|
else()
|
2012-08-13 17:47:32 +00:00
|
|
|
message(STATUS "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
|
|
|
else()
|
2012-08-13 17:47:32 +00:00
|
|
|
string(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output})
|
2008-01-10 21:22:52 +00:00
|
|
|
# force the path to be computed each time in case SWIG_EXECUTABLE has changed.
|
2012-08-13 17:47:32 +00:00
|
|
|
set(SWIG_DIR SWIG_DIR-NOTFOUND)
|
|
|
|
find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output})
|
|
|
|
if(SWIG_DIR)
|
|
|
|
set(SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake)
|
|
|
|
execute_process(COMMAND ${SWIG_EXECUTABLE} -version
|
2008-01-10 21:22:52 +00:00
|
|
|
OUTPUT_VARIABLE SWIG_version_output
|
|
|
|
ERROR_VARIABLE SWIG_version_output
|
|
|
|
RESULT_VARIABLE SWIG_version_result)
|
2012-08-13 17:47:32 +00:00
|
|
|
if(SWIG_version_result)
|
|
|
|
message(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -version\" failed with output:\n${SWIG_version_output}")
|
2012-08-13 17:50:14 +00:00
|
|
|
else()
|
2012-08-13 17:47:32 +00:00
|
|
|
string(REGEX REPLACE ".*SWIG Version[^0-9.]*\([0-9.]+\).*" "\\1"
|
2008-01-10 21:22:52 +00:00
|
|
|
SWIG_version_output "${SWIG_version_output}")
|
2012-08-13 17:47:32 +00:00
|
|
|
set(SWIG_VERSION ${SWIG_version_output} CACHE STRING "Swig version" FORCE)
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2008-01-10 21:22:52 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2010-08-07 21:18:17 +00:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
|
|
|
|
VERSION_VAR SWIG_VERSION )
|