Skip to content

Commit 2c23757

Browse files
committed
[http] let use external civetweb
With -Dbuiltin_civetweb=OFF one can try to find and build ROOT with exetrnal version of civetweb. But this external version should be compiled with websocket support - which is not alwys a case
1 parent be343a6 commit 2c23757

File tree

4 files changed

+68
-39
lines changed

4 files changed

+68
-39
lines changed

cmake/modules/RootBuildOptions.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ROOT_BUILD_OPTION(builtin_cfitsio OFF "Build CFITSIO internally (requires networ
8585
ROOT_BUILD_OPTION(builtin_clang ON "Build bundled copy of Clang")
8686
ROOT_BUILD_OPTION(builtin_cling ON "Build bundled copy of Cling. Only build with an external cling if you know what you are doing: associating ROOT commits with cling commits is tricky.")
8787
MARK_AS_ADVANCED(builtin_cling)
88+
ROOT_BUILD_OPTION(builtin_civetweb ON "Use civetweb distributed with ROOT")
8889
ROOT_BUILD_OPTION(builtin_cppzmq OFF "Use ZeroMQ C++ bindings installed by ROOT (requires network)")
8990
ROOT_BUILD_OPTION(builtin_davix OFF "Build Davix internally (requires network)")
9091
ROOT_BUILD_OPTION(builtin_fftw3 OFF "Build FFTW3 internally (requires network)")
@@ -278,6 +279,7 @@ endif()
278279
if(builtin_all)
279280
set(builtin_afterimage_defvalue ON)
280281
set(builtin_cfitsio_defvalue ON)
282+
set(builtin_civetweb_defvalue ON)
281283
set(builtin_clang_defvalue ON)
282284
set(builtin_cling_defvalue ON)
283285
set(builtin_cppzmq_defvalue ON)

cmake/modules/SearchInstalledSoftware.cmake

+15
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ if(builtin_nlohmannjson)
111111
add_subdirectory(builtins/nlohmann)
112112
endif()
113113

114+
#--- Check for civetweb ---------------------------------------------------------
115+
if(NOT builtin_civetweb)
116+
message(STATUS "Looking for civetweb")
117+
if(fail-on-missing)
118+
find_package(civetweb 1.15 REQUIRED)
119+
else()
120+
find_package(civetweb 1.15 QUIET)
121+
if(civetweb_FOUND)
122+
message(STATUS "Found civetweb version ${civetweb_VERSION}")
123+
else()
124+
message(STATUS "civetweb not found. Switching on builtin_civetweb option")
125+
set(builtin_civetweb ON CACHE BOOL "Enabled because civetweb not found" FORCE)
126+
endif()
127+
endif()
128+
endif()
114129

115130
#---Check for Unuran ------------------------------------------------------------------
116131
if(unuran AND NOT builtin_unuran)

net/http/CMakeLists.txt

+50-38
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ if(RT_LIBRARY)
1919
set(RT_LIBRARIES ${RT_LIBRARY})
2020
endif()
2121

22+
if(builtin_civetweb)
23+
set(_civetweb_src civetweb/civetweb.c)
24+
set(_civetweb_libs ${RT_LIBRARIES} )
25+
endif()
26+
2227
ROOT_STANDARD_LIBRARY_PACKAGE(RHTTP
2328
HEADERS
2429
THttpCallArg.h
@@ -42,62 +47,69 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RHTTP
4247
src/THttpWSHandler.cxx
4348
src/TRootSniffer.cxx
4449
src/TRootSnifferStore.cxx
45-
civetweb/civetweb.c
50+
${_civetweb_src}
4651
LIBRARIES
4752
ZLIB::ZLIB
48-
${RT_LIBRARIES}
53+
${_civetweb_libs}
4954
${FASTCGI_LIBRARY}
5055
${CMAKE_DL_LIBS}
5156
DEPENDENCIES
5257
RIO
5358
Thread
5459
)
5560

56-
if(ssl)
57-
target_include_directories(RHTTP SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
58-
endif()
61+
if(builtin_civetweb)
62+
target_include_directories(RHTTP PRIVATE ../civetweb)
5963

60-
if(FASTCGI_FOUND)
61-
target_include_directories(RHTTP PRIVATE ${FASTCGI_INCLUDE_DIR})
62-
endif()
64+
if(ssl)
65+
target_include_directories(RHTTP SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
66+
endif()
6367

64-
target_compile_definitions(RHTTP PRIVATE -DUSE_WEBSOCKET)
68+
target_compile_definitions(RHTTP PRIVATE -DUSE_WEBSOCKET)
6569

66-
if(NOT MSVC)
67-
target_compile_definitions(RHTTP PRIVATE -DUSE_X_DOM_SOCKET)
68-
endif()
70+
if(NOT MSVC)
71+
target_compile_definitions(RHTTP PRIVATE -DUSE_X_DOM_SOCKET)
72+
endif()
6973

70-
if(ssl)
71-
if(OPENSSL_VERSION)
72-
string(REPLACE "." ";" lst ${OPENSSL_VERSION})
73-
list(GET lst 0 ssl_major)
74-
list(GET lst 1 ssl_minor)
75-
endif()
74+
if(ssl)
75+
if(OPENSSL_VERSION)
76+
string(REPLACE "." ";" lst ${OPENSSL_VERSION})
77+
list(GET lst 0 ssl_major)
78+
list(GET lst 1 ssl_minor)
79+
endif()
7680

77-
if((${ssl_major} EQUAL "1") AND (${ssl_minor} EQUAL "1"))
78-
MESSAGE(STATUS "Use SSL API VERSION 1.1 for civetweb")
79-
target_compile_definitions(RHTTP PUBLIC -DOPENSSL_API_1_1)
80-
set(link_ssl ON)
81-
elseif((${ssl_major} EQUAL "3") AND ((${ssl_minor} EQUAL "0") OR (${ssl_minor} EQUAL "1")))
82-
MESSAGE(STATUS "Use SSL API VERSION 3.${ssl_minor} for civetweb")
83-
target_compile_definitions(RHTTP PUBLIC -DOPENSSL_API_3_0)
84-
set(link_ssl ON)
85-
elseif((${ssl_major} EQUAL "1") AND (${ssl_minor} EQUAL "0"))
86-
MESSAGE(STATUS "Use SSL API VERSION 1.0 for civetweb")
87-
target_compile_definitions(RHTTP PUBLIC -DOPENSSL_API_1_0)
88-
set(link_ssl ON)
81+
if((${ssl_major} EQUAL "1") AND (${ssl_minor} EQUAL "1"))
82+
MESSAGE(STATUS "Use SSL API VERSION 1.1 for civetweb")
83+
target_compile_definitions(RHTTP PUBLIC -DOPENSSL_API_1_1)
84+
set(link_ssl ON)
85+
elseif((${ssl_major} EQUAL "3") AND ((${ssl_minor} EQUAL "0") OR (${ssl_minor} EQUAL "1")))
86+
MESSAGE(STATUS "Use SSL API VERSION 3.${ssl_minor} for civetweb")
87+
target_compile_definitions(RHTTP PUBLIC -DOPENSSL_API_3_0)
88+
set(link_ssl ON)
89+
elseif((${ssl_major} EQUAL "1") AND (${ssl_minor} EQUAL "0"))
90+
MESSAGE(STATUS "Use SSL API VERSION 1.0 for civetweb")
91+
target_compile_definitions(RHTTP PUBLIC -DOPENSSL_API_1_0)
92+
set(link_ssl ON)
93+
else()
94+
MESSAGE(WARNING "Not able to recognize SSL version ${OPENSSL_VERSION}, disable SSL")
95+
target_compile_definitions(RHTTP PUBLIC -DNO_SSL)
96+
endif()
97+
if(link_ssl)
98+
target_compile_definitions(RHTTP PUBLIC -DNO_SSL_DL)
99+
target_link_libraries(RHTTP PRIVATE ${OPENSSL_LIBRARIES})
100+
endif()
89101
else()
90-
MESSAGE(WARNING "Not able to recognize SSL version ${OPENSSL_VERSION}, disable SSL")
91102
target_compile_definitions(RHTTP PUBLIC -DNO_SSL)
92103
endif()
93-
if(link_ssl)
94-
target_compile_definitions(RHTTP PUBLIC -DNO_SSL_DL)
95-
target_link_libraries(RHTTP PRIVATE ${OPENSSL_LIBRARIES})
96-
endif()
104+
97105
else()
98-
target_compile_definitions(RHTTP PUBLIC -DNO_SSL)
99-
endif()
106+
message(STATUS "Linking with ${civetweb_LIBRARIES} includes from ${civetweb_INCLUDE_DIR}")
107+
target_include_directories(RHTTP SYSTEM PRIVATE ${civetweb_INCLUDE_DIR})
108+
target_link_libraries(RHTTP PRIVATE ${civetweb_LIBRARIES})
109+
endif(builtin_civetweb)
100110

101-
if(NOT FASTCGI_FOUND)
111+
if(FASTCGI_FOUND)
112+
target_include_directories(RHTTP PRIVATE ${FASTCGI_INCLUDE_DIR})
113+
else()
102114
target_compile_definitions(RHTTP PUBLIC -DHTTP_WITHOUT_FASTCGI)
103115
endif()

net/http/src/TCivetweb.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <mutex>
1818

19-
#include "../civetweb/civetweb.h"
19+
#include "civetweb.h"
2020

2121
class TCivetweb : public THttpEngine {
2222
protected:

0 commit comments

Comments
 (0)