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/$<CONFIG>) # Specify the output path for dynamic libraries set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/$<CONFIG>) # Specify the output path for static libraries set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/$<CONFIG>) 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

Can Programmers Who Don’t Understand Makefile Still Write Code?

Can Programmers Who Don't Understand Makefile Still Write Code?

Introduction: Tired of Typing Compilation Commands? It’s Time to Learn Automation! Hello everyone, I am Xiaokang! Last time we talked about GCC, G++, and GDB, clarifying how these tools are used in C/C++ development. With them, you can happily compile and debug your code. But let me ask you, do you manually type the <span>gcc</span> … Read more

GCC Compiler Toolchain Download and Installation Guide

GCC Compiler Toolchain Download and Installation Guide

The GCC embedded system cross-compilation toolchain (GNU Arm Embedded Toolchain) includes: the Windows version of ARM-GCC, debugger (OpenOCD), make tools, and programming tools. I have shared “arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi.exe” via Quark Cloud Disk; click the link to save it. Link: https://pan.quark.cn/s/318d63030760 The option “Add path to environment variable” is not checked by default; please check it here. … Read more