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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
cmake_minimum_required(VERSION 3.5)
project(swipl-http)
include("../cmake/PrologPackage.cmake")
if(MULTI_THREADED)
set(SWIPL_WITH_HTTP_SERVER ON)
endif()
if(NOT EMSCRIPTEN)
set(SWIPL_WITH_HTTP_CLIENT ON)
endif()
#
# HTTP SERVER CONFIG
#
if(SWIPL_WITH_HTTP_SERVER)
if(NOT DEFINED JQUERYDIR)
message("-- Searching for jQuery")
if(NOT CMAKE_CROSSCOMPILING)
set(JQUERYFILE jquery.min.js)
find_path(JQUERYDIR
${JQUERYFILE}
PATHS /usr/share/javascript/jquery
NO_DEFAULT_PATH)
# Deal with snap creation
string(REPLACE "-sdk/current/" "/current/" JQUERYDIR "${JQUERYDIR}")
endif()
if(JQUERYDIR AND EXISTS ${JQUERYDIR}/${JQUERYFILE})
message("-- Using system jQuery from ${JQUERYDIR}/${JQUERYFILE}")
else()
message("-- No system jquery.js; using our own")
set(JQUERYDIR web/js)
set(JQUERYFILE jquery-3.6.0.min.js)
endif()
set(JQUERYDIR ${JQUERYDIR} CACHE INTERNAL "Directory for jquery.js")
set(JQUERYFILE ${JQUERYFILE} CACHE INTERNAL "File for jquery.js")
endif()
configure_file(jquery.pl.in jquery.pl)
set(HTTP_PLATFORM_FILES)
if(UNIX)
set(HTTP_PLATFORM_FILES http_unix_daemon.pl)
endif()
set(HTTP_SERVER_PL_FILES
http_parameters.pl http_dispatch.pl http_authenticate.pl http_log.pl
http_hook.pl http_exception.pl http_wrapper.pl
http_dirindex.pl http_server_files.pl http_pwp.pl http_host.pl
http_cookie.pl http_files.pl
http_cors.pl yadis.pl ax.pl http_load.pl http_multipart_plugin.pl
http_digest.pl http_redis_plugin.pl graphql.pl http_openid.pl
thread_httpd.pl http_server.pl http_dyn_workers.pl http_session.pl
README.md ${HTTP_PLATFORM_FILES})
set(HTTP_EXAMPLE_FILES
README.md
demo_body.pl demo_client.pl demo_threads.pl
calc.pl demo_files.pl demo_pwp.pl demo_openid.pl
demo_daemon.pl upstart-script.conf systemd-script.service
linux-init-script demo_login.pl demo_rest.pl demo_hello.pl)
prepend(HTTP_EXAMPLE_FILES examples/ ${HTTP_EXAMPLE_FILES})
set(PWP_FILES
context.pwp index.pwp pwp1.pwp pwp2.pwp pwp3.pwp pwp4.pwp
pwp5.pwp pwp6.pwp pwp7.pwp pwp8.pwp pwpdb.pl)
prepend(PWP_FILES examples/pwp/ ${PWP_FILES})
set(ICONS back.png compressed.png c.png folder.png generic.png
layout.png openid-logo-square.png openid-logo-tiny.png)
prepend(ICONS web/icons/ ${ICONS})
endif(SWIPL_WITH_HTTP_SERVER)
configure_file(config.h.cmake config.h)
set(HTML_PL_FILES
html_write.pl html_quasiquotations.pl term_html.pl html_head.pl
http_path.pl mimetype.pl)
set(HTTP_CLIENT_PL_FILES
http_client.pl http_header.pl js_write.pl js_grammar.pl
http_sgml_plugin.pl mimepack.pl dcg_basics.pl
http_open.pl http_proxy.pl http_error.pl)
set(JSON_PL_FILES json.pl json_convert.pl)
if(SWIPL_WITH_HTTP_SERVER)
list(APPEND JSON_PL_FILES http_json.pl)
endif()
swipl_plugin(
html_libs
PL_LIB_SUBDIR http
PL_LIBS ${HTML_PL_FILES})
swipl_plugin(
json
C_SOURCES json.c
PL_LIB_SUBDIR http
PL_LIBS ${JSON_PL_FILES})
swipl_plugin(
http_stream
C_SOURCES http_stream.c THREADED
PL_LIB_SUBDIR http
PL_LIBS http_stream.pl)
test_libs(json)
test_libs(term_html
PACKAGES clib sgml http)
add_custom_target(http)
add_dependencies(http html_libs json http_stream)
if(SWIPL_WITH_HTTP_CLIENT)
swipl_plugin(
http_client_libs
PL_LIB_SUBDIR http
PL_LIBS ${HTTP_CLIENT_PL_FILES})
add_dependencies(http http_client_libs)
endif()
if(SWIPL_WITH_HTTP_SERVER)
swipl_plugin(
http_server_libs
PL_LIB_SUBDIR http
PL_LIBS ${HTTP_SERVER_PL_FILES})
swipl_plugin(
websocket
C_SOURCES websocket.c
PL_LIB_SUBDIR http
PL_LIBS websocket.pl hub.pl)
swipl_plugin(
http_css
PL_LIB_SUBDIR http/web/css
PL_LIBS web/css/dirindex.css web/css/openid.css)
swipl_plugin(
http_icons
PL_LIB_SUBDIR http/web/icons
PL_LIBS ${ICONS})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jquery.pl
DESTINATION ${SWIPL_INSTALL_LIBRARY}/http)
if(NOT IS_ABSOLUTE ${JQUERYDIR})
install_src(plugin_http_jquery
FILES ${JQUERYDIR}/${JQUERYFILE}
DESTINATION ${SWIPL_INSTALL_LIBRARY}/http/web/js)
endif()
add_dependencies(http http_server_libs websocket http_css http_icons)
swipl_examples(${HTTP_EXAMPLE_FILES})
swipl_examples(${PWP_FILES}
SUBDIR pwp)
test_libs(cgi_stream http multipart websocket graphql
PACKAGES clib sgml plunit ssl zlib
PARENT_LIB)
endif(SWIPL_WITH_HTTP_SERVER)
has_package(ssl HAVE_SSL_PACKAGE)
if(HAVE_SSL_PACKAGE)
set(doc_depends ssl)
endif()
if(SWIPL_WITH_HTTP_SERVER)
set(HTTP_SECTION_FILES
websocket.pl hub.pl)
endif()
set(HTTP_PLDOC_FILES
js_write.pl http_path.pl html_head.pl
http_open.pl mimepack.pl http_client.pl http_header.pl)
if(SWIPL_WITH_HTTP_SERVER)
set(HTTP_PLDOC_FILES ${HTTP_PLDOC_FILES}
http_log.pl http_dispatch.pl http_dirindex.pl http_digest.pl
http_session.pl http_openid.pl http_dyn_workers.pl http_pwp.pl
http_files.pl http_cors.pl http_authenticate.pl http_host.pl)
endif()
pkg_doc(http
LIBSUBDIR
http
SOURCES
json.md
SOURCE
post.md --lib=http/html_write
DEPENDS
${doc_depends}
SECTION
${HTTP_SECTION_FILES}
SUBSECTION
${HTTP_PLDOC_FILES}
SUBSUBSECTION
${HTTP_PLATFORM_FILES})
|