Repository navigation
setup utilities: added cth_add_subdirectory - #7
Merged
Merged
Conversation
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
force-pushed
the
feat/cth-add-subdirectory
branch
from
October 18, 2026 14:10
b874984 to
010ffb1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cth_add_subdirectory(<dir> [<option> [<default>]]): adds a subdirectory behind an option. A parent project turns parts of a library off withset(<option> OFF)beforeadd_subdirectory(<library>)(CMP0077).if():ON,OFFor a variable name likeWIN32. An undefined variable is OFF; passing${WIN32}would drop the argument off windows and leave the default ON.cth_create_package(): the<project>_packagetarget is part ofallonly in the top level project. A parent project that adds a cth_cmake project withadd_subdirectory()installed it into its ownCMAKE_INSTALL_PREFIXon every build.Needed for cth components as options (
CTH_BUILD_OS,CTH_BUILD_CORO,CTH_BUILD_NET,CTH_BUILD_WINwith defaultWIN32), so cth_engine can add cth from a submodule without building coro and net.Test plan
set(<option> OFF)do notadd_subdirectory(lib/cth): no install on build, 273/273 on gcc and clang debug/release