
Modern CMake for C++
By :

After source code is compiled, we might want to avoid compiling it again for the same platform or even share it with external projects wherever possible. Of course, you could just simply provide all of your object files as they were originally created, but that has a few downsides. It is harder to distribute multiple files and add them individually to a buildsystem. It can be a hassle, especially if they are numerous. Instead, we could simply bring all object files into a single object and share that. CMake helps greatly with this process. We can create these libraries with a simple add_library()
command (which is consumed with the target_link_libraries()
command). By convention, all libraries have a common prefix, lib
, and use system-specific extensions that denote what kind of library they are:
.a
extension on Unix-like systems and .lib
on Windows..so
extension on Unix-like systems and .dll...