Skip to content
N0067HPublic

About

A C++ CLI for keeping a CMake project in sync with its source tree.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

cmsync

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.

Features

  • 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 add add_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> Add target_link_libraries(...) with PRIVATE, PUBLIC, or INTERFACE scope.
  • cmsync list Show the project from CMake's point of view, including targets and dependencies.
  • cmsync status Report untracked source files, missing registered files, and untracked directories.
  • cmsync sync Apply the pending source-tree changes back into CMakeLists.txt.

When multiple targets exist, add file can prompt for interactive target selection.

Build

cmake -S . -B build
cmake --build build

Run

./build/cmsync list

Install

cmake -S . -B build
cmake --build build
cmake --install build

If you want a user-local install without writing to /usr/local, use:

cmake --install build --prefix ~/.local

Example

cmsync 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 sync

C projects

cmsync init sample --lang c
cd sample
cmsync add exe server
cmsync add lib parser
cmsync add file src/token.c --target parser

C 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 cxx

Language 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.

About

A C++ CLI for keeping a CMake project in sync with its source tree.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages