1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
cmake_minimum_required(VERSION 3.18)
project(nuspell
VERSION 5.1.7
DESCRIPTION "Nuspell spellchecking library"
HOMEPAGE_URL https://nuspell.github.io/
LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
option(BUILD_SHARED_LIBS "Build as shared library" ON)
option(BUILD_TESTING "Build the testing tree." ON)
option(BUILD_TOOLS "Build the CLI tool." ON)
option(BUILD_DOCS "Build the docs." ON)
cmake_dependent_option(BUILD_MAN "Build man-pages." ON BUILD_DOCS OFF)
cmake_dependent_option(BUILD_API_DOCS "Build API docs." ON BUILD_DOCS OFF)
find_package(ICU 60 REQUIRED COMPONENTS uc data)
get_directory_property(subproject PARENT_DIRECTORY)
add_subdirectory(src/nuspell)
if (MSVC AND (BUILD_TOOLS OR BUILD_TESTING))
find_path(GETOPT_INCLUDE_DIR getopt.h REQUIRED)
find_library(GETOPT_LIBRARY getopt REQUIRED)
endif()
if (BUILD_TOOLS)
add_subdirectory(src/tools)
endif()
if (subproject)
# if added as subproject just build Nuspell
# no need to test, build docs or install
return()
endif()
if (BUILD_DOCS)
add_subdirectory(docs)
endif()
macro(fetch_catch2)
include(FetchContent)
FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG 3f0283de7a9c43200033da996ff9093be3ac84dc #v3.3.2
)
set(old_build_shared_libs ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
FetchContent_MakeAvailable(Catch2)
target_compile_features(Catch2 PRIVATE cxx_std_17)
set(BUILD_SHARED_LIBS ${old_build_shared_libs})
endmacro()
if (BUILD_TESTING)
enable_testing()
find_package(Catch2 3.1.1 QUIET)
if (NOT Catch2_FOUND)
fetch_catch2()
endif()
add_subdirectory(external/hunspell/hunspell)
add_subdirectory(tests)
endif()
configure_file(nuspell.pc.in nuspell.pc @ONLY)
#configure_file(NuspellConfig.cmake NuspellConfig.cmake COPYONLY)
write_basic_package_version_file(NuspellConfigVersion.cmake
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nuspell.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/NuspellConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/NuspellConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/nuspell)
install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
|