Debian Codegraph @

CMakeLists.txt

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