# Usage

**URL:** https://discourse.cmake.org/c/usage/12.md?page=75

[Latest](https://discourse.cmake.org/latest.md) · [Categories](https://discourse.cmake.org/categories.md) · [Tags](https://discourse.cmake.org/tags.md)

**Page:** 76

---

## [system build](https://discourse.cmake.org/t/system-build/3751)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 3\
**Last updated:** [July 15, 2021, 2:33pm UTC](https://discourse.cmake.org/t/system-build/3751 "2021-07-15T14:33:50Z")

</div>

When update the cmake code, it has something system environment upgrade. Do you have any suggest tool to build the environment and doesnt effect the original system ? I only know the docker. It can do it.

---

## [A Basic Starting Point - How to handle .h.in files](https://discourse.cmake.org/t/a-basic-starting-point-how-to-handle-h-in-files/3733)

<div class="topic-metadata">

**Author:** [@Marcelo\_Modolo](https://discourse.cmake.org/u/Marcelo_Modolo)\
**Replies:** 4\
**Last updated:** [July 14, 2021, 5:07pm UTC](https://discourse.cmake.org/t/a-basic-starting-point-how-to-handle-h-in-files/3733 "2021-07-14T17:07:09Z")

</div>

Hi! I started the tutorial and got a question about dynamic include files (.h.in to .h) Step 1: A Basic Starting Point How to handle code validation (IDE, Lint, Editor) if the file to be included doesn’t exist yet? Ar…

---

## [Header-only libs and VStudio Generator?](https://discourse.cmake.org/t/header-only-libs-and-vstudio-generator/3755)

<div class="topic-metadata">

**Author:** [@llm](https://discourse.cmake.org/u/llm)\
**Replies:** 0\
**Last updated:** [July 14, 2021, 1:11pm UTC](https://discourse.cmake.org/t/header-only-libs-and-vstudio-generator/3755 "2021-07-14T13:11:14Z")

</div>

i’ve tried to add a header-only lib project to my VStudio 2017 using latest CMake Release 3.20.5 under Win7 x64 in a x64 C++ Projekt using the tutorial here: http://mariobadr.com/creating-a-header-only-library-with-cm…

---

## [Fail to use self build Boost 1.75 under Ubuntu Linux 20.04 x64 with CMake default and 3.19.4](https://discourse.cmake.org/t/fail-to-use-self-build-boost-1-75-under-ubuntu-linux-20-04-x64-with-cmake-default-and-3-19-4/2750)

<div class="topic-metadata">

**Author:** [@llm](https://discourse.cmake.org/u/llm)\
**Replies:** 6\
**Last updated:** [July 14, 2021, 1:05pm UTC](https://discourse.cmake.org/t/fail-to-use-self-build-boost-1-75-under-ubuntu-linux-20-04-x64-with-cmake-default-and-3-19-4/2750 "2021-07-14T13:05:23Z")

</div>

Hello CMake community, hope here is someone around who can help me with using a self-build boost build with cmake my system: freshly installed Ubnutu 20.04 x64 with all build relevant tools (ubuntu packages: gcc 9.x, …

---

## [Help with unexpected behavior when installing](https://discourse.cmake.org/t/help-with-unexpected-behavior-when-installing/3709)

<div class="topic-metadata">

**Author:** [@fry](https://discourse.cmake.org/u/fry)\
**Replies:** 10\
**Last updated:** [July 13, 2021, 2:14pm UTC](https://discourse.cmake.org/t/help-with-unexpected-behavior-when-installing/3709 "2021-07-13T14:14:14Z")

</div>

I have some really weird behavior happening. I have a CMake build that creates a dynamic library and a static one (which is used by Google Test). I instruct install to only install the dynamic library. So that works, but…

---

## [icns](https://discourse.cmake.org/t/icns/3727)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 1\
**Last updated:** [July 13, 2021, 2:05pm UTC](https://discourse.cmake.org/t/icns/3727 "2021-07-13T14:05:26Z")

</div>

I create a dmg and double it to install. Then it will show the Application finder and the exe that I create. How to set the exe icns in the Application？

---

## [file(GET\_RUNTIME\_DEPENDENCIES) and cross-compiling](https://discourse.cmake.org/t/file-get-runtime-dependencies-and-cross-compiling/3726)

<div class="topic-metadata">

**Author:** [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Replies:** 2\
**Last updated:** [July 13, 2021, 2:02pm UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-and-cross-compiling/3726 "2021-07-13T14:02:13Z")

</div>

Reading the docs for file(GET\_RUNTIME\_DEPENDENCIES), it has statements of the form “On Linux platforms…”, “On Windows platforms…” and “On Apple platforms…”. The wording seems a bit ambiguous and it has made me wonder whe…

---

## [Using Swig and Lua](https://discourse.cmake.org/t/using-swig-and-lua/3729)

<div class="topic-metadata">

**Author:** [@leventelist](https://discourse.cmake.org/u/leventelist)\
**Replies:** 3\
**Last updated:** [July 12, 2021, 8:25am UTC](https://discourse.cmake.org/t/using-swig-and-lua/3729 "2021-07-12T08:25:55Z")

</div>

I’d like to use CMake to generate my Lua wrapper. I used this before to produce python wrapper. I can generate my wrapper.c by running Everything works fine, but I don’t get my wrapper.c. I use the following code: cmake…

---

## [CPACK\_BUNDLE\_NAME](https://discourse.cmake.org/t/cpack-bundle-name/3737)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 0\
**Last updated:** [July 12, 2021, 12:49am UTC](https://discourse.cmake.org/t/cpack-bundle-name/3737 "2021-07-12T00:49:52Z")

</div>

project(Qt5App LANGUAGES CXX) set(CPACK\_BUNDLE\_NAME “app”) The finally bundle name is Qt5App with project name

---

## [install interface](https://discourse.cmake.org/t/install-interface/3731)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 0\
**Last updated:** [July 11, 2021, 12:13pm UTC](https://discourse.cmake.org/t/install-interface/3731 "2021-07-11T12:13:49Z")

</div>

How to show the format interface with cmake in macOS?

---

## [Packaging an application](https://discourse.cmake.org/t/packaging-an-application/3593)

<div class="topic-metadata">

**Author:** [@poseid](https://discourse.cmake.org/u/poseid)\
**Replies:** 2\
**Last updated:** [July 11, 2021, 9:57am UTC](https://discourse.cmake.org/t/packaging-an-application/3593 "2021-07-11T09:57:43Z")

</div>

Hello, I am trying to install a small webclient that has a libcurl.dll depedency on Windows. Below is the snipped for the install instructions, but the problem is that not all dlls/deps are copied: if(WIN32) if(M…

---

## [JUnit CI dash demo](https://discourse.cmake.org/t/junit-ci-dash-demo/3721)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 1\
**Last updated:** [July 9, 2021, 10:47pm UTC](https://discourse.cmake.org/t/junit-ci-dash-demo/3721 "2021-07-09T22:47:44Z")

</div>

CMake 3.21 adds CTest JUnit output. Using plugins or capabilities of your CI (GitHub Actions, GitLab Runner, etc.) that works with JUnit, this allows dashboard like results. GitHub Actions example generates results. Mo…

---

## [No CMAKE\_Fortran\_COMPILER could be found.](https://discourse.cmake.org/t/no-cmake-fortran-compiler-could-be-found/3720)

<div class="topic-metadata">

**Author:** [@roslyn.parker](https://discourse.cmake.org/u/roslyn.parker)\
**Replies:** 2\
**Last updated:** [July 9, 2021, 8:07pm UTC](https://discourse.cmake.org/t/no-cmake-fortran-compiler-could-be-found/3720 "2021-07-09T20:07:24Z")

</div>

I have been getting this error from my cmake-gui window when compiling my C++/Fortran based project. The Fortran compiler identification is unknown CMake Error at Lib/Fast\_Table/CMakeLists.txt:2 (project): No CMAKE\_Fo…

---

## [presets inheritation question](https://discourse.cmake.org/t/presets-inheritation-question/3710)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 2\
**Last updated:** [July 8, 2021, 1:42pm UTC](https://discourse.cmake.org/t/presets-inheritation-question/3710 "2021-07-08T13:42:05Z")

</div>

Doc says: An optional array of strings representing the names of presets to inherit from. The preset will inherit all of the fields from the inherits presets by default (except name, hidden, inherits, description, and …

---

## [Weird edge case with gcov](https://discourse.cmake.org/t/weird-edge-case-with-gcov/3703)

<div class="topic-metadata">

**Author:** [@arclight](https://discourse.cmake.org/u/arclight)\
**Replies:** 2\
**Last updated:** [July 7, 2021, 5:11pm UTC](https://discourse.cmake.org/t/weird-edge-case-with-gcov/3703 "2021-07-07T17:11:28Z")

</div>

I’m trying to detect coverage testing flags in CMake before passing them to gfortran using check\_fortran\_compiler\_flag(). This works fine on Linux (GCC 9.4.0). With MinGW64 on Windows, some flags aren’t detected (GCC 10.…

---

## [How to use FetchContent correctly for building external dependencies](https://discourse.cmake.org/t/how-to-use-fetchcontent-correctly-for-building-external-dependencies/3686)

<div class="topic-metadata">

**Author:** [@rschoe](https://discourse.cmake.org/u/rschoe)\
**Replies:** 4\
**Last updated:** [July 6, 2021, 2:53pm UTC](https://discourse.cmake.org/t/how-to-use-fetchcontent-correctly-for-building-external-dependencies/3686 "2021-07-06T14:53:32Z")

</div>

Hi, I am trying to use FetchContent to build and statically link against a third party dependency in my c++ project. I am hitting the following problems: Install directives from the dependency are also added to my pr…

---

## [how to use pkg-config in cmake?](https://discourse.cmake.org/t/how-to-use-pkg-config-in-cmake/3695)

<div class="topic-metadata">

**Author:** [@javavwv](https://discourse.cmake.org/u/javavwv)\
**Replies:** 2\
**Last updated:** [July 6, 2021, 10:20am UTC](https://discourse.cmake.org/t/how-to-use-pkg-config-in-cmake/3695 "2021-07-06T10:20:02Z")

</div>

I installed opencv by sudo apt-get install libopencv-dev. Then opencv.pc file and opencv libraries are installed on my computer. I want to use the opencv libraries in another project which was build by cmake. how can I f…

---

## [Using External Project to built and add non-cmake library to project](https://discourse.cmake.org/t/using-external-project-to-built-and-add-non-cmake-library-to-project/3692)

<div class="topic-metadata">

**Author:** [@Robin\_Montferme](https://discourse.cmake.org/u/Robin_Montferme)\
**Replies:** 6\
**Last updated:** [July 5, 2021, 2:13pm UTC](https://discourse.cmake.org/t/using-external-project-to-built-and-add-non-cmake-library-to-project/3692 "2021-07-05T14:13:59Z")

</div>

Hello I’m currently trying to build a library using CMake and I would like to add a specific library to it. My goal is to be able to bundle the sources with my library source and make them build alongside my own. I f…

---

## [Internal compiler error with gcc 4.9.4](https://discourse.cmake.org/t/internal-compiler-error-with-gcc-4-9-4/3614)

<div class="topic-metadata">

**Author:** [@StefanBattmer](https://discourse.cmake.org/u/StefanBattmer)\
**Replies:** 4\
**Last updated:** [July 5, 2021, 8:53am UTC](https://discourse.cmake.org/t/internal-compiler-error-with-gcc-4-9-4/3614 "2021-07-05T08:53:41Z")

</div>

Hi, we recently migrated our build system from CMake 3.6.3 to 3.20.2. We build on Windows with VS and on Linux with various cross compilers and mostly the migration went smoothly. However one of our Linux builds using g…

---

## [(Ninja generator) Precise control over command line](https://discourse.cmake.org/t/ninja-generator-precise-control-over-command-line/3683)

<div class="topic-metadata">

**Author:** [@decimad](https://discourse.cmake.org/u/decimad)\
**Replies:** 1\
**Last updated:** [July 3, 2021, 10:40am UTC](https://discourse.cmake.org/t/ninja-generator-precise-control-over-command-line/3683 "2021-07-03T10:40:26Z")

</div>

Hi there, I’m in the unfortunate position that I need to produce particular build rules given my specific build tools. I’m using CMake + Ninja Generator in a particular controled version (3.18). I found out about the …

---

## [testing 3rd party package major version from full versoin](https://discourse.cmake.org/t/testing-3rd-party-package-major-version-from-full-versoin/3675)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [July 2, 2021, 4:16pm UTC](https://discourse.cmake.org/t/testing-3rd-party-package-major-version-from-full-versoin/3675 "2021-07-02T16:16:19Z")

</div>

Hi, I’ve got a 3rd party package (namely gdal) that only report its full version.x.y.z in \_VERSION variable but it does not define \_VERSION\_MAJOR (for instance) Is there a way to test only the x part? (I want to set s…

---

## [Measuring the times while building](https://discourse.cmake.org/t/measuring-the-times-while-building/3660)

<div class="topic-metadata">

**Author:** [@NeoCortex97](https://discourse.cmake.org/u/NeoCortex97)\
**Replies:** 8\
**Last updated:** [July 2, 2021, 6:11am UTC](https://discourse.cmake.org/t/measuring-the-times-while-building/3660 "2021-07-02T06:11:59Z")

</div>

Is there any practical way to generate build benchmarks? I want them to try and find code that takes time to compile in a huge code base, so I can try to improve the code in question. Ros catkin does it, so I suppose it…

---

## [When to reconfigure vs configure from scratch? Why?](https://discourse.cmake.org/t/when-to-reconfigure-vs-configure-from-scratch-why/3670)

<div class="topic-metadata">

**Author:** [@thejohnfreeman](https://discourse.cmake.org/u/thejohnfreeman)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 10:50pm UTC](https://discourse.cmake.org/t/when-to-reconfigure-vs-configure-from-scratch-why/3670 "2021-07-01T22:50:31Z")

</div>

In my testing, I’ve noticed that there are many configuration changes that do not affect the build. Say I initially configure and build my project like this (I’m testing with 3.17): cmake -DBUILD\_SHARED\_LIBS=OFF -DCMAKE…

---

## [CMAKE\_LIBRARY\_ARCHITECTURE doesn't work](https://discourse.cmake.org/t/cmake-library-architecture-doesnt-work/3669)

<div class="topic-metadata">

**Author:** [@Aleksey\_Midenkov](https://discourse.cmake.org/u/Aleksey_Midenkov)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 9:16pm UTC](https://discourse.cmake.org/t/cmake-library-architecture-doesnt-work/3669 "2021-07-01T21:16:25Z")

</div>

I run cmake with -DCMAKE\_INSTALL\_PREFIX=/usr -DCMAKE\_LIBRARY\_ARCHITECTURE=i386-linux-gnu but it finds .so libraries in x86\_64-linux-gnu though both versions installed: dpkg -S libgnutls.so libgnutls28-dev:i386: /usr/l…

---

## [CMake 3.21 | Global NO\_CACHE?](https://discourse.cmake.org/t/cmake-3-21-global-no-cache/3664)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 6\
**Last updated:** [July 1, 2021, 12:53pm UTC](https://discourse.cmake.org/t/cmake-3-21-global-no-cache/3664 "2021-07-01T12:53:24Z")

</div>

As of CMake 3.21 there is a NO\_CACHE for find\_\* commands. The find\_file(), find\_path(), find\_program(), and find\_library() commands gained the option NO\_CACHE to store find result in normal variable. Is there a way to …

---

## [try\_compile() checks fail with conditional CMAKE\_EXECUTABLE\_SUFFIX](https://discourse.cmake.org/t/try-compile-checks-fail-with-conditional-cmake-executable-suffix/3606)

<div class="topic-metadata">

**Author:** [@petwu](https://discourse.cmake.org/u/petwu)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 12:37pm UTC](https://discourse.cmake.org/t/try-compile-checks-fail-with-conditional-cmake-executable-suffix/3606 "2021-07-01T12:37:56Z")

</div>

I am trying to build a application for VxWorks 7. VxWorks provides a platform (VxWorks.cmake) and toolchain file for CMake that I have adapted a little bit. The reason for my issue is that VxWorks has two types of execu…

---

## [How to use generator expression in target\_sources?](https://discourse.cmake.org/t/how-to-use-generator-expression-in-target-sources/3662)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 2\
**Last updated:** [June 30, 2021, 3:00pm UTC](https://discourse.cmake.org/t/how-to-use-generator-expression-in-target-sources/3662 "2021-06-30T15:00:07Z")

</div>

Sorry this is a bit basic but how do I use a generator expression in target\_sources, to conditionally add some source files? Here is what I need to do: option(extras "some help" "${extras\_default}") target\_sources(${\_…

---

## [CMake preset and VsDevCmd.bat / yocto environment](https://discourse.cmake.org/t/cmake-preset-and-vsdevcmd-bat-yocto-environment/3519)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 4\
**Last updated:** [June 30, 2021, 9:47am UTC](https://discourse.cmake.org/t/cmake-preset-and-vsdevcmd-bat-yocto-environment/3519 "2021-06-30T09:47:03Z")

</div>

There is the environment element in CMakePresets.json to specify environment variables. However, the usual way to get the build tools into PATH and other variables is to run a script before executing cmake. Can this be…

---

## [Best way to form target executable path at configure time?](https://discourse.cmake.org/t/best-way-to-form-target-executable-path-at-configure-time/3658)

<div class="topic-metadata">

**Author:** [@Zachary\_Turner](https://discourse.cmake.org/u/Zachary_Turner)\
**Replies:** 5\
**Last updated:** [June 29, 2021, 10:36pm UTC](https://discourse.cmake.org/t/best-way-to-form-target-executable-path-at-configure-time/3658 "2021-06-29T22:36:59Z")

</div>

I realize this is fraught with peril due to multi-config generators, but we need to be able to write metadata about the build to a json file that is consumed by one of our executables. In particular, this means collecti…

---

## [protobuf\_generate\_cpp and fetchedconttent](https://discourse.cmake.org/t/protobuf-generate-cpp-and-fetchedconttent/3644)

<div class="topic-metadata">

**Author:** [@wannamak](https://discourse.cmake.org/u/wannamak)\
**Replies:** 5\
**Last updated:** [June 28, 2021, 11:33pm UTC](https://discourse.cmake.org/t/protobuf-generate-cpp-and-fetchedconttent/3644 "2021-06-28T23:33:59Z")

</div>

Is it possible to FetchContent\_Declare and FetchContent\_MakeAvailable a Google protocol buffers version, then have find\_package(Protobuf) use the resulting built protoc and libraries? If I force find\_package to use the …

[Previous page](https://discourse.cmake.org/c/usage/12.md?page=74)

[Next page](https://discourse.cmake.org/c/usage/12.md?page=76)
