Skip to content

cmake: allow disabling the web layer via BUILD_MODULE_WEBServer#1307

Closed
Fantu wants to merge 1 commit into
mickem:mainfrom
Fantu:webserver-build-flag
Closed

cmake: allow disabling the web layer via BUILD_MODULE_WEBServer#1307
Fantu wants to merge 1 commit into
mickem:mainfrom
Fantu:webserver-build-flag

Conversation

@Fantu
Copy link
Copy Markdown
Contributor

@Fantu Fantu commented Jun 3, 2026

Upstream always builds the Beast/mongoose HTTP backend library: libs/mongoose-cpp (nscp_mongoose) is added by the unconditional libs/* glob and installed by NSCP_MAKE_LIBRARY, the HTTP backend selector in dependencies.cmake runs and aborts when its mongoose default cannot find the Windows-only vendored source, and the mongoose wrapper test links nscp_mongoose. Disabling only the WEBServer module via the generic per-module flag (-DBUILD_MODULE_WEBServer=OFF) therefore still builds and
installs that library orphaned, still runs the backend selector and still
requires a backend.

Rather than add a new top-level option, reuse the existing per-module flag that LOAD_SECTIONS already declares for every module, so a single -DBUILD_MODULE_WEBServer=OFF turns off the whole web layer in one place (same flag name and spelling as every other module):

  • CMakeLists.txt: declare option(BUILD_MODULE_WEBServer ...) up front, before dependencies.cmake and the libs/* glob, so those early consumers
    see it (and its ON default). LOAD_SECTIONS' later option() call for the
    same name is then a no-op, and it keeps honouring the flag natively to
    skip the module itself - so modules/WEBServer/module.cmake needs no
    change.
  • CMakeLists.txt: skip libs/mongoose-cpp in the libs glob when it is OFF.
  • build/cmake/dependencies.cmake: run the HTTP backend selector only when
    it is ON, so a no-web build needs neither the vendored mongoose source nor Beast/OpenSSL and does not abort.
  • tests/CMakeLists.txt: gate the mongoose wrapper test, which links nscp_mongoose (no longer built).

With BUILD_MODULE_WEBServer=ON (the default) nothing changes: configure on Debian sid still selects the backend (e.g. beast) and adds the mongoose library as before. With -DBUILD_MODULE_WEBServer=OFF the backend
selector is skipped, no mongoose backend library is built, and the WEBServer module is reported as disabled - a build with no web/HTTP server at all (e.g. a stripped-down agent package).

Assisted-by: Claude Code (Opus 4.8)

Upstream always builds the Beast/mongoose HTTP backend library:
libs/mongoose-cpp (nscp_mongoose) is added by the unconditional libs/*
glob and installed by NSCP_MAKE_LIBRARY, the HTTP backend selector in
dependencies.cmake runs and aborts when its mongoose default cannot find
the Windows-only vendored source, and the mongoose wrapper test links
nscp_mongoose. Disabling only the WEBServer module via the generic
per-module flag (-DBUILD_MODULE_WEBServer=OFF) therefore still builds
and
installs that library orphaned, still runs the backend selector and
still
requires a backend.

Rather than add a new top-level option, reuse the existing per-module
flag that LOAD_SECTIONS already declares for every module, so a single
-DBUILD_MODULE_WEBServer=OFF turns off the whole web layer in one place
(same flag name and spelling as every other module):

- CMakeLists.txt: declare option(BUILD_MODULE_WEBServer ...) up front,
before dependencies.cmake and the libs/* glob, so those early
consumers
see it (and its ON default). LOAD_SECTIONS' later option() call for
the
  same name is then a no-op, and it keeps honouring the flag natively to
  skip the module itself - so modules/WEBServer/module.cmake needs no
  change.
- CMakeLists.txt: skip libs/mongoose-cpp in the libs glob when it is
OFF.
- build/cmake/dependencies.cmake: run the HTTP backend selector only
when
  it is ON, so a no-web build needs neither the vendored mongoose source
  nor Beast/OpenSSL and does not abort.
- tests/CMakeLists.txt: gate the mongoose wrapper test, which links
  nscp_mongoose (no longer built).

With BUILD_MODULE_WEBServer=ON (the default) nothing changes: configure
on Debian sid still selects the backend (e.g. beast) and adds the
mongoose library as before. With -DBUILD_MODULE_WEBServer=OFF the
backend
selector is skipped, no mongoose backend library is built, and the
WEBServer module is reported as disabled - a build with no web/HTTP
server at all (e.g. a stripped-down agent package).

Assisted-by: Claude Code (Opus 4.8)
Signed-off-by: Fabio Fantoni <fantonifabio@tiscali.it>
@mickem
Copy link
Copy Markdown
Owner

mickem commented Jun 4, 2026

I have been pondering this and I think the problem here is that we bring in "all libraries" as dependencies (instead of using the actual dependencies). So if we remove that this would likely "sort it self out"...

@mickem
Copy link
Copy Markdown
Owner

mickem commented Jun 4, 2026

Here is how that looks: https://github.com/mickem/nscp/pull/1308/changes

@Fantu Fantu closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants