Easily add nginx to a CMake project.
include(FetchContent)
# Declare this repository as a dependency.
# Make sure not to name this "nginx" or it will conflict with the actual nginx dependency.
FetchContent_Declare(nginx-cmake
GIT_REPOSITORY https://github.com/hi5dev/nginx-cmake
GIT_TAG main)
# Append your auto/configure options to nginx_CONFIGURE_OPTS.
# For example, if you're building an nginx module, you might want to add something like this:
list(APPEND nginx_CONFIGURE_OPTS "--add-module=${CMAKE_CURRENT_SOURCE_DIR}/src")
# Optionally override the URL to the Git repository. This is the default:
set(nginx_URL https://github.com/nginx/nginx.git)
# Use the repository's git tags to specify which version of nginx to use. This is the default:
set(nginx_TAG release-1.23.2)
# Install rules are enabled by default.
set(nginx_INSTALL ON)
# By default all these components are installed.
# Setting nginx_INSTALL to OFF disables all of these as well.
set(nginx_INSTALL_CONFIG_FILES ON)
set(nginx_INSTALL_EXE ON)
set(nginx_INSTALL_MANPAGE ON)
# Clones this repository, then nginx, patches it for CMake, configures it, and makes it available
# for immediate use by CMake.
FetchContent_MakeAvailable(nginx-cmake)
This project includes nginx as a dependency using FetchContent. After cloning the repository, it
adds a script to the auto directory that generates a CMakeLists.txt
file at the same time
the Makefile
is generated. The file is generated by CMake using configure_file
. The template
can be found in this repository at auto/cmake/CMakeLists.txt.in.