Tuesday, June 8, 2021

CMake tutorials

CMake tutorials & Git quick notes:

    CMake basic command:

  1. Hello CMake!
  2. CMake is one of the most popular build systems for C++ out there. One of the main reasons probably is that it is cross-platform: It does not build the project itself but operates a platform-specific system. That means it can generate Makefiles, ninja-build files, or project files for Visual Studio or Xcode, to name just a few..

  3. CMake series
  4. greate CMake series by a german guy.

  5. It's Time To Do CMake Right
  6. Many of the concepts presented here find their roots in Daniel Pfeifer’s masterpiece Effective CMake. Daniel has practically become the Messiah of the modern CMake church, preaching best practices and guidelines in a time when the only standard is to not have one. Daniel, I am your prophet.

    very good video from Daniel

  7. Use CMake Converter
  8. Quick Use To use cmake converter, simply give your *.sln file to cmake-converter command:.

  9. Learning CMake 1: a really quick introduction to CMake
  10. good series

    We could say that CMake is a framework to build/test/package software. It is not a build system: it is a build system generator. With CMake, we will write how to build our software in a high-level programming language and we will generate a native build system (like Unix Makefiles or Visual Studio Solutions). It's open source and extensively used by different companies and projects.

  11. Generating 64-bit projects for Visual Studio with CMake
  12. Generator Hm, interesting… I thought for some reason that by invoking CMake from the 64-bit Visual Studio command prompt, the project would automatically be generated as a 64-bit target — turns out that this is not the case: Checking the Solution File, the configuration is still set to Win32 (instead of x64) and in the project properties under Linker → Advanced, the Target Machine is still set to /MACHINE:X86 (instead of X64)..

  13. VST3 Project Generator doesn’t see CMake
  14. VST3 Project Generator doesn’t see CMake.

  15. Installing root on windows 10,64bit for visual studio 2019
  16. I started a physics course at university and they required to use root libraries for compiling programs. Is there a way to use root libraries with Visual Studio 2019? i tried to install the last release from the site,the 6.22.06, but when i try to include a library in vs it doesnt work,it show an error; a friend told me it is because root for windows is only for 32bit computers,and mine is 64. To install root i downloaded the .zip file from the site and then placed it to C:\ ,and then from the vs prompt i run c:\root\bin\thisroot.bat as the installation tutorial says in the release page,but then when i try to include libraries it doesnt work as i said before. Can anybody tell me what i am doing wrong?you would save my life,thanks :slight_smile:

  17. Visual studio solution build of CMake
  18. Visual studio solution build of CMake

  19. CMake tutorial & FAQ
  20. CMake tutorial & FAQ.

  21. Visual Studio 16 2019¶
  22. Generates Visual Studio 16 (VS 2019) project files..

    Platform Selection The default target platform name (architecture) is that of the host and is provided in the CMAKE_VS_PLATFORM_NAME_DEFAULT variable.

    The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the cmake(1) -A option, to specify a target platform name (architecture). For example:

    1. cmake -G "Visual Studio 16 2019" -A Win32
    2. cmake -G "Visual Studio 16 2019" -A x64
    3. cmake -G "Visual Studio 16 2019" -A ARM
    4. cmake -G "Visual Studio 16 2019" -A ARM64

  23. Why Using CMake
  24. CMake is a tool that allows us to generate project files from our code for a multitude of different environments. By using it we are not tied anymore to a specific IDE environment, like Visual Studio (or a specific version of it), or NetBeans, or CLion, because the project files are going to be independently generated using CMake. We can dictate the project structure in a platform-agnostic manner, so whoever downloads our code can generate the solution project files as we initially planned, regardless of the chosen environment..

  25. CGold: The Hitchhiker’s Guide to the CMake
  26. This guide will show you how to use CMake and will help you to write elegant, correct and scalable projects. We’ll start from the simple cases and add more features one by one. This tutorial covers only part of the CMake capabilities - some topics are skipped intentionally in favor of better modern approaches [1]. This document is designed to be a good tutorial for absolute beginners but also touches on some aspects in which advanced developers may be interested. Look at this document as a skeleton/starting point for further CMake learning..

  27. It's Time To Do CMake Right
  28. Many of the concepts presented here find their roots in Daniel Pfeifer’s masterpiece Effective CMake. Daniel has practically become the Messiah of the modern CMake church, preaching best practices and guidelines in a time when the only standard is to not have one. Daniel, I am your prophet..

  29. [MUC++] Daniel Pfeifer - "Effective CMake"
  30. While CMake has become the de-facto standard buildsystem for C++, it's siblings CTest and CPack are less well known. This talk gives a lightspeed introduction into these three tools and then focuses on best practices on building, testing, and packaging. We will learn how to manage dependencies and export our libraries in such a way that they can be easily used by our clients. We will crosscompile for different platforms and run our tests in an emulator. We will analyze code coverage and perform static and dynamic code analysis. .

  31. CMake @GitLab source code
  32. complete setting for CI.

  33. CMake and Visual Studio
  34. CMake produces Visual Studio solutions seamlessly. This post will map CMake commands to the Visual Studio IDE with an example which makes learning much easier. It is primarily intended for a C++ developer using Visual Studio. Most references here is based on Visual Studio 2010 but will apply equally well to other versions. Continuing from the preface CMake for Visual Studio Developers..

  35. CMake, Visual Studio, and the Command Line
  36. Quick note before we begin: throughout this article, I will be using Visual Studio 2015 on Windows 10 to build the source code of CMake itself. If’s a nice project for a case study, since it’s neither too big nor too small, and has no dependencies to worry about (and of course, it uses CMake to build itself :).

  37. Wrong compiler platform selected with Visual Studio 16 2019 kit
  38. The automatically detected kit for Visual Studio 16 2019 for the x86 platform incorrectly uses the x64 compiler. This can be fixed by adding "platform": "Win32" to the kit configuration in cmake-tools-kits.json and changing "visualStudioArchitecture" from "x86" to "Win32"..

  39. How do I convert a C++ project built with CMake to Visual Studio?
  40. Manually, one file, library or macro definition at a time.

    The best idea is NOT to convert cmake project to visuals studio, as you lose cross-platform support, and if someone setup tests and compiler definition in the project, you lose those as well.

    CMake can generate visual studio project. It’ll still use cmake under the hood, but you’ll work within the idea as usual. So either use cmake -G "Visual Studio 15 2017" or pick desired project type with cmake-gui..

    Git Basics for quick start

  41. 2.1 Git Basics - Getting a Git Repository
  42. If you can read only one chapter to get going with Git, this is it. This chapter covers every basic command you need to do the vast majority of the things you’ll eventually spend your time doing with Git. By the end of the chapter, you should be able to configure and initialize a repository, begin and stop tracking files, and stage and commit changes. We’ll also show you how to set up Git to ignore certain files and file patterns, how to undo mistakes quickly and easily, how to browse the history of your project and view changes between commits, and how to push and pull from remote repositories.

  43. Git official documentations
  44. Git official documentations: index

  45. Git tutorials: External Links
  46. very good collections of Git for quick start.

    Visual Studio 2017 & 2019 Visualization tools

  47. Compiler options listed alphabetically
  48. This table contains an alphabetical list of compiler options. For a list of compiler options by category, see the Compiler options listed by category article..

  49. /FR, /Fr (Create .Sbr File)
  50. Creates .sbr files.

  51. Compiler Options
  52. This is a paragraphcl.exe is a tool that controls the Microsoft C++ (MSVC) C and C++ compilers and linker. cl.exe can be run only on operating systems that support Microsoft Visual Studio for Windows. .

    to generate CodeMap in Visual Studio 2019, you must set browse information compilation option( /FR) in your C++ project. it won't impact binary output.

       

  53. Code Graph
  54. Code Graph is a code visualization tool for Visual Studio 2012-2017 and allows one to explore the code conveniently.

  55. Code Graph for Visual Studio 2019
  56. Code Graph for Visual Studio 2019..

  57. Solution Dependency Viewer
  58. Every wanted to see the web of project reference from your solution. Solution Dependency Viewer provides a graph layer to the solution with projects represented as nodes and project references represented as links between nodes. Current version supports C++, C#, VB projects.

    The graph uses the DGML and the graph model engine in Visual Studio and uses MSBuild Framework to parse solution.

  59. Map dependencies with code maps
  60. In this article, you'll learn how to visualize dependencies across your code with code maps..

    CMake Visualization

  61. CMakeGraphVizOptions¶
  62. The builtin Graphviz support of CMake..

  63. Graphviz GUI tool
  64. GRaphviz GUI tools.

  65. Qt Visual Graph Editor
  66. Qt Visual Graph Editor.

  67. Graphviz
  68. What is Graphviz? Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. It has important applications in networking, bioinformatics, software engineering, database and web design, machine learning, and in visual interfaces for other technical domains..

  69. Graphvize Documentation & User’s Guides
  70. Graphvize Documentation & User’s Guides.

    CMake Build process and generator-expression

  71. CGold: The Hitchhiker’s Guide to the CMake
  72. This guide will show you how to use CMake and will help you to write elegant, correct and scalable projects. We’ll start from the simple cases and add more features one by one. This tutorial covers only part of the CMake capabilities - some topics are skipped intentionally in favor of better modern approaches [1]. This document is designed to be a good tutorial for absolute beginners but also touches on some aspects in which advanced developers may be interested. Look at this document as a skeleton/starting point for further CMake learning..

  73. CMake and object libraries
  74. I recently discovered CMake support for Object Libraries, those are, in simple words, not “real” libraries generating a .lib, .so or .dll files but temporary libraries based in Object files. I find this very useful for supporting different build targets that depends in common code but I don’t need to generate a library at all.

    very useful discovery...

  75. Handling external dependencies in C/C++ with Conan
  76. Conan is another popular cross platform package manager for C/C++, its approach is slightly different. In Conan, the developer has complete control of the package creation and build packages are available (so you don’t have to build the package from scratch just to use it). Maybe the best way to explain the difference is doing the same example as last time but now with Conan..

  77. How to use CMake to configure your projects with deal.II
  78. cmake is controlled by input files that by convention are called CMakeLists.txt, listing both configuration commands as well as dependencies between source files and targets. This page presents some CMakeLists.txt examples for potential use in your projects. (A detailed description of the deal.II project configuration is given in the deal.II CMake ReadMe.)

  79. Details on the deal.II configuration and build system
  80. The deal.II README file gives an overview over the basics of configuring and building the deal.II library. This page provides more details about using the deal.II CMake build system.

  81. Installation instructions and further information on deal.II
  82. Installation instructions and further information on deal.II.

  83. cmake-build system
  84. IntroductionA CMake-based buildsystem is organized as a set of high-level logical targets. Each target corresponds to an executable or library, or is a custom target containing custom commands. Dependencies between the targets are expressed in the buildsystem to determine the build order and the rules for regeneration in response to change..

  85. cmake-generator-expressions(7)
  86. Generator expressions are evaluated during build system generation to produce information specific to each build configuration.

    Generator expressions are allowed in the context of many target properties, such as LINK_LIBRARIES, INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS and others. They may also be used when using commands to populate those properties, such as target_link_libraries(), target_include_directories(), target_compile_definitions() and others.

    This means that they enable conditional linking, conditional definitions used when compiling, and conditional include directories and more. The conditions may be based on the build configuration, target properties, platform information or any other queryable information.

  87. Linking multiple static .lib files into one monolithic .lib file using VS2008 SP1 using CMake 2.8.x
  88. Create a static library "merged" with a dummy source file, and add libs to be merged to the STATIC_LIBRARY_FLAGS, so they will be additional input to lib.exe..

  89. CMake Wildcard for TARGET_OBJECTS
  90. but the $<TARGET_OBJECTS:A > command becomes ugly very quickly. Is there any way to tell CMake to include all .o files in the lib folder for linking everything?

  91. Building a C++ Application on Windows
  92. This section explains how to build an application with the ZED SDK on Windows platforms..

    CMake Tutorials & Examples

  93. Building with CMake
  94. very good series: Building with CMake...

  95. CMake tutorials from CMake.org
  96. Steps The tutorial documentation and source code for examples can be found in the Help/guide/tutorial directory of the CMake source code tree. Each step has its own subdirectory containing code that may be used as a starting point. The tutorial examples are progressive so that each step provides the complete solution for the previous step..

  97. CMake projects in Visual Studio
  98. Microsoft guide.

  99. CMake reference
  100. CMake is a tool to manage building of source code. Originally, CMake was designed as a generator for various dialects of Makefile, today CMake generates modern buildsystems such as Ninja as well as project files for IDEs such as Visual Studio and Xcode..

  101. A CMake Tutorial for Visual C++ Developers
  102. This article provides an introduction to CMake through a series of examples to help you, as VC++ developers, to create and maintain CMake projects.

  103. Working with CMake
  104. This is a developer-oriented introduction to CMake and how to modify the CMake build scripts.

    We assume you already know the basics of how to use cmake to configure and build Inkscape (if not, see Inkscape's README).

  105. what is the proper use of the CMake “project” directive
  106. I've gone through and placed a CMakeLists.txt file at each directory to build each library.

    In each CMakeLists.txt I have used the "project( xxx )" directive. This has defined for me PROJECT_NAME, PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables which I make judicious use of.

  107. Tradeof between CMAKE_BINARY_DIR and PROJECT_BINARY_DIR when setting submodule targets' output directories
  108. I'm working on a library which will be used by another project. The main project uses a couple of libraries linked as git submodules. Inside the library project used as a submodule, I can set the LIBRARY_OUTPUT_DIRECTORY and the ARCHIVE_OUTPUT_DIRECTORY in two different ways.

    In option A the targets are built and saved to their own subdirectories using the ${PROJECT_BINARY_DIR}/lib, but in option B all targets are built and saved to the ${CMAKE_BINARY_DIR}/lib directory.

    This could also be extended to binaries built by the submodules. Thus, which of the two options will scale better / is normally used as best-practice?

  109. Cmake PROJECT_BINARY_DIR
  110. Full path to build directory for project.

    This is the binary directory of the most recent project() command.

  111. Using configuration options in c++ using CMake
  112. my note: very useful tips..

    Sometimes when writing generic code you want to only using certain bits of code in special circumstances, for example only use OpenCV code when it is availble. With CMake this is easy.

  113. CMake Tutorial
  114. step by step, various topics in one example

    Modern CMake & Split CMake project into multiple projects

  115. CMake Directory Variables
  116. CMake creates software build systems for a wide variety of platforms based on a single, unified control file–it’s a makefile maker. You create the CMake control file once and based on this file, CMake will create almost any build environment for you: GNU Make for Linux, Eclipse project, Visual Studio solution for Windows, and the list goes on.

    I found the relationship between certain groups of related CMake variables troublesome. I wrote my understanding of these variables to help myself remember, and I will share it with you. If you have an better (or more correct) explanation, please leave a comment..

  117. More Modern CMake
  118. Welcome to HSF CMake tutorial! The aim of this tutorial is to cover the basics of using CMake. This tutorial is based on the online book Modern CMake, with a focus on CMake 3.14+. This is in what is called the “More Modern” era of CMake (roughly defined as 3.12+), and includes the fantastic command line improvements in CMake π (3.14).

    This workshop covers the basics of making and building a project, and some details of design.

  119. An Introduction to Modern CMake
  120. this is the content of its PDF file online.

    People love to hate build systems. Just watch the talks from CppCon17 to see examples of developers making the state of build systems the brunt of jokes. This raises the question: Why? Certainly there are no shortage of problems when building. But I think that, in 2020, we have a very good solution to quite a few of those problems. It's CMake. Not CMake 2.8 though; that was released before C++11 even existed! Nor the horrible examples out there for CMake (even those posted on KitWare's own tutorials list). I'm talking about Modern CMake. CMake 3.4+, maybe even CMake 3.20+! It's clean, powerful, and elegant, so you can spend most of your time coding, not adding lines to an unreadable, unmaintainable Make (Or CMake 2) file. And CMake 3.11+ is supposed to be significantly faster, as well!

    you can download a PDF version of this book. it is saved in C:\DemoCmake folder one copy

  121. Scott Craig's blog:Enabling C++11 And Later In CMake
  122. With the constant evolution of C++, build systems have had to deal with the complication of selecting the relevant compiler and linker flags. If your project targets multiple platforms and compilers, this can be a headache to set up. Happily, with features added in CMake 3.1, it is trivial to handle this in a generic way..

  123. Generated Sources In CMake Builds
  124. Using a set of source files to build libraries and executables is about the most basic thing a build system needs to do. This is relatively easy with CMake, but things get more interesting when some of the source files need to be generated as part of the build. CMake provides a range of functionality which can be used to create files, but getting build dependencies correct is an area where many developers struggle or even simply give up. It doesn’t have to be that way!

    Comments: Very useful indeed. Thanks a lot. I’ve now got something which takes my GLSL shaders and puts them into a map of inside the C++ code, thus solving my “how to embed my shaders in the executable” problem, nicely.

  125. Enhanced source file handling with target_sources()
  126. In all but trivial CMake projects, it is common to find targets built from a large number of source files. These files may be distributed across various subdirectories, which may themselves be nested multiple levels deep. In such projects, traditional approaches usually either list all source files at the top-most level or build up the list of source files in a variable and pass that to add_library(), add_executable(), etc. With CMake 3.1, a new command target_sources() was introduced which provides the missing piece among the various target_... commands. While the CMake documentation succintly describes what target_sources() does, it fails to highlight just how useful the new command is and why it promotes better CMake projects:.

  127. PROJECT_BINARY_DIR
  128. Full path to build directory for project.

    This is the binary directory of the most recent project() command..

  129. CMake 3.20 (English)
  130. CMake documentation & command list.

  131. Basic CMake usage, Part 1
  132. The end of a semester is here and, as I grade our student's semestral works, I get to use Makefiles and CMakeLists of dubious quality[1]. After seeing the same errors repeated over and over again, I decided to write a short tutorial towards writing simple Makefiles and CMakeLists. This is the CMake tutorial, the Make one can be found here..

    the source code can be downloaded from this link: In case you do care, here is a link to one of the zips that contains them. ↩︎

  133. Basic CMake, part 2: libraries
  134. My previous post about CMake provided a simple CMakeLists.txt for a small, self-contained, project. In practice, very few projects are fully self-contained, as they either depend on external libraries or are themselves libraries that other projects depend on. This post shows how to create and consume simple libraries using modern CMake.

  135. splitting a project into a library and a application
  136. I'm using cmake for my project. No I want to split some parts into a library and use this for 2 different applications..

  137. Splitting large C++ project
  138. Like it happens to many, our C++ project grew larger and larger, and it finally hit the point where maintainability starts to be a concern, mostly due to build times: even by using ccache, every change requires anywhere from 30 seconds to 5 minutes to rebuild and test (actually it seems that "linking" is the time-consuming phase, but we are still investigating).

    The project consists mainly of a big scientific library, along with some applications which make use of it. For example, there are applications to augment simulation models, or language bindings (python) for integration into other software packages.

  139. How can I effectively use one file per class in C++?
  140. Even though I have a decent bit of professional experience with object oriented programming in Java and a basic familiarity with C, I've run into a bit of a mental block with C++ that I was hoping other developers could help me shine a light on..

  141. What are forward declarations in C++?
  142. What are forward declarations in C++?

No comments:

Post a Comment