diff --git a/CMakeLists.txt b/CMakeLists.txt index fe133eb26b..9ac172d06a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ LYX_OPTION(CPACK "Use the CPack management (Implies LYX_INSTALL optio LYX_OPTION(LOCALVERSIONING "Add version info to created package name (only used if LYX_CPACK option set)" OFF ALL) LYX_OPTION(INSTALL "Build install projects/rules (implies a bunch of other options)" OFF ALL) LYX_OPTION(NLS "Enable Native Language Support (NLS)" ON ALL) +LYX_OPTION(REQUIRE_SPELLCHECK "Abort if no spellchecker available" OFF ALL) LYX_OPTION(ASPELL "Require aspell" OFF ALL) LYX_OPTION(ENCHANT "Require Enchant" OFF ALL) LYX_OPTION(HUNSPELL "Require Hunspell" OFF ALL) @@ -540,20 +541,22 @@ endif() include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src) -if(LYX_ASPELL) - find_package(ASPELL REQUIRED) - 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) +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}") + 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() if(LYX_NLS) FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS ${GNUWIN32_DIR}/python) @@ -819,6 +822,15 @@ if(LYX_NLS) message(STATUS) endif() +if(NOT Spelling_FOUND) + if(LYX_REQUIRE_SPELLCHECK) + set(_mode "FATAL_ERROR") + else() + set(_mode "STATUS") + endif() + message(${_mode} "No spellcheck libraries found. Lyx will be unable use spellchecking") +endif() + include("${TOP_CMAKE_PATH}/LyxPackaging.cmake") if(ENABLE_DIST)