cmsync is a C++ CLI for keeping a CMake project in sync with its source tree.
It automates common CMake maintenance tasks such as adding source files, creating new
targets, wiring subdirectories, and linking targets, while still producing a normal CMake
project that can be built without cmsync.
cmsync init [name] [--lang c|cxx]Create a minimal CMake project scaffold.cmsync add file <path> [--target <name>]Create a source file and register it in a target.cmsync add dir <path>Create a subdirectory and addadd_subdirectory(...)to the parent project.cmsync add exe <name> [--lang c|cxx]Create a new executable target scaffold.cmsync add lib <name> [--lang c|cxx]Create a new library target scaffold.cmsync link <target> <dependency>Addtarget_link_libraries(...)withPRIVATE,PUBLIC, orINTERFACEscope.cmsync listShow the project from CMake's point of view, including targets and dependencies.cmsync statusReport untracked source files, missing registered files, and untracked directories.cmsync syncApply the pending source-tree changes back intoCMakeLists.txt.
When multiple targets exist, add file can prompt for interactive target selection.
cmake -S . -B build
cmake --build build./build/cmsync listcmake -S . -B build
cmake --build build
cmake --install buildIf you want a user-local install without writing to /usr/local, use:
cmake --install build --prefix ~/.localcmsync init sample
cd sample
cmsync add exe editor
cmsync add lib renderer
cmsync link editor renderer --public
cmsync add file src/extra.cpp
cmsync list
cmsync status
cmsync synccmsync init sample --lang c
cd sample
cmsync add exe server
cmsync add lib parser
cmsync add file src/token.c --target parserC projects use C17, .c sources, and .h headers. Generated C library headers
include C++ linkage guards. C++ remains the default for new projects and uses C++20.
New targets inherit the language of a single-language project. For projects with both C and C++ enabled, select the target language explicitly:
cmsync add lib parser --lang c
cmsync add exe editor --lang cxxLanguage detection supports literal project(... LANGUAGES ...) and
enable_language(...) declarations in the current CMakeLists.txt. A project()
without LANGUAGES is treated as enabling both C and C++. For configurations using
variables, included files, or conditional language declarations, check the enabled
languages manually; cmsync does not evaluate CMake code.
If the requested language is not detected as enabled, cmsync stops before creating
the target. Enable it in project(... LANGUAGES C CXX) or with
enable_language(C) / enable_language(CXX), then retry. Existing CMake language
settings are not rewritten automatically. File registration, status, and sync
already recognize .c sources alongside C++ sources.