FindSWIGΒΆ
Find the Simplified Wrapper and Interface Generator (SWIG) executable.
This module finds an installed SWIG and determines its version.
Added in version 3.18: If a COMPONENTS
or OPTIONAL_COMPONENTS
argument is given to the
find_package()
command, it will also determine supported target
languages.
Added in version 3.19: When a version is requested, it can be specified as a simple value or as a
range. For a detailed description of version range usage and capabilities,
refer to the find_package()
command.
The module defines the following variables:
SWIG_FOUND
Whether SWIG and any required components were found on the system.
SWIG_EXECUTABLE
Path to the SWIG executable.
SWIG_DIR
Path to the installed SWIG
Lib
directory (result ofswig -swiglib
).SWIG_VERSION
SWIG executable version (result of
swig -version
).SWIG_<lang>_FOUND
If
COMPONENTS
orOPTIONAL_COMPONENTS
are requested, each available target language<lang>
(lowercase) will be set to TRUE.
Any COMPONENTS
given to find_package
should be the names of supported
target languages as provided to the LANGUAGE argument of swig_add_library
,
such as python
or perl5
. Language names must be lowercase.
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
.
Example usage requiring SWIG 4.0 or higher and Python language support, with optional Fortran support:
find_package(SWIG 4.0 COMPONENTS python OPTIONAL_COMPONENTS fortran)
if(SWIG_FOUND)
message("SWIG found: ${SWIG_EXECUTABLE}")
if(NOT SWIG_fortran_FOUND)
message(WARNING "SWIG Fortran bindings cannot be generated")
endif()
endif()