CMake Insights: A Case Study with FAST-LIO

CMake Insights: A Case Study with FAST-LIO

Review: Why do we use Make and CMake tools? The main reasons are to automate the build process, manage dependencies, and simplify cross-platform development for complex project compilation requirements: Large C++ projects often consist of multiple source files, header files, and library dependencies, making manual compilation commands (like <span>g++</span>) error-prone and inefficient. Dependency Management: Build … Read more

CMake Mastery (5): Comprehensive Guide to add_library – Static and Dynamic Libraries

CMake Mastery (5): Comprehensive Guide to add_library - Static and Dynamic Libraries

Master the Core Logic of Library Building from Compilation Principles to Industrial Practices 1. Essential Differences Between Static and Dynamic Libraries Core Feature Comparison Feature Static Library (<span>.a</span>/<span>.lib</span>) Dynamic Library (<span>.so</span>/<span>.dll</span>) Linking Method Compiled into the executable file at build time Loaded dynamically at runtime Memory Usage Multiple loads of the same library will consume … 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

CMake Function Syntax

CMake Function Syntax

In CMake, functions are used to encapsulate a reusable block of code. Below is a detailed explanation of defining and calling functions in CMake. Defining Functions Function definitions start with function(), followed by the function name and any parameter list, as shown below: function(<function_name> [arg1 [arg2 […]]]) # Function code… endfunction() The function name should … 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

Common Syntax of CMake (Cache Variables)

Common Syntax of CMake (Cache Variables)

Previous exciting content: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) In the previous article on CMake Variables, we briefly mentioned cache variables but did not elaborate on them. Today, we will organize the common syntax for cache … Read more

CMake from Beginner to Expert (4): Multi-Directory Project Management

CMake from Beginner to Expert (4): Multi-Directory Project Management

Foundation of Modular Builds: In-Depth Practice from Directory Isolation to Variable Passing 1. Why is Multi-Directory Project Management Necessary? As the project scales to hundreds of source files, piling all code into a single directory leads to: Difficult Maintenance: Hard to quickly locate the code corresponding to a module or function Low Compilation Efficiency: Full … Read more

Optimizing Link Time Optimization (LTO) in CMake

Optimizing Link Time Optimization (LTO) in CMake

Enabling Link Time Optimization (LTO) in CMake can significantly enhance program performance and sometimes reduce the size of the final binary. LTO allows the compiler to perform optimizations across the entire program rather than just within individual source files. Below is a detailed guide on how to enable and configure LTO in CMake projects.1. Enabling … Read more

Common Syntax of CMake (Environment Variables)

Common Syntax of CMake (Environment Variables)

Previous Exciting Content: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) In CMake, environment variables have the following characteristics: 1. The scope of environment variables is global and they are not cached. 2. They … Read more