1*ec63e07aSXin Li# Copyright 2022 Google LLC 2*ec63e07aSXin Li# 3*ec63e07aSXin Li# Licensed under the Apache License, Version 2.0 (the "License"); 4*ec63e07aSXin Li# you may not use this file except in compliance with the License. 5*ec63e07aSXin Li# You may obtain a copy of the License at 6*ec63e07aSXin Li# 7*ec63e07aSXin Li# https://www.apache.org/licenses/LICENSE-2.0 8*ec63e07aSXin Li# 9*ec63e07aSXin Li# Unless required by applicable law or agreed to in writing, software 10*ec63e07aSXin Li# distributed under the License is distributed on an "AS IS" BASIS, 11*ec63e07aSXin Li# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*ec63e07aSXin Li# See the License for the specific language governing permissions and 13*ec63e07aSXin Li# limitations under the License. 14*ec63e07aSXin Li 15*ec63e07aSXin Licmake_minimum_required(VERSION 3.13..3.26) 16*ec63e07aSXin Li 17*ec63e07aSXin Liproject(sapi_hunspell CXX) 18*ec63e07aSXin Liinclude(CTest) 19*ec63e07aSXin Liinclude(GoogleTest) 20*ec63e07aSXin Li 21*ec63e07aSXin Liset(CMAKE_CXX_STANDARD 17) 22*ec63e07aSXin Liset(CMAKE_CXX_STANDARD_REQUIRED True) 23*ec63e07aSXin Li 24*ec63e07aSXin Liif(NOT TARGET sapi::sapi) 25*ec63e07aSXin Li set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree") 26*ec63e07aSXin Li add_subdirectory("${SAPI_ROOT}" 27*ec63e07aSXin Li "${CMAKE_BINARY_DIR}/sandboxed-api-build" 28*ec63e07aSXin Li EXCLUDE_FROM_ALL) 29*ec63e07aSXin Liendif() 30*ec63e07aSXin Li 31*ec63e07aSXin LiFetchContent_Declare(libhunspell 32*ec63e07aSXin Li GIT_REPOSITORY https://github.com/hunspell/hunspell.git 33*ec63e07aSXin Li GIT_TAG 31e6d6323026a3bef12c5912ce032d88bfef2091 # 2021-10-15 34*ec63e07aSXin Li) 35*ec63e07aSXin Li 36*ec63e07aSXin LiFetchContent_GetProperties(libhunspell) 37*ec63e07aSXin Liif(NOT libhunspell_POPULATED) 38*ec63e07aSXin Li FetchContent_Populate(libhunspell) 39*ec63e07aSXin Li set(libhunspell_STATUS_FILE "${libhunspell_SOURCE_DIR}/config.status") 40*ec63e07aSXin Li if(EXISTS "${libhunspell_STATUS_FILE}") 41*ec63e07aSXin Li file(SHA256 "${libhunspell_STATUS_FILE}" _sapi_CONFIG_STATUS) 42*ec63e07aSXin Li endif() 43*ec63e07aSXin Li if(NOT _sapi_CONFIG_STATUS STREQUAL "${libhunspell_CONFIG_STATUS}") 44*ec63e07aSXin Li message("-- Configuring libhunspell...") 45*ec63e07aSXin Li execute_process( 46*ec63e07aSXin Li COMMAND autoreconf -i 47*ec63e07aSXin Li WORKING_DIRECTORY "${libhunspell_SOURCE_DIR}" 48*ec63e07aSXin Li RESULT_VARIABLE _sapi_libhunspell_autoreconf_result 49*ec63e07aSXin Li ) 50*ec63e07aSXin Li if(NOT _sapi_libhunspell_autoreconf_result EQUAL "0") 51*ec63e07aSXin Li message(FATAL_ERROR "Configuration for libhunspell failed: " 52*ec63e07aSXin Li "${_sapi_libhunspell_autoreconf_result}") 53*ec63e07aSXin Li endif() 54*ec63e07aSXin Li execute_process( 55*ec63e07aSXin Li COMMAND ./configure --disable-dependency-tracking 56*ec63e07aSXin Li --quiet 57*ec63e07aSXin Li WORKING_DIRECTORY "${libhunspell_SOURCE_DIR}" 58*ec63e07aSXin Li RESULT_VARIABLE _sapi_libhunspell_config_result 59*ec63e07aSXin Li ) 60*ec63e07aSXin Li if(NOT _sapi_libhunspell_config_result EQUAL "0") 61*ec63e07aSXin Li message(FATAL_ERROR "Configuration for libhunspell failed: " 62*ec63e07aSXin Li "${_sapi_libhunspell_config_result}") 63*ec63e07aSXin Li endif() 64*ec63e07aSXin Li file(SHA256 "${libhunspell_SOURCE_DIR}/config.status" _sapi_CONFIG_STATUS) 65*ec63e07aSXin Li set(libhunspell_CONFIG_STATUS "${_sapi_CONFIG_STATUS}" CACHE INTERNAL "") 66*ec63e07aSXin Li endif() 67*ec63e07aSXin Liendif() 68*ec63e07aSXin Li 69*ec63e07aSXin Liadd_library(hunspell STATIC 70*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/affentry.cxx" 71*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/affentry.hxx" 72*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/affixmgr.cxx" 73*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/affixmgr.hxx" 74*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/atypes.hxx" 75*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/baseaffix.hxx" 76*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/csutil.cxx" 77*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/csutil.hxx" 78*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/filemgr.cxx" 79*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/filemgr.hxx" 80*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hashmgr.cxx" 81*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hashmgr.hxx" 82*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/htypes.hxx" 83*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hunspell.cxx" 84*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hunspell.h" 85*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hunspell.hxx" 86*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hunzip.cxx" 87*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/hunzip.hxx" 88*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/langnum.hxx" 89*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/phonet.cxx" 90*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/phonet.hxx" 91*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/replist.cxx" 92*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/replist.hxx" 93*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/suggestmgr.cxx" 94*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/suggestmgr.hxx" 95*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/utf_info.hxx" 96*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell/w_char.hxx" 97*ec63e07aSXin Li) 98*ec63e07aSXin Li 99*ec63e07aSXin Litarget_include_directories(hunspell PUBLIC 100*ec63e07aSXin Li "${libhunspell_SOURCE_DIR}/src/hunspell" 101*ec63e07aSXin Li) 102*ec63e07aSXin Li 103*ec63e07aSXin Liset(libhunspell_INCLUDE_DIR "${libhunspell_SOURCE_DIR}/src/hunspell") 104*ec63e07aSXin Li 105*ec63e07aSXin Liadd_sapi_library(sapi_hunspell 106*ec63e07aSXin Li FUNCTIONS Hunspell_create 107*ec63e07aSXin Li Hunspell_create_key 108*ec63e07aSXin Li Hunspell_destroy 109*ec63e07aSXin Li 110*ec63e07aSXin Li Hunspell_spell 111*ec63e07aSXin Li Hunspell_get_dic_encoding 112*ec63e07aSXin Li 113*ec63e07aSXin Li Hunspell_suggest 114*ec63e07aSXin Li Hunspell_analyze 115*ec63e07aSXin Li 116*ec63e07aSXin Li Hunspell_add 117*ec63e07aSXin Li Hunspell_remove 118*ec63e07aSXin Li 119*ec63e07aSXin Li Hunspell_free_list 120*ec63e07aSXin Li 121*ec63e07aSXin Li INPUTS "${libhunspell_INCLUDE_DIR}/hunspell.h" 122*ec63e07aSXin Li 123*ec63e07aSXin Li LIBRARY hunspell 124*ec63e07aSXin Li LIBRARY_NAME Hunspell 125*ec63e07aSXin Li NAMESPACE "" 126*ec63e07aSXin Li) 127*ec63e07aSXin Liadd_library(sapi_contrib::hunspell ALIAS sapi_hunspell) 128*ec63e07aSXin Litarget_include_directories(sapi_hunspell INTERFACE 129*ec63e07aSXin Li "${PROJECT_BINARY_DIR}" 130*ec63e07aSXin Li) 131*ec63e07aSXin Li 132*ec63e07aSXin Liif(SAPI_BUILD_EXAMPLES) 133*ec63e07aSXin Li add_subdirectory(example) 134*ec63e07aSXin Liendif() 135*ec63e07aSXin Li 136*ec63e07aSXin Liif(BUILD_TESTING AND SAPI_BUILD_TESTING) 137*ec63e07aSXin Li add_subdirectory(test) 138*ec63e07aSXin Liendif() 139