Skip to content
/ cnew Public

This project generates a template C project with CMake and Make build systems

License

Notifications You must be signed in to change notification settings

jgsn13/cnew

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CNew

This project generates a template C project with CMake and Make build systems. It provides a quick and easy way to scaffold a new C project with a basic directory structure, build files, and a "Hello, world!" example.

Installing

You can install cnew to easily generate new C projects with CMake and Make build systems by running the following command:

cargo install --git https://github.com/jgsn13/cnew

This will download and install the cnew binary to your system's PATH (usually ~/.cargo/bin).

Note: This requires Rust and Cargo to be installed beforehand. You can install them from the official website: https://www.rust-lang.org/tools/install.

Usage

After installing cnew, you can generate a new C project by running the following command in your terminal:

cnew project_name

Replace project_name with the desired name for your new project. This will create a new directory with the specified name and populate it with the template project files.

Project Structure (Generated Project)

The generated project has the following directory structure:


project\_name/
├── CMakeLists.txt
├── src/
│   └── main.c
├── Makefile
├── README.md
└── .gitignore

  • CMakeLists.txt: Configures the CMake build system for your project.
  • src/: Contains all source code files, currently just main.c.
  • Makefile: Defines build targets for compiling, running, cleaning, and testing.
  • README.md: This file provides information about the generated project.
  • .gitignore: Specifies files to be ignored by Git version control.

Building (Generated Project)

The generated project uses CMake and Make for building. You'll need these tools installed on your system.

  1. Navigate to the generated project directory:
cd project_name
  1. Build the project:
make

This will create the executable file named project_name in the current directory.

Running (Generated Project)

  1. Run the built executable:
./project_name

This will print "Hello, world!" to the console.

Testing (Compile, Run and Clean) (Generated Project)

A convenient target is available to compile, run, and clean the project in one go:

make test

Cleaning (Generated Project)

Clean the project and remove any generated files:

make clean

License

GNU AFFERO GENERAL PUBLIC LICENSE

Authors