# Code

**URL:** https://discourse.cmake.org/c/code/11.md?page=55

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

**Page:** 56

---

## [How to specify system include directories as \`-isystem\` in CMake](https://discourse.cmake.org/t/how-to-specify-system-include-directories-as-isystem-in-cmake/4011)

<div class="topic-metadata">

**Author:** [@alvaropalmaaste](https://discourse.cmake.org/u/alvaropalmaaste)\
**Replies:** 2\
**Last updated:** [September 1, 2021, 10:57pm UTC](https://discourse.cmake.org/t/how-to-specify-system-include-directories-as-isystem-in-cmake/4011 "2021-09-01T22:57:33Z")

</div>

In CMake, I know I can do target\_include\_directories(my\_target SYSTEM PRIVATE ${SOME\_THIRD\_PARTY\_LIBRARY\_INCLUDES}) to avoid catching warnings coming from that library that could stop my compilation if I have those war…

---

## [How to specify PDB file generation for C#/CSharp projects using CMake](https://discourse.cmake.org/t/how-to-specify-pdb-file-generation-for-c-csharp-projects-using-cmake/4009)

<div class="topic-metadata">

**Author:** [@StefanBattmer](https://discourse.cmake.org/u/StefanBattmer)\
**Replies:** 0\
**Last updated:** [September 1, 2021, 12:31pm UTC](https://discourse.cmake.org/t/how-to-specify-pdb-file-generation-for-c-csharp-projects-using-cmake/4009 "2021-09-01T12:31:42Z")

</div>

Hi there, is there a way to tell CMake to set the DebugType property for C# projects using CMake? What I would like to be able to do is to set it to pdbonly for Release Builds since without that my code coverage analysi…

---

## [Include Meson project with CMake FetchContent](https://discourse.cmake.org/t/include-meson-project-with-cmake-fetchcontent/3985)

<div class="topic-metadata">

**Author:** [@junglie85](https://discourse.cmake.org/u/junglie85)\
**Replies:** 4\
**Last updated:** [August 30, 2021, 5:28pm UTC](https://discourse.cmake.org/t/include-meson-project-with-cmake-fetchcontent/3985 "2021-08-30T17:28:27Z")

</div>

I’m trying to move to using the bleeding branch, which comes with Meson build system instead of CMake. Does anyone have any advice on how to add this as a dependency using FetchContent? I’ve tried the following, but no l…

---

## [CMAKE\_BUILD\_TYPE doc question](https://discourse.cmake.org/t/cmake-build-type-doc-question/3990)

<div class="topic-metadata">

**Author:** [@shivupa](https://discourse.cmake.org/u/shivupa)\
**Replies:** 6\
**Last updated:** [August 28, 2021, 8:35pm UTC](https://discourse.cmake.org/t/cmake-build-type-doc-question/3990 "2021-08-28T20:35:42Z")

</div>

Note that configuration names are case-insensitive. The value of this variable will be the same as it is specified when invoking CMake. For instance, if -DCMAKE\_BUILD\_TYPE=ReLeAsE is specified, then the value of CMAKE\_B…

---

## [cpack -G deb not working even though I set maintainer's name](https://discourse.cmake.org/t/cpack-g-deb-not-working-even-though-i-set-maintainers-name/3993)

<div class="topic-metadata">

**Author:** [@9d6e13cb300898596d35](https://discourse.cmake.org/u/9d6e13cb300898596d35)\
**Replies:** 2\
**Last updated:** [August 27, 2021, 7:58pm UTC](https://discourse.cmake.org/t/cpack-g-deb-not-working-even-though-i-set-maintainers-name/3993 "2021-08-27T19:58:54Z")

</div>

– Build files have been written to: /root/dev-learn/build-tools/cmake-tutorial/Tutorial-new/build CPack: Create package using DEB CPack: Install projects CPack: - Run preinstall target for: Tutorial CPack: - Install …

---

## [CMake BuildInParallel flag for MSVC](https://discourse.cmake.org/t/cmake-buildinparallel-flag-for-msvc/3924)

<div class="topic-metadata">

**Author:** [@1114](https://discourse.cmake.org/u/1114)\
**Replies:** 3\
**Last updated:** [August 27, 2021, 1:50pm UTC](https://discourse.cmake.org/t/cmake-buildinparallel-flag-for-msvc/3924 "2021-08-27T13:50:46Z")

</div>

Hello! How can i set BuildInParallel flag for MSVC for custom target? I found this issue but there are no solution: https://gitlab.kitware.com/cmake/cmake/-/issues/18405

---

## [How to define fixture that executes once, no matter where I run \`ctest\`?](https://discourse.cmake.org/t/how-to-define-fixture-that-executes-once-no-matter-where-i-run-ctest/3978)

<div class="topic-metadata">

**Author:** [@brettdh](https://discourse.cmake.org/u/brettdh)\
**Replies:** 1\
**Last updated:** [August 25, 2021, 11:41pm UTC](https://discourse.cmake.org/t/how-to-define-fixture-that-executes-once-no-matter-where-i-run-ctest/3978 "2021-08-25T23:41:59Z")

</div>

I have a test fixture for starting a database server: # pg\_setup.cmake add\_test(NAME setupPostgres COMMAND /path/to/pg-setup) add\_test(NAME teardownPostgres COMMAND /path/to/pg-teardown) set\_tests\_properties(setupPost…

---

## [Unexpected behavior for INSTALL directory](https://discourse.cmake.org/t/unexpected-behavior-for-install-directory/3955)

<div class="topic-metadata">

**Author:** [@bjornblissing](https://discourse.cmake.org/u/bjornblissing)\
**Replies:** 8\
**Last updated:** [August 25, 2021, 1:44pm UTC](https://discourse.cmake.org/t/unexpected-behavior-for-install-directory/3955 "2021-08-25T13:44:01Z")

</div>

I have added section in my script that handles adding third party DLL files to my install. It looks something like this: install(DIRECTORY ${THIRDPARTY\_BIN\_DIR} DESTINATION "bin" FILES\_MATCHING PATTERN "\*.dll") The id…

---

## [Skip dependency checks in CMake + Ninja builds](https://discourse.cmake.org/t/skip-dependency-checks-in-cmake-ninja-builds/3220)

<div class="topic-metadata">

**Author:** [@gshipman](https://discourse.cmake.org/u/gshipman)\
**Replies:** 9\
**Last updated:** [August 23, 2021, 12:08am UTC](https://discourse.cmake.org/t/skip-dependency-checks-in-cmake-ninja-builds/3220 "2021-08-23T00:08:24Z")

</div>

Hello, We have a very large code that uses CMake + Ninja which can take quite some time to build. We sometimes find ourselves doing printf style debugging within the code which can trigger rebuilding of large portions o…

---

## [generate slow / pauses for \> 30 seconds starting with 3.21](https://discourse.cmake.org/t/generate-slow-pauses-for-30-seconds-starting-with-3-21/3901)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 5\
**Last updated:** [August 19, 2021, 4:31pm UTC](https://discourse.cmake.org/t/generate-slow-pauses-for-30-seconds-starting-with-3-21/3901 "2021-08-19T16:31:30Z")

</div>

Since I can remember, on Windows, for our project (open\_iA), there was a short “pause” at the beginning of the “generate” phase; meaning, for example in the GUI, there is no visual feedback in the first few seconds after…

---

## [How are circular generator expressions evaluated?](https://discourse.cmake.org/t/how-are-circular-generator-expressions-evaluated/3933)

<div class="topic-metadata">

**Author:** [@alex](https://discourse.cmake.org/u/alex)\
**Replies:** 5\
**Last updated:** [August 19, 2021, 3:29pm UTC](https://discourse.cmake.org/t/how-are-circular-generator-expressions-evaluated/3933 "2021-08-19T15:29:11Z")

</div>

Consider the following: cmake\_minimum\_required(VERSION 3.21) project(test) add\_executable(foo foo.cpp) target\_compile\_definitions(foo PRIVATE "FOO$\<TARGET\_PROPERTY:bar,COMPILE\_DEFINITIONS\>") add\_executable(bar bar.…

---

## [How not to have dollar sign in target\_link\_options mangled?](https://discourse.cmake.org/t/how-not-to-have-dollar-sign-in-target-link-options-mangled/3939)

<div class="topic-metadata">

**Author:** [@mmarczell-graphisoft](https://discourse.cmake.org/u/mmarczell-graphisoft)\
**Replies:** 6\
**Last updated:** [August 19, 2021, 10:19am UTC](https://discourse.cmake.org/t/how-not-to-have-dollar-sign-in-target-link-options-mangled/3939 "2021-08-19T10:19:22Z")

</div>

If I have this CMake script: add\_link\_options(--preload-file=temp$.txt) add\_executable(main main.cpp) or add\_executable(main main.cpp) target\_link\_options(main PUBLIC --preload-file=temp$.txt) and an arbitrary file n…

---

## [CMake/CPack with system extensions MacOS](https://discourse.cmake.org/t/cmake-cpack-with-system-extensions-macos/959)

<div class="topic-metadata">

**Author:** [@skratchi](https://discourse.cmake.org/u/skratchi)\
**Replies:** 3\
**Last updated:** [August 18, 2021, 12:51pm UTC](https://discourse.cmake.org/t/cmake-cpack-with-system-extensions-macos/959 "2021-08-18T12:51:02Z")

</div>

The concept of system extensions or DEXTs is fairly new to MacOS. My team is in process of developing one. Is it planed to support this technology? Building and signing a dext with cmake would be a great extension. Anoth…

---

## [Idiomatic way to deal with huge number of include directories](https://discourse.cmake.org/t/idiomatic-way-to-deal-with-huge-number-of-include-directories/3947)

<div class="topic-metadata">

**Author:** [@tom](https://discourse.cmake.org/u/tom)\
**Replies:** 3\
**Last updated:** [August 17, 2021, 9:19pm UTC](https://discourse.cmake.org/t/idiomatic-way-to-deal-with-huge-number-of-include-directories/3947 "2021-08-17T21:19:18Z")

</div>

Hi, I’m writing a CMake build system for a very large, very elderly code base. It contains tens of thousands of source code files, most of which live in a complex nested directory structure. Each target is likely to h…

---

## [Following build on Win10 - .dll and .a and not .lib with BUILD\_SHARED\_LIBS=ON](https://discourse.cmake.org/t/following-build-on-win10-dll-and-a-and-not-lib-with-build-shared-libs-on/3936)

<div class="topic-metadata">

**Author:** [@mornesto](https://discourse.cmake.org/u/mornesto)\
**Replies:** 1\
**Last updated:** [August 16, 2021, 3:28pm UTC](https://discourse.cmake.org/t/following-build-on-win10-dll-and-a-and-not-lib-with-build-shared-libs-on/3936 "2021-08-16T15:28:54Z")

</div>

Hi, Following a build of some third party source code I’m using, I noticed that in \\lib folder there was a .dll and .a (static linux) libraries. My setup is Win10 x64 and I’m using MSYS2 Mingw 64-bit. I was expecting t…

---

## [FindMPI insists on Fortran](https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922)

<div class="topic-metadata">

**Author:** [@jsuthe](https://discourse.cmake.org/u/jsuthe)\
**Replies:** 2\
**Last updated:** [August 14, 2021, 6:17pm UTC](https://discourse.cmake.org/t/findmpi-insists-on-fortran/3922 "2021-08-14T18:17:00Z")

</div>

I’m getting failures when finding MPI: Could NOT find MPI (missing: MPI\_CXX\_FOUND CXX) Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled. My CMake code: find\_pa…

---

## [CMake Qt, Linking error when I turn an own library from SHARED, to STATIC](https://discourse.cmake.org/t/cmake-qt-linking-error-when-i-turn-an-own-library-from-shared-to-static/2952)

<div class="topic-metadata">

**Author:** [@Jos](https://discourse.cmake.org/u/Jos)\
**Replies:** 2\
**Last updated:** [August 13, 2021, 6:53am UTC](https://discourse.cmake.org/t/cmake-qt-linking-error-when-i-turn-an-own-library-from-shared-to-static/2952 "2021-08-13T06:53:13Z")

</div>

Hi, I have a project with a library and amn app that link the library from different path. The Project compiles fine if I link the library as SHARED, but when I try turn to STATIC, I get the next report: \[100%\] Linkin…

---

## [SET(CMAKE\_SYSTEM\_VERSION) unsuccessful for 10.0.20348.0](https://discourse.cmake.org/t/set-cmake-system-version-unsuccessful-for-10-0-20348-0/3929)

<div class="topic-metadata">

**Author:** [@kvynlim](https://discourse.cmake.org/u/kvynlim)\
**Replies:** 0\
**Last updated:** [August 13, 2021, 5:26am UTC](https://discourse.cmake.org/t/set-cmake-system-version-unsuccessful-for-10-0-20348-0/3929 "2021-08-13T05:26:08Z")

</div>

My project requires Target Platform Version 10.0.20348.0 to build without error. Currently, I use the Retarget Solution in Visual Studio 2015 to change the Target Platform Version. I want to be able to build my project w…

---

## [Turn Address Sanitizer when available](https://discourse.cmake.org/t/turn-address-sanitizer-when-available/3891)

<div class="topic-metadata">

**Author:** [@eri0](https://discourse.cmake.org/u/eri0)\
**Replies:** 3\
**Last updated:** [August 11, 2021, 3:31pm UTC](https://discourse.cmake.org/t/turn-address-sanitizer-when-available/3891 "2021-08-11T15:31:01Z")

</div>

Hi, I am trying to create an option in my CMake builds that turns on Address Sanitizer when selected. I found this for Xcode: set(CMAKE\_XCODE\_GENERATE\_SCHEME ON) set(CMAKE\_XCODE\_SCHEME\_ADDRESS\_SANITIZER ON) set(CMAKE\_…

---

## [Reject extra arguments to a function](https://discourse.cmake.org/t/reject-extra-arguments-to-a-function/3895)

<div class="topic-metadata">

**Author:** [@Eric\_Malenfant](https://discourse.cmake.org/u/Eric_Malenfant)\
**Replies:** 1\
**Last updated:** [August 9, 2021, 11:49pm UTC](https://discourse.cmake.org/t/reject-extra-arguments-to-a-function/3895 "2021-08-09T23:49:06Z")

</div>

AFAIU, any function can be invoked with extra arguments. For example: function(Takes2Args MyArg1, MyArg2) #do stuff ... endfunction() can be invoked like this without error: TakesTwoArgs("one" "two" "three") I’d …

---

## [if(... EQUAL 0) syntax](https://discourse.cmake.org/t/if-equal-0-syntax/3886)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 1\
**Last updated:** [August 6, 2021, 10:09pm UTC](https://discourse.cmake.org/t/if-equal-0-syntax/3886 "2021-08-06T22:09:39Z")

</div>

I believed correct syntax for the if(EQUAL) would be like try\_run(runcode buildOK ...) if(runcode EQUAL 0) endif() That usually works, but I ran into a CentOS 8 system where even though message(STATUS ${runcode}) sho…

---

## [Ninja code generator does not build in correct order when using protobuf and custom\_command](https://discourse.cmake.org/t/ninja-code-generator-does-not-build-in-correct-order-when-using-protobuf-and-custom-command/3730)

<div class="topic-metadata">

**Author:** [@Acki](https://discourse.cmake.org/u/Acki)\
**Replies:** 8\
**Last updated:** [August 6, 2021, 6:45am UTC](https://discourse.cmake.org/t/ninja-code-generator-does-not-build-in-correct-order-when-using-protobuf-and-custom-command/3730 "2021-08-06T06:45:55Z")

</div>

I have a project which is using protobuf and a custom command. However I get a compile error, because my custom\_command is not executed in the correct order. The problem occurs only with the ninja code generator. With …

---

## [Unable to fully build Windows UMDF Driver Using CMake](https://discourse.cmake.org/t/unable-to-fully-build-windows-umdf-driver-using-cmake/2368)

<div class="topic-metadata">

**Author:** [@nsulmol](https://discourse.cmake.org/u/nsulmol)\
**Replies:** 11\
**Last updated:** [August 4, 2021, 12:20pm UTC](https://discourse.cmake.org/t/unable-to-fully-build-windows-umdf-driver-using-cmake/2368 "2021-08-04T12:20:28Z")

</div>

Hello everyone, I’m running into issues trying to compile a Windows UMDF driver using CMake version 3.18+. More specifically, I am able to compile, but run into a strange ZERO\_CHECK error that causes the build to fail. …

---

## [Possible to quiet specific installs?](https://discourse.cmake.org/t/possible-to-quiet-specific-installs/3869)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 0\
**Last updated:** [August 3, 2021, 12:29pm UTC](https://discourse.cmake.org/t/possible-to-quiet-specific-installs/3869 "2021-08-03T12:29:29Z")

</div>

I think the answer to this is “no” from my reading of the docs, but I want to be sure. In my project, I have this little chunk of code from @scivision where we auto-gitignore our build dirs and I then use install() to au…

---

## [Generator Expressions in add\_custom\_command COMMENT field](https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865)

<div class="topic-metadata">

**Author:** [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Replies:** 2\
**Last updated:** [August 2, 2021, 5:56pm UTC](https://discourse.cmake.org/t/generator-expressions-in-add-custom-command-comment-field/3865 "2021-08-02T17:56:24Z")

</div>

Im trying to add a custom command, which is working fine except the “comment” section add\_custom\_command(TARGET shared\_lib POST\_BUILD COMMAND “${CMAKE\_COMMAND}” -E copy “$\<TARGET\_FILE:shared\_lib\>” “$\<TARGET\_FILE\_DIR:ma…

---

## [Create a library by linking link external library](https://discourse.cmake.org/t/create-a-library-by-linking-link-external-library/3844)

<div class="topic-metadata">

**Author:** [@swaraj\_somala](https://discourse.cmake.org/u/swaraj_somala)\
**Replies:** 1\
**Last updated:** [July 28, 2021, 1:38pm UTC](https://discourse.cmake.org/t/create-a-library-by-linking-link-external-library/3844 "2021-07-28T13:38:43Z")

</div>

I am using yocto build environment for my project. There are multiple applications in the project and some of them are depending on one third party library(It contains the \*.s0 files, header files). So I am planning to c…

---

## [CLang and MSVC mixes up, configuration error](https://discourse.cmake.org/t/clang-and-msvc-mixes-up-configuration-error/3846)

<div class="topic-metadata">

**Author:** [@Dharani\_Prasad](https://discourse.cmake.org/u/Dharani_Prasad)\
**Replies:** 0\
**Last updated:** [July 28, 2021, 10:18am UTC](https://discourse.cmake.org/t/clang-and-msvc-mixes-up-configuration-error/3846 "2021-07-28T10:18:38Z")

</div>

Hello, I’m trying to configure a project using Qt, while I try to open the project the compiler pops this error and configuration is failing. The current configuration mixes Clang and MSVC or some other CL compatible c…

---

## [condition comparison in if](https://discourse.cmake.org/t/condition-comparison-in-if/3842)

<div class="topic-metadata">

**Author:** [@TaddeusPunkt](https://discourse.cmake.org/u/TaddeusPunkt)\
**Replies:** 1\
**Last updated:** [July 28, 2021, 7:45am UTC](https://discourse.cmake.org/t/condition-comparison-in-if/3842 "2021-07-28T07:45:20Z")

</div>

Hi, i tried to do a short test script to see differences in my system when comparing different conditions. set(BUILD\_SHARED\_RUNTIME2 TRUE) message(STATUS “Boost Linkage Shared: ${BUILD\_SHARED\_RUNTIME2}”) if(BUILD\_SHA…

---

## [Unknown CMake command "get\_test\_property" in TEST\_INCLUDE\_FILES](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828)

<div class="topic-metadata">

**Author:** [@Eric\_Pederson](https://discourse.cmake.org/u/Eric_Pederson)\
**Replies:** 7\
**Last updated:** [July 27, 2021, 2:53pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-get-test-property-in-test-include-files/3828 "2021-07-27T14:53:30Z")

</div>

I helping the Catch2 team with CTest label support (see Make catch tags work with ctest labels · Issue #1590 · catchorg/Catch2 · GitHub). The catch\_discover\_tests CMake command that comes with Catch2 uses the TEST\_INCLU…

---

## [one bundle target for multiple targets](https://discourse.cmake.org/t/one-bundle-target-for-multiple-targets/3836)

<div class="topic-metadata">

**Author:** [@eri0](https://discourse.cmake.org/u/eri0)\
**Replies:** 4\
**Last updated:** [July 27, 2021, 10:51am UTC](https://discourse.cmake.org/t/one-bundle-target-for-multiple-targets/3836 "2021-07-27T10:51:17Z")

</div>

Hi, I have a project that produces 8 executable binaries, each as it’s own target. Is it possible to have a “bundle-like” pseudo target I could use to build these 8 binaries that are built with add\_executable ? Currentl…

[Previous page](https://discourse.cmake.org/c/code/11.md?page=54)

[Next page](https://discourse.cmake.org/c/code/11.md?page=56)
