Skip to content
This repository was archived by the owner on Jun 9, 2026. It is now read-only.

Commit 8b7025c

Browse files
authored
Merge pull request #169 from Karm/cmake-windows
Adds CMake Windows build, removes mpm_winnt.h include from mod_md_os.c
2 parents 6fe5f36 + 1d6d6fa commit 8b7025c

7 files changed

Lines changed: 288 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ src/a2md
4545
/test/unit/main
4646
wiki
4747
test/conf/std_vhosts.conf
48+
build/

CMakeLists.txt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2020 Contributors to mod_md project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
PROJECT(mod_md C)
16+
CMAKE_MINIMUM_REQUIRED(VERSION 3.14)
17+
18+
INCLUDE(CheckSymbolExists)
19+
20+
IF(WIN32)
21+
SET(CMAKE_C_FLAGS "/O2 /MD /W3 /Zi")
22+
# TODO: Questionable...people might want to override -DCMAKE_C_FLAGS_DEBUG="..."
23+
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS}")
24+
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}")
25+
ELSE()
26+
27+
ENDIF()
28+
29+
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
30+
31+
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/modules)
32+
33+
FIND_PACKAGE(OpenSSL REQUIRED)
34+
FIND_PACKAGE(CURL REQUIRED)
35+
FIND_PACKAGE(JANSSON REQUIRED)
36+
FIND_PACKAGE(APACHE REQUIRED)
37+
FIND_PACKAGE(APR REQUIRED)
38+
39+
INCLUDE_DIRECTORIES(${APR_INCLUDE_DIR})
40+
INCLUDE_DIRECTORIES(${APRUTIL_INCLUDE_DIR})
41+
INCLUDE_DIRECTORIES(${APACHE_INCLUDE_DIR})
42+
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
43+
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
44+
INCLUDE_DIRECTORIES(${JANSSON_INCLUDE_DIR})
45+
46+
AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src SRC_LIST)
47+
ADD_LIBRARY(mod_md MODULE ${SRC_LIST})
48+
SET_TARGET_PROPERTIES(mod_md PROPERTIES PREFIX "")
49+
SET_TARGET_PROPERTIES(mod_md PROPERTIES SUFFIX ".so")
50+
51+
TARGET_LINK_LIBRARIES(mod_md ${APR_LIBRARIES} ${APRUTIL_LIBRARIES} ${APACHE_LIBRARY} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
52+
53+
MESSAGE(STATUS "")
54+
MESSAGE(STATUS "")
55+
MESSAGE(STATUS "mod_md configuration summary:")
56+
MESSAGE(STATUS "")
57+
MESSAGE(STATUS " Build type ...................... : ${CMAKE_BUILD_TYPE}")
58+
MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
59+
MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
60+
MESSAGE(STATUS " APR include directory ........... : ${APR_INCLUDE_DIR}")
61+
MESSAGE(STATUS " APR libraries ................... : ${APR_LIBRARIES}")
62+
MESSAGE(STATUS " APR Util include directory ...... : ${APRUTIL_INCLUDE_DIR}")
63+
MESSAGE(STATUS " APR Util libraries .............. : ${APRUTIL_LIBRARIES}")
64+
MESSAGE(STATUS " OpenSSL include directory ....... : ${OPENSSL_INCLUDE_DIR}")
65+
MESSAGE(STATUS " OpenSSL libraries ............... : ${OPENSSL_LIBRARIES}")
66+
MESSAGE(STATUS " Curl include directory........... : ${CURL_INCLUDE_DIR}")
67+
MESSAGE(STATUS " Curl libraries................... : ${CURL_LIBRARIES}")
68+
MESSAGE(STATUS " Jansson include directory.........: ${JANSSON_INCLUDE_DIR}")
69+
MESSAGE(STATUS " Jansson libraries ............... : ${JANSSON_LIBRARIES}")
70+
MESSAGE(STATUS "")

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,29 @@ and restart ```httpd```.
720720

721721
[@nono303](https://github.com/nono303) has builds available at his [github repository](https://github.com/nono303/mod_md).
722722

723+
You can also build your own mod_md on Windows. Requirements: APR/APR Util (as likely comes with your httpd distro), OpenSSL, Curl, Jansson, Apache HTTP Server, CMake installation, Visual Studio installation. The undermentioned example is intended for development and debugging. Production build should be done in the context of httpd build, exactly with the libraries your httpd uses.
724+
725+
726+
```
727+
mkdir build
728+
cd build
729+
vcvars64
730+
cmake -G "NMake Makefiles"
731+
-DOPENSSL_ROOT_DIR=C:/Users/Administrator/source/openssl/target/
732+
-DCURL_LIBRARY=C:/Users/Administrator/source/curl-build/lib/libcurl_imp.lib
733+
-DCURL_INCLUDE_DIR=C:/Users/Administrator/source/curl-build/include
734+
-DAPACHE_ROOT_DIR=C:/Users/Administrator/source/Apache24/
735+
-DAPR_ROOT_DIR=C:/Users/Administrator/source/Apache24/
736+
-DAPRUTIL_ROOT_DIR=C:/Users/Administrator/source/Apache24/
737+
-DJANSSON_ROOT_DIR=C:/Users/Administrator/source/jansson/build
738+
-DCMAKE_BUILD_TYPE=Release ..
739+
740+
nmake
741+
742+
dir modules\
743+
mod_md.exp mod_md.lib mod_md.so* mod_md.so.manifest
744+
```
745+
723746
## Fedora
724747

725748
The plan in Fedora is to include v2.x of mod_md with Fedora 31, which is due to be released end of summer 2019.

cmake/modules/FindAPACHE.cmake

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2020 Contributors to mod_md project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# One must set a hint: APACHE_ROOT_DIR
16+
# Module defines
17+
# APACHE_FOUND - System has APACHE
18+
# APACHE_INCLUDE_DIR - The APACHE include directory
19+
# APACHE_LIBRARIES - Library
20+
# Defined:
21+
# APACHE_LIBRARY - httpd lib
22+
23+
IF(NOT APACHE_ROOT_DIR)
24+
message(FATAL_ERROR "APACHE_ROOT_DIR is not set. We don't know where to look for APACHE, quitting.")
25+
ENDIF()
26+
FIND_PATH(APACHE_INCLUDE_DIR httpd.h
27+
"${APACHE_ROOT_DIR}/include"
28+
)
29+
SET(APACHE_NAMES ${APACHE_NAMES} httpd libhttpd)
30+
FIND_LIBRARY(APACHE_LIBRARY NAMES ${APACHE_NAMES} PATHS "${APACHE_ROOT_DIR}/lib" "${APACHE_ROOT_DIR}/lib64")
31+
IF (APACHE_LIBRARY AND APACHE_INCLUDE_DIR)
32+
SET(APACHE_LIBRARIES ${APACHE_LIBRARY})
33+
SET(APACHE_FOUND "YES")
34+
ELSE (APACHE_LIBRARY AND APACHE_INCLUDE_DIR)
35+
SET(APACHE_FOUND "NO")
36+
ENDIF (APACHE_LIBRARY AND APACHE_INCLUDE_DIR)
37+
38+
IF (APACHE_FOUND)
39+
IF (NOT APACHE_FIND_QUIETLY)
40+
MESSAGE(STATUS "Found APACHE: ${APACHE_LIBRARIES}")
41+
ENDIF (NOT APACHE_FIND_QUIETLY)
42+
ELSE (APACHE_FOUND)
43+
IF (APACHE_FIND_REQUIRED)
44+
MESSAGE(FATAL_ERROR "Could not find APACHE library")
45+
ENDIF (APACHE_FIND_REQUIRED)
46+
ENDIF (APACHE_FOUND)
47+
48+
MARK_AS_ADVANCED(
49+
APACHE_LIBRARY
50+
APACHE_INCLUDE_DIR
51+
)

cmake/modules/FindAPR.cmake

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright 2020 Contributors to mod_md project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# One must set a hint: APR_ROOT_DIR, APRUTIL_ROOT_DIR
16+
# Find the APR includes and libraries
17+
# Module defines
18+
# APR_INCLUDE_DIR and APRUTIL_INCLUDE_DIR, apr.h, etc.
19+
# APR_LIBRARIES and APRUTIL_LIBRARIES, libs needed to use APR.
20+
# APR_FOUND and APRUTIL_FOUND, whether APR usable.
21+
# Defined:
22+
# APR_LIBRARY and APRUTIL_LIBRARY, where to find the APR library.
23+
24+
IF(NOT APR_ROOT_DIR)
25+
message(FATAL_ERROR "APR_ROOT_DIR is not set. We don't know where to look for APR, quitting.")
26+
ENDIF()
27+
28+
IF(NOT APRUTIL_ROOT_DIR)
29+
message(FATAL_ERROR "APR_ROOT_DIR is not set. We don't know where to look for APR, quitting.")
30+
ENDIF()
31+
32+
FIND_PATH(APR_INCLUDE_DIR apr.h
33+
"${APR_ROOT_DIR}/include"
34+
)
35+
SET(APR_NAMES ${APR_NAMES} libapr-1 apr-1)
36+
FIND_LIBRARY(APR_LIBRARY NAMES ${APR_NAMES} PATHS "${APR_ROOT_DIR}/lib" "${APR_ROOT_DIR}/lib64")
37+
IF (APR_LIBRARY AND APR_INCLUDE_DIR)
38+
SET(APR_LIBRARIES ${APR_LIBRARY})
39+
SET(APR_FOUND "YES")
40+
ELSE (APR_LIBRARY AND APR_INCLUDE_DIR)
41+
SET(APR_FOUND "NO")
42+
ENDIF (APR_LIBRARY AND APR_INCLUDE_DIR)
43+
44+
IF (APR_FOUND)
45+
IF (NOT APR_FIND_QUIETLY)
46+
MESSAGE(STATUS "Found APR: ${APR_LIBRARIES}")
47+
ENDIF (NOT APR_FIND_QUIETLY)
48+
ELSE (APR_FOUND)
49+
IF (APR_FIND_REQUIRED)
50+
MESSAGE(FATAL_ERROR "Could not find APR library")
51+
ENDIF (APR_FIND_REQUIRED)
52+
ENDIF (APR_FOUND)
53+
54+
MARK_AS_ADVANCED(
55+
APR_LIBRARY
56+
APR_INCLUDE_DIR
57+
)
58+
59+
# APR Util
60+
FIND_PATH(APRUTIL_INCLUDE_DIR apu.h
61+
"${APRUTIL_ROOT_DIR}/include"
62+
)
63+
64+
SET(APRUTIL_NAMES ${APRUTIL_NAMES} libaprutil-1 aprutil-1)
65+
FIND_LIBRARY(APRUTIL_LIBRARY
66+
NAMES ${APRUTIL_NAMES}
67+
PATHS "${APRUTIL_ROOT_DIR}/lib" "${APRUTIL_ROOT_DIR}/lib64"
68+
)
69+
70+
IF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
71+
SET(APRUTIL_LIBRARIES ${APRUTIL_LIBRARY})
72+
SET(APRUTIL_FOUND "YES")
73+
ELSE (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
74+
SET(APRUTIL_FOUND "NO")
75+
ENDIF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
76+
77+
IF (APRUTIL_FOUND)
78+
IF (NOT APRUTIL_FIND_QUIETLY)
79+
MESSAGE(STATUS "Found APRUTIL: ${APRUTIL_LIBRARIES}")
80+
ENDIF (NOT APRUTIL_FIND_QUIETLY)
81+
ELSE (APRUTIL_FOUND)
82+
IF (APRUTIL_FIND_REQUIRED)
83+
MESSAGE(FATAL_ERROR "Could not find APRUTIL library")
84+
ENDIF (APRUTIL_FIND_REQUIRED)
85+
ENDIF (APRUTIL_FOUND)
86+
87+
MARK_AS_ADVANCED(
88+
APRUTIL_LIBRARY
89+
APRUTIL_INCLUDE_DIR
90+
)

cmake/modules/FindJANSSON.cmake

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2020 Contributors to mod_md project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# One must set a hint: JANSSON_ROOT_DIR
16+
# Once done this will define
17+
# JANSSON_FOUND
18+
# JANSSON_INCLUDE_DIRS
19+
# JANSSON_LIBRARIES
20+
21+
IF(NOT JANSSON_ROOT_DIR)
22+
message(FATAL_ERROR "JANSSON_ROOT_DIR is not set. We don't know where to look for JANSSON, quitting.")
23+
ENDIF()
24+
25+
26+
FIND_PATH(JANSSON_INCLUDE_DIR jansson.h
27+
"${JANSSON_ROOT_DIR}/include"
28+
)
29+
30+
SET(JANSSON_NAMES ${JANSSON_NAMES} jansson libjansson)
31+
FIND_LIBRARY(JANSSON_LIBRARY NAMES ${JANSSON_NAMES} PATHS "${JANSSON_ROOT_DIR}/lib" "${JANSSON_ROOT_DIR}/lib64")
32+
33+
IF (JANSSON_LIBRARY AND JANSSON_INCLUDE_DIR)
34+
SET(JANSSON_LIBRARIES ${JANSSON_LIBRARY})
35+
SET(JANSSON_FOUND "YES")
36+
ELSE (JANSSON_LIBRARY AND JANSSON_INCLUDE_DIR)
37+
SET(JANSSON_FOUND "NO")
38+
ENDIF (JANSSON_LIBRARY AND JANSSON_INCLUDE_DIR)
39+
40+
IF (JANSSON_FOUND)
41+
IF (NOT JANSSON_FIND_QUIETLY)
42+
MESSAGE(STATUS "Found JANSSON: ${JANSSON_LIBRARIES}")
43+
ENDIF (NOT JANSSON_FIND_QUIETLY)
44+
ELSE (JANSSON_FOUND)
45+
IF (JANSSON_FIND_REQUIRED)
46+
MESSAGE(FATAL_ERROR "Could not find JANSSON library")
47+
ENDIF (JANSSON_FIND_REQUIRED)
48+
ENDIF (JANSSON_FOUND)
49+
50+
MARK_AS_ADVANCED(
51+
JANSSON_LIBRARY
52+
JANSSON_INCLUDE_DIR
53+
)

src/mod_md_os.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
#if APR_HAVE_UNISTD_H
2626
#include <unistd.h>
2727
#endif
28-
#ifdef WIN32
29-
#include "mpm_winnt.h"
30-
#endif
3128
#if AP_NEED_SET_MUTEX_PERMS
3229
#include "unixd.h"
3330
#endif

0 commit comments

Comments
 (0)