Skip to content

setup utilities: added cth_add_subdirectory - #7

Merged
codethinki merged 2 commits into
mainfrom
feat/cth-add-subdirectory
Oct 18, 2026
Merged

codethinki merged 2 commits into
mainfrom
feat/cth-add-subdirectory

Conversation

@codethinki

@codethinki codethinki commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • cth_add_subdirectory(<dir> [<option> [<default>]]): adds a subdirectory behind an option. A parent project turns parts of a library off with set(<option> OFF) before add_subdirectory(<library>) (CMP0077).
  • The default is evaluated with if(): ON, OFF or a variable name like WIN32. An undefined variable is OFF; passing ${WIN32} would drop the argument off windows and leave the default ON.
  • cth_create_package(): the <project>_package target is part of all only in the top level project. A parent project that adds a cth_cmake project with add_subdirectory() installed it into its own CMAKE_INSTALL_PREFIX on every build.

Needed for cth components as options (CTH_BUILD_OS, CTH_BUILD_CORO, CTH_BUILD_NET, CTH_BUILD_WIN with default WIN32), so cth_engine can add cth from a submodule without building coro and net.

Test plan

  • examples/basic: default ON and a true variable add the subdirectory, OFF, an undefined variable and set(<option> OFF) do not
  • forcing the options the other way fails the configure
  • cth with the options: all components (264 tests) and net/coro off (192 tests, package only has cth and os)
  • cth_engine with add_subdirectory(lib/cth): no install on build, 273/273 on gcc and clang debug/release
  • CI: Linux gcc/clang, Windows msvc/clang

cth_add_subdirectory(<dir> [<option> [<default>]]) adds a subdirectory behind an option, a parent
project turns parts of a library off with set(<option> OFF) before it adds the library. The default
is evaluated with if(): ON, OFF or a variable name like WIN32 (undefined -> OFF).
The basic example checks the defaults and the override.
…level project

A parent project that adds a cth_cmake project with add_subdirectory() installed it into its own
CMAKE_INSTALL_PREFIX on every build.
@codethinki
codethinki force-pushed the feat/cth-add-subdirectory branch from b874984 to 010ffb1 Compare October 18, 2026 14:10
@codethinki codethinki changed the title setup utilities: added cth_add_subdirectory and cth_check_msvc_stl setup utilities: added cth_add_subdirectory Oct 18, 2026
@codethinki
codethinki merged commit 09a6c5d into main Oct 18, 2026
6 checks passed
@codethinki
codethinki deleted the feat/cth-add-subdirectory branch October 18, 2026 14:15
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.

1 participant