Using CMake for platform-independent commands
One of the keystones for the success of CMake is that it allows you to build the same software on a multitude of platforms. Conversely, this means that CMakeLists.txt
must be written in a way that does not assume a certain platform or compiler must be used. This can be challenging, especially when you’re working with custom tasks. A big help here is that the cmake
command-line utility supports the -E
flag, which can be used to perform common tasks such as file operations and creating hashes. Most of the cmake -E
commands are for file-related operations such as creating, copying, renaming, and deleting files, as well as creating directories. On systems that support filesystem links, CMake can also create symbolic links or hard links between files. Since CMake version 3.21, most of them are also available by using the file()
command, but not all of them. Notably, creating hashes from files can be done in a platform-independent way...