2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
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
|
|
|
|
2014-07-05 16:55:36 +04:00
|
|
|
find_program(SWIG_EXECUTABLE NAMES swig3.0 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)
|