Using CMake for Project Development

Using CMake for Project Development

Installing CMake Tool yum install cmake Installing yaml-cpp Unzipping yaml-cpp [root@vbox ~]# unzip yaml-cpp-master.zip Entering the Source Directory [root@vbox ~]# cd yaml-cpp-master/ Creating Build Directory [root@vbox yaml-cpp-master]# mkdir build && cd build Generating Build Files [root@vbox build]# ls CMakeCache.txt cmake_install.cmake CTestTestfile.cmake Makefile util yaml-cpp-config-version.cmake CMakeFiles cmake_uninstall.cmake DartConfiguration.tcl Testing yaml-cpp-config.cmake yaml-cpp.pc CMake Installation (Generating Shared Library) … Read more

Package Management Module FetchContent in CMake

Package Management Module FetchContent in CMake

Background Introduction In the realm of C++ package management tools, aside from Microsoft’s vcpkg, there doesn’t seem to be a particularly famous package manager. CMake actually provides basic package management functionality. By using the <span>FetchContent</span> module commands, you can download the source code or other files that your project depends on. Basic Usage <span>FetchContent_Declare</span> command … Read more

Setting the Default Startup Project in CMake for Visual Studio: No Longer ALL_BUILD

Setting the Default Startup Project in CMake for Visual Studio: No Longer ALL_BUILD

The default startup project generated by <span>cmake</span> is <span>ALL_BUILD</span>. We want to specify the default startup project so that we don’t have to set it every time we open the <span>.sln</span> file. This was not possible before <span>cmake 3.6</span>. After <span>cmake 3.6</span>, it can be accomplished by setting the <span>VS_STARTUP_PROJECT</span> property. 1. Core Setting Statement … Read more

CMake Command Quick Reference: Comprehensive Overview of Common Commands

CMake Command Quick Reference: Comprehensive Overview of Common Commands

Click the blue text to follow the author 1. Introduction CMake is a cross-platform open-source build system generator. It does not directly build software but generates a build system for a specific platform based on the descriptions in the <span>CMakeLists.txt</span> file. The role of CMake is to decouple the build process from the compiler, operating … Read more

Introduction to CMake

Introduction to CMake

1. What is CMake CMake is a more advanced build configuration tool than make, supporting different platforms and compilers, generating corresponding Makefiles or vcproj projects (Visual Studio project files). By writing a CMakeLists.txt file, you can control the generated Makefile, thereby controlling the build process. The Makefile generated by CMake not only allows you to … Read more

A Beginner’s Guide to Modern CMake

A Beginner's Guide to Modern CMake

The eBook “A Beginner’s Guide to Modern CMake” http://t.cn/A6r1ls4q “People love to complain about build systems. Just look at the talks from CppCon17, where developers used the current state of build systems as a punchline. This raises a question: why? Of course, there are countless issues during the build process. But I believe we have … Read more

Building C++ Projects: Makefile and CMake

Building C++ Projects: Makefile and CMake

Building C++ Projects: Makefile and CMake In the software development process, build management is a crucial aspect. For C++ projects, the two commonly used build tools are Makefile and CMake. This article will provide a detailed introduction to these two tools, including basic concepts, usage methods, and code examples to help you better understand how … Read more

Stop Using the Default Compiler? CMake Compiler Configuration Enables Code Compilation Anywhere!

Stop Using the Default Compiler? CMake Compiler Configuration Enables Code Compilation Anywhere!

Click the blue textFollow the author 1. Background Introduction CMake compiler configuration not only relates to performance but also directly affects the maintainability and portability of the code. By explicitly specifying the compiler and its options, you can ensure consistent behavior of the code across different platforms and reduce maintenance costs. Limitations of using the … Read more

Is Your CMake Build Slow? A Deep Dive into Build Types!

Is Your CMake Build Slow? A Deep Dive into Build Types!

Click the blue textFollow the blogger 1. Overview of CMake Build Types In CMake, “build type” refers to a set of predefined settings and options used to control the compilation and linking process. It is essentially a variable <span>CMAKE_BUILD_TYPE</span> that can be explicitly set or determined by CMake based on default rules. The build type … Read more