Skip to content

Commit

Permalink
Merge pull request #278 from jfclere/master
Browse files Browse the repository at this point in the history
Add CMakeLists.txt and README.cmake
  • Loading branch information
icing authored Apr 3, 2024
2 parents 5889279 + 3753e22 commit abc6e25
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
87 changes: 87 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Read README.cmake before using this.

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(MOD_HTTP2 C)

INCLUDE(CheckCSourceCompiles)

IF(EXISTS "${NGHTTP2_LIBRARIES}")
MESSAGE(STATUS "have NGHTTP2_LIBRARIES")
MESSAGE(STATUS "NGHTTP2_LIBRARIES >${NGHTTP2_LIBRARIES}<")
SET(default_nghttp2_libraries "${NGHTTP2_LIBRARIES}")
ELSE()
SET(default_nghttp2_libraries "-lnghttp2")
ENDIF()

IF(EXISTS "${PROXY_LIBRARY}")
MESSAGE(STATUS "have PROXY_LIBRARY")
MESSAGE(STATUS "PROXY_LIBRARY >${PROXY_LIBRARY}<")
SET(default_proxy_libraries "${PROXY_LIBRARY}")
ENDIF()

CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
int main() {
ssize_t err= -1;
return 1;}" HAS_ssize_t)

INCLUDE_DIRECTORIES(${APR_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${APRUTIL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${APACHE_INCLUDE_DIR})

SET(mod_http2_extra_includes ${NGHTTP2_INCLUDE_DIR})
SET(mod_http2_extra_libs ${default_nghttp2_libraries})

SET(mod_http2_sources
mod_http2/h2_bucket_beam.c mod_http2/h2_bucket_eos.c
mod_http2/h2_c1.c mod_http2/h2_c1_io.c
mod_http2/h2_c2.c mod_http2/h2_c2_filter.c
mod_http2/h2_config.c mod_http2/h2_conn_ctx.c
mod_http2/h2_mplx.c mod_http2/h2_headers.c
mod_http2/h2_protocol.c mod_http2/h2_push.c
mod_http2/h2_request.c mod_http2/h2_session.c
mod_http2/h2_stream.c mod_http2/h2_switch.c
mod_http2/h2_util.c mod_http2/h2_workers.c
mod_http2/h2_ws.c
)


SET(mod_proxy_http2_extra_includes ${NGHTTP2_INCLUDE_DIR})
SET(mod_proxy_http2_extra_libs ${default_nghttp2_libraries} ${default_proxy_libraries})
SET(mod_proxy_http2_extra_sources
mod_http2/h2_proxy_session.c mod_http2/h2_proxy_util.c
)

ADD_LIBRARY(mod_http2 MODULE ${mod_http2_sources} mod_http2/mod_http2.c)
SET_TARGET_PROPERTIES(mod_http2 PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(mod_http2 PROPERTIES SUFFIX ".so")
IF(${HAS_ssize_t})
MESSAGE(STATUS "have ssize_t")
ELSE()
SET(mod_http2_extra_defines ssize_t=long)
SET_TARGET_PROPERTIES(mod_http2 PROPERTIES COMPILE_DEFINITIONS ${mod_http2_extra_defines})
ENDIF()
target_link_libraries(mod_http2 ${default_nghttp2_libraries} ${APACHE_LIBRARY} ${APRUTIL_LIBRARY} ${APR_LIBRARY})

ADD_LIBRARY(mod_proxy_http2 MODULE ${mod_proxy_http2_extra_sources} mod_http2/mod_proxy_http2.c)
SET_TARGET_PROPERTIES(mod_proxy_http2 PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(mod_proxy_http2 PROPERTIES SUFFIX ".so")
IF(${HAS_ssize_t})
MESSAGE(STATUS "have ssize_t")
ELSE()
SET(mod_proxy_http2_extra_defines ssize_t=long)
SET_TARGET_PROPERTIES(mod_proxy_http2 PROPERTIES COMPILE_DEFINITIONS ${mod_proxy_http2_extra_defines})
ENDIF()
target_link_libraries(mod_proxy_http2 ${mod_proxy_http2_extra_libs} ${APACHE_LIBRARY} ${APRUTIL_LIBRARY} ${APR_LIBRARY})
42 changes: 42 additions & 0 deletions README.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Experimental cmake-based build support for mod_h2 on Microsoft Windows

Prerequisites
-------------

The following tools must be in PATH:

* cmake, version 2.8 or later
* compiler and linker and related tools

The following support libraries are mandatory:
* APR and APR_UTIL built using cmake
* nghttp2 built using cmake
* httpd built using cmake (Read the README.cmake there).

How to build
------------

1. cd to a clean directory for building (i.e., don't build in your
source tree)

2. Make sure cmake and build environment are in PATH and set the platform (call vcvars64 for example).

3. cmake -G "some backend, like "'Visual Studio 17 2022'"
-DAPR_INCLUDE_DIR=/path/to/aprinst/include/
-DAPRUTIL_INCLUDE_DIR=/path/to/aprutilinst/include/
-DAPACHE_INCLUDE_DIR=/path/to/httpdinst/include/
-DAPR_LIBRARY=/path/to/aprinst/lib/libapr-1.lib
-DAPRUTIL_LIBRARY=/path/to/aprutilinst/lib/libaprutil-1.lib
-DAPACHE_LIBRARY=/path/to/httpdinst/lib/libhttpd.lib
-DPROXY_LIBRARY=/path/to/httpdinst/lib/mod_proxy.lib
-DNGHTTP2_LIBRARIES=/path/to/nghttp2inst/lib/nghttp2.lib
-DNGHTTP2_INCLUDE_DIR=/path/to/nghttp2inst/include/
path/to/mod_h2sources
4. Build using the chosen generator (e.g., "MSBuild ALL_BUILD.vcxproj -t:build -p:Configuration=Release"
for cmake's "Visual Studio 17 2022" generator).
5. copy the *.so files from Release to /path/to/httpdinst/modules
Note: The apachelounge distribution doesn't contain nghttp2.h.
Use cmake from nghttp2 to build the library and copy the include file.

0 comments on commit abc6e25

Please sign in to comment.