On this page
FindSWIG
Find the Simplified Wrapper and Interface Generator (SWIG) executable.
This module finds an installed SWIG and determines its version.
New 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.
New 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
Libdirectory (result ofswig -swiglib). SWIG_VERSION-
SWIG executable version (result of
swig -version). SWIG_<lang>_FOUND-
If
COMPONENTSorOPTIONAL_COMPONENTSare 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()
© 2000–2021 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.21/module/FindSWIG.html