FindASPELL
Finds the GNU Aspell spell checker library:
find_package(ASPELL [<version>] [COMPONENTS <components>] [...])
Components
This module supports optional components which can be specified using the find_package() command:
find_package(ASPELL [COMPONENTS <components>...])
Supported components include:
-
ASPELL -
Added in version 4.1.
Finds the Aspell library and its include paths.
-
Executable -
Added in version 4.1.
Finds the Aspell command-line interactive spell checker executable.
If no components are specified, the module searches for both the ASPELL and Executable components by default.
Imported Targets
This module provides the following Imported Targets when CMAKE_ROLE is PROJECT:
-
ASPELL::ASPELL -
Added in version 4.1.
Target encapsulating the Aspell library usage requirements. It is available only when the
ASPELLcomponent is found. -
ASPELL::Executable -
Added in version 4.1.
Target encapsulating the Aspell command-line spell checker executable. It is available only when the
Executablecomponent is found.
Result Variables
This module defines the following variables:
-
ASPELL_FOUND -
Boolean indicating whether (the requested version of) Aspell and all requested components were found.
-
ASPELL_VERSION -
Added in version 4.1.
Version string of the found Aspell if any. It may be only determined if the
Executablecomponent is found. If version isn't determined, version value is not set. -
ASPELL_INCLUDE_DIRS -
Added in version 4.1.
Include directories needed to use Aspell. They are available when the
ASPELLcomponent is found.The Aspell library may also provide a backward-compatible interface for Pspell via the
pspell.hheader file. If such an interface is found, it is also added to the list of include directories. -
ASPELL_LIBRARIES -
Libraries needed to link to Aspell. They are available when the
ASPELLcomponent is found.Changed in version 4.1: This variable is now set as a regular result variable instead of being a cache variable.
Cache Variables
The following cache variables may also be set:
-
ASPELL_INCLUDE_DIR -
The directory containing the
aspell.hheader file when using theExecutablecomponent. -
ASPELL_LIBRARY -
Added in version 4.1.
The path to the Aspell library when using the
ASPELLcomponent. -
ASPELL_EXECUTABLE -
The path to the
aspellcommand-line spell checker program when using theExecutablecomponent.
Examples
Finding the Aspell library with CMake 4.1 or later and linking it to a project target:
find_package(ASPELL COMPONENTS ASPELL) target_link_libraries(project_target PRIVATE ASPELL::ASPELL)
When writing backward-compatible code that supports CMake 4.0 and earlier, a local imported target can be defined directly in the project:
find_package(ASPELL COMPONENTS ASPELL)
if(ASPELL_FOUND AND NOT TARGET ASPELL::ASPELL)
add_library(ASPELL::ASPELL INTERFACE IMPORTED)
set_target_properties(
ASPELL::ASPELL
PROPERTIES
INTERFACE_LINK_LIBRARIES "${ASPELL_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${ASPELL_INCLUDE_DIR}"
)
endif()
target_link_libraries(project_target PRIVATE ASPELL::ASPELL)
Example, how to execute the aspell command-line spell checker in a project:
find_package(ASPELL COMPONENTS Executable)
execute_process(COMMAND ${ASPELL_EXECUTABLE} --help)
© 2000–2026 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/latest/module/FindASPELL.html