Basic Usage of CMake: A Must for Native Cross-Platform Development

Basic Usage of CMake: A Must for Native Cross-Platform Development

CMake is an open-source, cross-platform suite of tools for building, testing, and packaging software. CMake controls the software compilation process using simple platform and compiler-independent configuration files (CMakeLists.txt) and generates native build files and workspaces that can be used in your chosen build environment. The CMake suite was created by Kitware in response to the … Read more

CMake Tips: Do You Really Understand add_dependencies and find_package?

CMake Tips: Do You Really Understand add_dependencies and find_package?

In the world of CMake, mastering dependency management is an essential skill for every developer. Today, we will discuss the two commands add_dependencies and find_package, exploring their differences and how to use them correctly. 🔧 add_dependencies is used to set target dependencies. For example, if you have a custom target or executable that needs to … Read more

Building and Linking Dynamic and Static Libraries with CMake Made Simple!

Building and Linking Dynamic and Static Libraries with CMake Made Simple!

Click the blue textFollow the author 1. Introduction In slightly more complex projects, we often encounter situations where we need to build multiple executable files, each potentially composed of different source files. More commonly, the project’s source code is distributed across multiple subdirectories rather than being concentrated in a single directory. ProjectRoot ├── CMakeLists.txt (Top-level … Read more

How to Solve 90% of Build Problems with CMake Using Conditions and Loops?

How to Solve 90% of Build Problems with CMake Using Conditions and Loops?

Click the blue textFollow the author 1. Introduction So far, the CMake examples we have encountered follow a straightforward process: starting from a series of source files, ultimately building into a single executable program or generating static/dynamic libraries. This linear process is simple and easy to understand, but often proves inadequate in more complex projects. … Read more

CMake Compilation Optimization – Precompiled Header Files

CMake Compilation Optimization - Precompiled Header Files

<span>target_precompile_headers</span> is a feature introduced in CMake 3.16, used to generate precompiled header files (Precompiled Headers, PCH) for specific targets (such as executables or libraries). Precompiled header files can significantly speed up compilation, especially when there are many repeated header file inclusions in the project. 1. The Role of Precompiled Header Files Reduce Redundant Compilation: … Read more

CMake vs qmake: Which One Should You Choose?

CMake vs qmake: Which One Should You Choose?

CMake vs qmake: Which One Should You Choose? 🔥 Today, let’s discuss CMake and qmake, two tools used for managing project builds, but they have significant differences! 💡 Design Philosophy • CMake: It is a cross-platform build system generator that supports various compilers and build tools, such as Make, Ninja, Visual Studio, etc. It handles … Read more

Common Syntax of CMake (List)

Common Syntax of CMake (List)

Previous Highlights:CMake Hello, WorldCMake VariablesCMake Official Tutorial (Basic Project Setup)CMake Official Tutorial (Library Creation)CMake Official Tutorial (Usage Requirements)CMake Official Tutorial (Installation and Testing)CMake Common Syntax (if Statement)CMake Common Syntax (Cache Variables)CMake Common Syntax (Environment Variables)CMake Common Syntax (Mathematical Calculations)CMake Common Syntax (Strings) In CMake, a list is a collection of strings separated by semicolons, and … Read more

Using CMake: Static and Dynamic Libraries

Using CMake: Static and Dynamic Libraries

When compiling a new program, we will use third-party compiled library files or library files that we compiled ourselves. Here we will use the static and dynamic libraries that have been compiled previously.1. Using Static LibrariesThe file structure is as follows. Here we have deleted add.c and subtract.c from the src folder, keeping only main.c, … Read more