Auto C and C++ Makfile Generator Extension
AutoCMakefileGenerator generates can generate a Makefile as well as a simple Debugging Setup for C and C++ automatically based on a small configuration json file.
Features
The extension adds a new command to your VSCode that allows you to automatically generate a very basic Makefile for your C and C++ Applications, just based on a small bit of json you have to provide. It can also generate a simple debugging setup in VSCode.
- Create a 'autoMakefile.json' in your workspace root directory.
- Add all the necessary information:
- unix: What type of operating system you are using | Boolean: true meaning MacOS or Linux - false meaning Windows
- lang: The language of your application | 'c' or 'cpp'
- name: The name of your output file, which will be created in the root directory | any valid filename as string
- flags: The compiler flags you want to attach to the compiler call | an array of any compiler flag without the -
- output: The path of the directory where all the .o files will be stored. If the given directory does not exist it will be created. | any valid directory path as string
- libs: The paths to any valid libraries you want to attach to the compiler call. | an array of any valid paths to external libraries
- dirs: All the paths to directories which contain source code eiter directly or in a subdirecotry | an array of any valid directory names
- Run the 'Generate Makefile'-Command by pressing Crtl + Shift + P (Cmd + Shift + P on Mac).
- If everything is correct there should be Makefile generated in your project root directory.
- Run 'make' in your terminal to compile all your specified source code into a single file also in your project root directory.
- 'make clean' removes all .o and output files.
- To generate the Debugging Setup run the 'Enable Debugging'-Command by pressing Crtl + Shift + P (Cmd + Shift + P on Mac) For this to work there must already be an autoMakefile.json and you have to set the '-g' compiler flag.
- A '.vscode' Folder should have been created in your root directory, containing a 'launch.json' and a 'tasks.json'.
- The Debugging should now be startable by going to the 'Run and Debug'-Tab in VSCode.
Example Config JSON
{
"unix": true,
"name": "nameOfOutputFile",
"flags": [
"Wall",
"I./dependencies/include",
"std=c++20",
"g"
],
"output": "nameOfOutputFolder",
"libs": [
"dependencies/libraries/anyLibrary.o",
"dependencies/libraries/anotherLibrary.dylib"
],
"dirs": [
"src"
]
}
Known Issues
This Extension is only tested for MacOS and Windows, but should also work on Linux. Windows is supported since version 2.0.0. It is also only tested in single folder workspaces.
Release Notes
1.0.1
Initial release of AutoCMakefileGenerator
1.0.2
Minor Bug Fixes
1.0.3
Fixed CPP Makefile Template
1.0.4
Added CPP Library Support and Compiler Flag Config Option
1.0.5
Improved Library Support
1.0.6
Added Debugging Setup Command
1.0.7
Minor Bug Fixes
2.0.0
Added Support for Windows via "unix"-flag in config file
2.0.1
Minor Bug Fixes
2.0.2
Fixed Clean Command Bug