CMake Notes
Install CMake
Similar to Bazel, I need to first download the CMake. Download Page has the latest release candidate and stable version.
I chose to download the .sh file, which turns out would install the CMake at the directory where the shell scripts is executed...So afterwards, I decide to move the files to /usr/local/bin/cmake.
# similarly use wget to download the .sh file.
wget https://github.com/Kitware/CMake/releases/download/v3.26.0-rc6/cmake-3.26.0-rc6-linux-x86_64.sh
# run the shell file.
mv cmake-3.26.0-rc6-linux-x86_64.sh cmake-install.sh
chmod +x cmake-install.sh
./cmake-install.sh
# then move all installed directories, including doc, bin, etc, to /usr/local/bin/cmake
Again, I need to add /usr/loca/bin/cmake/bin into $PATH, so I similarly added it to my ./profile.d/.bashrc file.
Run CMake and Use CMake
Cmake turns out has their Mastering CMake book. Well, I am not planning to go deep into it, because I am not really a big fan of CMake. Mostly because I am big fan of Bazel. However, it seems that the industry has a heavy use of CMake, so I probably need to learn about it anyway.
Unfortunately, the manual is not as straightforward as I would expected for "Getting Started". I did try
# currently I am using -B to specify the build directory,
# because I don't know where to find all files generated by build.
cmake ./CMakeList.txt -B ./build
but it generates a lot of directories and files under ./build/
I have no idea what they are, and most importantly I don't know where is the executables. However, one thing that seems to work is if I go into the build/, I can run the following to build
or actually cmake --build /path/to/build-directory. After this, I do find three executables in build/ directory, and I can run it. Not as straightforward as I would imagine, and that's all about "Getting Started", and the next chapter starts to talk about "Writing CMakeLists Files".
The CMake language
After reading some examples, I start to appreciate what Bazel does: provides a dialect of Python. Ultimately the build language needs to have multiple language features, such as scoping, variable setting, variable expanding etc, include other files, etc.
... I haven't finish read the entire tutorial ...