Files
CMake/Tests/FindASPELL/Test/CMakeLists.txt
Peter Kokot dd2edc3497 FindASPELL: Add components and imported targets
Components are added in a backward-compatible way:

* ASPELL component - adds the ASPELL::ASPELL imported target
* Executable component - adds the ASPELL::Executable imported target

If components are not specified in find_package() call, module, by
default, searches for both components and provides backward
compatibility with the find_package(ASPELL) usage via ASPELL_LIBRARIES,
ASPELL_INCLUDE_DIR, and ASPELL_EXECUTABLE variables.

The ASPELL_DEFINITIONS variable description removed from the
documentation as it was never defined by this module.

Additionally added a Pspell interface check (pspell.h header file) if
Aspell library provides it. It is checked separately because it might
be located in a subdirectory of pspell/pspell.h and code includes it as
`<pspell.h>`. Some distributions package pspell.h as part of the
libpspell development package and install also libaspell development
package as a dependency for BC.

Added also ASPELL_VERSION variable in case aspell executable can
determine it.

Issue: #26811
2025-04-01 05:25:25 +02:00

28 lines
828 B
CMake

cmake_minimum_required(VERSION 3.10)
project(TestFindASPELL C)
include(CTest)
find_package(ASPELL COMPONENTS ASPELL)
add_executable(test_tgt main.c)
target_link_libraries(test_tgt ASPELL::ASPELL)
add_test(NAME test_tgt COMMAND test_tgt)
add_executable(test_var main.c)
target_include_directories(test_var PRIVATE ${ASPELL_INCLUDE_DIR})
target_link_libraries(test_var PRIVATE ${ASPELL_LIBRARIES})
add_test(NAME test_var COMMAND test_var)
set_tests_properties(
test_tgt test_var
PROPERTIES PASS_REGULAR_EXPRESSION "^Word \"[^\"]+\" is spelled correctly"
)
find_package(ASPELL)
add_executable(test_version version.c)
target_link_libraries(test_version ASPELL::ASPELL)
target_compile_definitions(
test_version PRIVATE -DCMAKE_EXPECTED_ASPELL_VERSION="${ASPELL_VERSION}"
)
add_test(NAME test_version COMMAND test_version)