I and Gagan was trying to make program in CMake. We have done it in three ways.
The basic purpose of doing it in 3 ways was to familiar more with CMake.
First Method(Single cpp file)
I have created two files “test.cpp” and “CMakeLists.txt”
Syntax of cmake:-
project command gives the name to the project.
include_directories command will include the directories in the project.
Execute commands in the source directory.
./bin/hello #executable file(i.e hello) is in the bin directory.
First method is done.
In real world programming, in order to hide our algorithm we abstract our code by making set of files. It also provides reusability of code.
Second method(independent of first method)
In this, I have created four files overall. they are “hello.h”, “hello.cpp”, “test.cpp”, “CMakeLists.txt”.
means commenting the statement. You all might know.
In the third method there are three directories i.e. source directory and two subdirectories(sub and test). Sub directory contain the files “hello.cpp” and “hello.h”.
There is a file named “CMakeLists.txt” in each directory.
Executable file is in the test directory.