-if(LYX_ASPELL)
- find_package(ASPELL)
- include_directories(${ASPELL_INCLUDE_DIR})
-endif()
-
-if(LYX_ENCHANT)
- find_package(Enchant REQUIRED)
- include_directories(${ENCHANT_INCLUDE_DIR})
-endif()
-
-if(LYX_HUNSPELL)
- find_package(Hunspell REQUIRED)
- include_directories(${HUNSPELL_INCLUDE_DIR})
-endif()
+set(Spelling_FOUND OFF)
+set(Include_used_spellchecker) # String will be inserted into config.h
+
+foreach(_spell "ASPELL" "Enchant" "Hunspell")
+ string(TOUPPER ${_spell} _upspell)
+ find_package(${_spell})
+ if (${_upspell}_FOUND)
+ include_directories(${${_upspell}_INCLUDE_DIR})
+ set(Spelling_FOUND ON)
+ message(STATUS "Building with USE_${_upspell}")
+ set(Include_used_spellchecker "${Include_used_spellchecker}#define USE_${_upspell} 1\n")
+ else()
+ if(LYX_${_upspell})
+ message(FATAL_ERROR "Required ${_spell} devel package not found")
+ else()
+ message(STATUS "${_upspell} not found, building without ${_spell} support")
+ endif()
+ endif()
+endforeach()