Using CMake: A C++ Project Build Tool

Using CMake: A C++ Project Build Tool

Using CMake: A C++ Project Build Tool CMake is a popular cross-platform build system that generates standardized build files, allowing C++ projects to be easily compiled and managed across different operating systems and development environments. In this article, we will introduce the basic usage of CMake and how to use it to create a simple … Read more

CMake from Beginner to Pro (1): A Minimal Introduction to CMake – Environment Setup and First Project

CMake from Beginner to Pro (1): A Minimal Introduction to CMake - Environment Setup and First Project

1. Why Use CMake? In C++ projects, manually managing the build chain (especially for large projects with multiple platforms and modules) can introduce significant complexity. CMake addresses the following issues with its declarative syntax: Cross-platform builds: Generates build files for the corresponding platform (Makefile/MSVC project/Xcode project) Dependency management: Automatically finds third-party libraries (such as OpenCV, … Read more

Exploring CMakeLists: ROS and Catkin

Exploring CMakeLists: ROS and Catkin

Introduction to CMakeLists<span>CMakeLists.txt</span> file is the input file for the CMake build system used to build software packages. Any package that conforms to the CMake specification contains one or more <span>CMakeLists.txt</span> files that describe how to build the code and where to install it. The <span>CMakeLists.txt</span> file used for catkin projects is a standard CMakeLists.txt … Read more

Comprehensive Guide to CMakeLists (Part 1)

Comprehensive Guide to CMakeLists (Part 1)

Word count: 7897, approximately 40 minutes of reading time Comprehensive Guide to CMakeLists (Part 1) 0. CMake Application Examples Previously, we organized content on using CMake to introduce third-party libraries (header file directories, library directories, library files). However, the content organized here is not complete. Therefore, we need to further organize the usage of CMake … Read more

CMake Basics: Configuration and Best Practices

CMake Basics: Configuration and Best Practices

1. File Structure mkdir buildcmake .. -G "Unix Makefiles"make 2. Code Explanation # CMake recommends using "out-of-source builds" to avoid polluting the source code directory. # Create a build directory (name can be arbitrary, e.g., build/) mkdir build # Enter that directory cd build # Specify the parent directory of CMakeLists.txt (i.e., the source code … 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

CMake Project Management: From Beginner to Expert

CMake Project Management: From Beginner to Expert

Hello everyone! Today I want to share a very practical topic – CMake project management. As a veteran C++ developer with over ten years of experience, I know how important a good build system is in large project development. CMake is such a powerful tool that helps us manage code dependencies and configure compilation options, … Read more

CMake Tutorial: Building C/C++ Projects with Different Generators

CMake Tutorial: Building C/C++ Projects with Different Generators

For CMake, I had always understood it to be a project build tool, until I encountered –build and realized that CMake also unifies the compilation phase across different platforms. To understand CMake‘s build and compile process, one must first understand generators. 1. Generators The CMake generator is responsible for writing input files for the underlying … Read more

Master CMake for Building Static and Dynamic Libraries

Master CMake for Building Static and Dynamic Libraries

1. Task Explain the process of building static and dynamic libraries with CMake in a simple and understandable way using examples. Tasks: Create a static library and a dynamic library, providing the HelloFunc function for use in other programs, which outputs the string ‘Hello World!’ to the terminal. Install header files and shared libraries. Write … Read more