C++ code based on the amazing playlist by The Cherno structured with CMake.
Check if CMake is installed in your system by running
cmake --version
in the Terminal. Install it if it is not installed. This build currently requires a minimum CMake version of 3.22 but you can try changing that in the root CMakeLists.txt file and verify if your code compiles if you face any issues because of that.
Header files for functions have been stored in sample-library in the include directory and their definitions are stored in the src directory. The main file lies in the examples directory.
The CMakeLists.txt of the src directory should be updated when new function definitions are created.
- Install the CMake extension by twxs and the CMake Tools extension by Microsoft.
- Open Command Palette and select CMake: Scan for kits. CMake should automatically configure your project now and once its done you can simply click the triangular play button at the bottom of the IDE to run your code.
Open a new Terminal in the root folder of the project and do the following:
- Create a new directory called 'build' to store your build files and change your directory from the root directory to the build directory.
mkdir build && cd build
- Use CMake and Make to build your project from the build directory
cmake ..
make
- Run the main executable from the build directory
./examples/main