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

Mastering CMake from Beginner to Advanced (3): Functions and Parameter Passing

Mastering CMake from Beginner to Advanced (3): Functions and Parameter Passing

In-depth analysis<span>function()</span> and <span>macro()</span> differences, mastering variable arguments and cross-platform compilation practical applications. 1. <span><span>function()</span></span> and <span><span>macro()</span></span> essential differences 1.1 Scope and Variable Passing <span>function()</span>: Local Scope: Variables (including parameters) defined inside the function are only valid within the function and are not visible externally. Parameter Passing: Passed by value, modifications to parameters within the … Read more

CMake from Beginner to Expert (2): Variables and Scope

CMake from Beginner to Expert (2): Variables and Scope

1. Why is it important to understand variables and scope? CMake is not just a build tool, but also a “meta-programming language”. Variables and scope are its core programming elements, directly affecting: Project Configuration: Dynamically switching compilers, library paths, and compilation options Module Interaction: Data transfer between parent and child directories Environment Control: Cross-platform compatibility … Read more

CMake Basics: Specifying Executable Output Paths

CMake Basics: Specifying Executable Output Paths

cmake_minimum_required(VERSION 3.0)project(MyProject VERSION 1.0) # Specify the output path for the executable set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/$&lt;CONFIG&gt;) # Specify the output path for dynamic libraries set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/$&lt;CONFIG&gt;) # Specify the output path for static libraries set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/$&lt;CONFIG&gt;) set(SRC_LIST add.c subtract.c main.c)add_executable(demo01 ${SRC_LIST}) File paths and execution results

Common Syntax of CMake (Mathematical Calculations)

Common Syntax of CMake (Mathematical Calculations)

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) The math command in CMake is primarily used to perform simple integer mathematical operations during the build configuration phase, making … Read more

Basics of CMake: CMakeLists.txt

Basics of CMake: CMakeLists.txt

# File name: CMakeLists.txt # Set the minimum required CMake version to 3.15 cmake_minimum_required(VERSION 3.15) # Set the project name to MyProject, version number to 1.0 project(MyProject VERSION 1.0) # Set compilation options, set C++ standard to C++17 set(CMAKE_CXX_STANDARD 17) # Force the compiler to support the specified C++ standard (C++17 in this case), # … 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

Introduction to Go Project Development (Part 8): Makefile

Introduction to Go Project Development (Part 8): Makefile

1. What is a Makefile In software development, a Makefile is a script file used for automating the build and management of projects, typically used in conjunction with the make tool. Its core objective is to automate tasks such as compilation, testing, packaging, and deployment. Makefile standardizes commands through declarative rules and dependencies, unifying the … Read more

A Brief Discussion on Makefile, Kconfig, and .config Files in the Linux Kernel Source Code

A Brief Discussion on Makefile, Kconfig, and .config Files in the Linux Kernel Source Code

Follow+Star Public Account Number, don’t miss out on exciting content Source | Baiwen Technology WeChat Public Account | Embedded Column The Linux kernel source code contains numerous files, and it can be confusing to understand the relationship between Makefile, Kconfig, and .config. Without a clear understanding of the kernel compilation system, one may struggle with … Read more

Learning Makefile

Learning Makefile

GDB Debugging Tool Common commands for GDB debugging: gcc -g main.c -o main Common commands: help bt Show the call stack info locals Show local variables break main.c:10 Set a breakpoint at line 10 next Execute the next line list List source code continue Continue execution print Print variable value start Restart program execution delete … Read more