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

Common Syntax of CMake (Strings)

Common Syntax of CMake (Strings)

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 Statements)CMake Common Syntax (Cache Variables)CMake Common Syntax (Environment Variables)CMake Common Syntax (Mathematical Calculations) In mainstream programming languages, strings are a fundamental and core data type, which is crucial, and … Read more

CMake Tutorial

CMake Tutorial

1. Introduction to CMake CMake is a cross-platform build tool, which can generate: Makefile for Linux/Unix Project files for <span>Visual Studio</span> on Windows Project files for <span>Xcode</span> on macOS without manually writing build scripts for different platforms. 2. Installing CMake Windows: Download the installer from cmake.org/download Linux: <span>sudo apt install cmake</span> (Debian/Ubuntu) macOS: <span>brew install … Read more

Different Linking Methods for CMake Libraries

Different Linking Methods for CMake Libraries

1. Different Libraries Have Different Linking Methods OpenCV uses ${OpenCV_LIBS} target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) protobuf uses ${PROTOBUF_LIBRARIES} target_link_libraries(${PROJECT_NAME} ${PROTOBUF_LIBRARIES}) jpeg-turbo uses the target name libjpeg-turbo::turbojpeg-static target_link_libraries(${PROJECT_NAME} libjpeg-turbo::turbojpeg-static) 2. How to Determine Which Method to Use Generally, the following methods can be used: Check the CMake file for usage instructions. (Well-written CMake files usually include usage instructions) Look … Read more

Implementing Static Library Compilation in Zephyr

Implementing Static Library Compilation in Zephyr

Zephyr has encapsulated a lot of functionality in its build system around CMake, primarily through a series of macros and functions that simplify the declaration of libraries and modules, the addition of source files, the setting of include directories, and linking operations. Below are detailed explanations of some key points: 1.zephyr_library() Macro lFunction This macro … 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

A Complete Guide to Using CMake

A Complete Guide to Using CMake

Scan to FollowLearn Embedded Together, Learn Together, Grow Together Hello everyone, I previously shared some articles related to makefiles: Make Command Tutorial | A Hands-On Guide to Makefile Linux Kernel Makefile Execution Process Some General Makefile Templates Today, I am sharing an article about CMake, which can generate local Makefiles without having to write complex … Read more

Cross-Compiling C and C++ with CMake

Cross-Compiling C and C++ with CMake

Embedded development, especially in SOA (Service Oriented Architecture), often encounters a scenario where part of the business functionality is developed in C and is relatively mature, and there is a desire to reuse it directly. However, the underlying services obtained by the business layer are written in C++. If both need to be placed in … Read more