Can someone help me write my first makefile?
I have a helloworld.cpp code in /path/to/main/code/helloworld.cpp.
And then I have just included a .h file #include "SFML/network.hpp".
Now SFML library is saved in /path/to/SFML/Library
It would be great if someone can help me getting started in this. In the mean time, I am trying to read thru the literature but its very overwhelming.
Although you may need to learn the traditional GNU Makefile syntax in order to work with other projects, I recommend using CMake for your own projects because it is simpler and more intuitive.
A CMake file for your example would go in a file called
CMakeLists.txtin the root directory of your project (same as the source in this case) and look like this:If you want to be able to #include headers from SFML without including the directory name every time, then you can also write:
Further documentation on writing CMake files and running CMake is available on the website.
Lastly, CMake often gives a noisy but harmless message requesting that you put a line like this at the top of your CMakeLists.txt file:
Cheers.