aboutsummaryrefslogtreecommitdiff
path: root/ports/hunspell/CMakeLists.txt
blob: 810c894f7706c31964ed93a739b0c0983808bfb4 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
cmake_minimum_required(VERSION 3.0)
project(hunspell)

#get hunspell version
file(STRINGS "configure.ac" CONFIGURE_AC_INIT REGEX "AC_INIT\\(\\[hunspell\\],\\[.*\\].*" )
string(REGEX REPLACE "AC_INIT\\(\\[.*\\],\\[([0-9]+\\.[0-9]+\\.[0-9]+)\\].*" "\\1"  VERSION ${CONFIGURE_AC_INIT})
message(STATUS "Hunspell version: ${VERSION}")

option(BUILD_SHARED_LIBS "Build shared libs" OFF)
option(ENABLE_NLS "Define if translation of program messages to the user's native language is requested" OFF)
option(HUNSPELL_WARNING_ON "Define if you need warning messages" OFF)

if(NOT BUILD_SHARED_LIBS)
    add_definitions(-DHUNSPELL_STATIC)
endif()

if(MSVC)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

include_directories("src/hunspell")
include_directories("src/parsers")

#libhunspell
set(LIBHUNSPELL_SRCS
    src/hunspell/affentry.cxx
    src/hunspell/affixmgr.cxx
    src/hunspell/csutil.cxx
    src/hunspell/hashmgr.cxx
    src/hunspell/hunspell.cxx
    src/hunspell/suggestmgr.cxx
    src/hunspell/phonet.cxx
    src/hunspell/filemgr.cxx
    src/hunspell/hunzip.cxx
    src/hunspell/replist.cxx
    src/hunspell/affentry.hxx
    src/hunspell/htypes.hxx
    src/hunspell/affixmgr.hxx
    src/hunspell/csutil.hxx
    src/hunspell/atypes.hxx
    src/hunspell/suggestmgr.hxx
    src/hunspell/baseaffix.hxx
    src/hunspell/hashmgr.hxx
    src/hunspell/langnum.hxx
    src/hunspell/phonet.hxx
    src/hunspell/filemgr.hxx
    src/hunspell/hunzip.hxx
    src/hunspell/replist.hxx
)

set(LIBHUNSPELL_HDRS
    src/hunspell/hunspell.hxx 
    src/hunspell/hunspell.h 
    src/hunspell/hunvisapi.h
    src/hunspell/w_char.hxx 
    src/hunspell/atypes.hxx 
    src/hunspell/csutil.hxx
    src/hunspell/htypes.hxx
)

#hunspell/libhunspell
add_library(libhunspell ${LIBHUNSPELL_HDRS} ${LIBHUNSPELL_SRCS})
target_compile_definitions(libhunspell PRIVATE -DBUILDING_LIBHUNSPELL)
install(TARGETS libhunspell
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
)

#parsers/libparsers
set(LIBPARSERS_SRCS
    src/parsers/firstparser.cxx
    src/parsers/xmlparser.cxx
    src/parsers/latexparser.cxx
    src/parsers/manparser.cxx
    src/parsers/textparser.cxx
    src/parsers/htmlparser.cxx
    src/parsers/odfparser.cxx
)
add_library(libparsers OBJECT ${LIBPARSERS_SRCS})

#parsers/testparser
set(TESTPARSER_SRCS
    src/parsers/firstparser.cxx
    src/parsers/firstparser.hxx
    src/parsers/xmlparser.cxx
    src/parsers/xmlparser.hxx
    src/parsers/latexparser.cxx
    src/parsers/latexparser.hxx
    src/parsers/manparser.cxx 
    src/parsers/manparser.hxx
    src/parsers/testparser.cxx
    src/parsers/textparser.cxx
    src/parsers/textparser.hxx
    src/parsers/htmlparser.cxx
    src/parsers/htmlparser.hxx
    src/parsers/odfparser.hxx
    src/parsers/odfparser.cxx
)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND CMAKE_BUILD_TYPE STREQUAL "Release" AND BUILD_TOOLS)
    add_executable(testparser ${TESTPARSER_SRCS})
    target_link_libraries(testparser libhunspell)

    #tools/analyze
    add_executable(analyze "src/tools/analyze.cxx")
    target_link_libraries(analyze libhunspell)

    #tools/chmorph
    add_executable(chmorph "src/tools/chmorph.cxx" $<TARGET_OBJECTS:libparsers>)
    target_link_libraries(chmorph libhunspell)

    #tools/hunspell
    include(CheckIncludeFile)
    check_include_file("curses.h" HAVE_CURSES_H)
    check_include_file("langinfo.h" HAVE_LANGINFO_CODESET)
    check_include_file("libintl.h" HAVE_LIBINTL_H)
    check_include_file("locale.h" HAVE_LOCALE_H)
    check_include_file("ncursesw/curses.h" HAVE_NCURSESW_H)
    check_include_file("unistd.h" HAVE_UNISTD_H)
    configure_file("config.h.in" "config.h")

    add_executable(hunspell "src/tools/hunspell.cxx" $<TARGET_OBJECTS:libparsers>)
    target_include_directories(hunspell PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
    target_link_libraries(hunspell libhunspell)

    #tools/munch
    add_executable(munch "src/tools/munch.cxx")

    #tools/unmunch
    add_executable(unmunch "src/tools/unmunch.cxx")

    #tools/hzip
    #add_executable(hzip "src/tools/hzip.cxx")
    #target_link_libraries(hzip libhunspell)

    #tools/hunzip
    add_executable(hunzip "src/tools/hunzip.cxx")
    target_link_libraries(hunzip libhunspell)

    install(
        TARGETS
            hunspell 
            testparser
            analyze
            chmorph
            munch
            unmunch
        #    hzip
            hunzip 
        DESTINATION tools/hunspell
    )
endif()

install(FILES ${LIBHUNSPELL_HDRS} DESTINATION "include/hunspell/")