This project is meant to be a starting point, to quickly start working on a C++ program. This can be ether way, with or without using Nix.
There are some libraries that are by default available:
- boost
- spdlog
- yaml-cpp
- nlohmann_json
- protobuf
Like already mentioned, you have two ways to run the program.
(optional) You can use direnv to drop you instantly in a nix-shell session when opening the project folder Just run
direnv allow .
one time in the project after installingdirenv
.
Open the default.nix
file and edit project_name
to the name you want.
This is also the main file where you would at libraries, change the compiler version, etc.
You should of course still add the libraries that you added to your CMakeLists.txt
file.
To build the program, run:
nix-build
nix-build
will create a new symbolic link, containing a link the program.
To run the program:
./result/bin/<project_name>
You could also start a shell by running nix-shell
. This will create a shell that has links to all the
libraries/programs defined in default.nix
. From there it's also possible to compile the program yourself.
By doing this, you should set the
CMAKE_PROJECT_NAME
in theCMakeLists.txt
to the project name you want.
mkdir build && cd build
cmake ../src/. . && cmake --build .
If you are not using nix, you should first make sure that you have all the libraries and compilers you need.
You can change the project name by changing
CMAKE_PROJECT_NAME
in theCMakeLists.txt
.
After that you can just build the project manually:
mkdir build && cd build
cmake ../src/. . && cmake --build .