# Code

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

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

**Page:** 59

---

## [CMake regex](https://discourse.cmake.org/t/cmake-regex/3439)

<div class="topic-metadata">

**Author:** [@mscofield0](https://discourse.cmake.org/u/mscofield0)\
**Replies:** 1\
**Last updated:** [June 1, 2021, 1:38pm UTC](https://discourse.cmake.org/t/cmake-regex/3439 "2021-06-01T13:38:29Z")

</div>

I was just stunned by the fact CMake does not support non-capture groups. Please add it.

---

## [Empty FindOpenMP variables](https://discourse.cmake.org/t/empty-findopenmp-variables/3449)

<div class="topic-metadata">

**Author:** [@gzauhar](https://discourse.cmake.org/u/gzauhar)\
**Replies:** 0\
**Last updated:** [May 31, 2021, 9:03pm UTC](https://discourse.cmake.org/t/empty-findopenmp-variables/3449 "2021-05-31T21:03:01Z")

</div>

Hi there! I have weird problem with CMake/IntelFortran/OpenMP setup. Following code snippet works as intended on Linux with Intel Fortran 2020. Code compiles, runs and produces correct result. On Windows with Intel For…

---

## [\--config since 3.20](https://discourse.cmake.org/t/config-since-3-20/3446)

<div class="topic-metadata">

**Author:** [@Sergey\_K](https://discourse.cmake.org/u/Sergey_K)\
**Replies:** 1\
**Last updated:** [May 31, 2021, 6:05pm UTC](https://discourse.cmake.org/t/config-since-3-20/3446 "2021-05-31T18:05:45Z")

</div>

A few days ago I updated from 3.19 to 3.20 and my project failed to build because I use ExternalProject\_Add and pass --config to subrojects, but --config has gone. For example, if we run cmake this way: $ cmake --config…

---

## [Python Interpreter found but Python\_EXECUTABLE not populated](https://discourse.cmake.org/t/python-interpreter-found-but-python-executable-not-populated/3398)

<div class="topic-metadata">

**Author:** [@satrapes](https://discourse.cmake.org/u/satrapes)\
**Replies:** 7\
**Last updated:** [May 31, 2021, 9:21am UTC](https://discourse.cmake.org/t/python-interpreter-found-but-python-executable-not-populated/3398 "2021-05-31T09:21:44Z")

</div>

Excerpt from my CMakeLists.txt add\_custom\_command( OUTPUT ${PROJECT\_SOURCE\_DIR}/tests/bit\_tests\_lut.c COMMAND ${Python\_EXECUTABLE} ${PROJECT\_SOURCE\_DIR}/python/generate\_bit\_lut\_for\_unit\_tests.py DEPENDS ${PR…

---

## [How to properly configure CMake script to run with osx\_deployment\_target 10.10?](https://discourse.cmake.org/t/how-to-properly-configure-cmake-script-to-run-with-osx-deployment-target-10-10/3395)

<div class="topic-metadata">

**Author:** [@lolgear](https://discourse.cmake.org/u/lolgear)\
**Replies:** 11\
**Last updated:** [May 29, 2021, 3:45pm UTC](https://discourse.cmake.org/t/how-to-properly-configure-cmake-script-to-run-with-osx-deployment-target-10-10/3395 "2021-05-29T15:45:30Z")

</div>

History I would like to build libgit2 project with the following script #!/bin/sh export MACOSX\_DEPLOYMENT\_TARGET=10.10 rm -rf "xcode" mkdir "xcode" cd "xcode" cmake -G "Xcode" .. open "libgit2.xcodeproj" Open Xcode …

---

## [integration of inspxe-cl](https://discourse.cmake.org/t/integration-of-inspxe-cl/3404)

<div class="topic-metadata">

**Author:** [@grimgort](https://discourse.cmake.org/u/grimgort)\
**Replies:** 2\
**Last updated:** [May 27, 2021, 3:28pm UTC](https://discourse.cmake.org/t/integration-of-inspxe-cl/3404 "2021-05-27T15:28:47Z")

</div>

Hello, I wanted to know if it was possible to integrate the intel suite in the code analysis? For example, use inspxe-cl to do memory leak analysis instead of valgrind. Same for the gcov equivalent Thanks

---

## [Nvidia GPU: code performance is not as expected](https://discourse.cmake.org/t/nvidia-gpu-code-performance-is-not-as-expected/3413)

<div class="topic-metadata">

**Author:** [@comway](https://discourse.cmake.org/u/comway)\
**Replies:** 4\
**Last updated:** [May 27, 2021, 11:19am UTC](https://discourse.cmake.org/t/nvidia-gpu-code-performance-is-not-as-expected/3413 "2021-05-27T11:19:53Z")

</div>

Hello, This code will output two values, representing the address of a static variable. The two output values should be equal, but tested on the Nvidia, they are not equal. It is now expected that the problem lies in th…

---

## [Compilation option flags settings and default](https://discourse.cmake.org/t/compilation-option-flags-settings-and-default/3393)

<div class="topic-metadata">

**Author:** [@serge](https://discourse.cmake.org/u/serge)\
**Replies:** 1\
**Last updated:** [May 26, 2021, 10:34am UTC](https://discourse.cmake.org/t/compilation-option-flags-settings-and-default/3393 "2021-05-26T10:34:33Z")

</div>

Here is my code on windows OS: cmake\_minimum\_required (VERSION 3.19) project (try) set (CMAKE\_CXX\_FLAGS “”) set (CMAKE\_CXX\_FLAGS\_DEBUG “”) add\_executable(hello hello.cpp) hello.cpp got compiled in the following way…

---

## [clang-format integration](https://discourse.cmake.org/t/clang-format-integration/3358)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 8\
**Last updated:** [May 25, 2021, 7:41pm UTC](https://discourse.cmake.org/t/clang-format-integration/3358 "2021-05-25T19:41:48Z")

</div>

Is there any plans for a clang-format integration in cmake? cmake does provide a clean clang-tidy integration, but couldn’t find clang-format.

---

## [I need help with error building wheel for cmake on raspberry pi 4](https://discourse.cmake.org/t/i-need-help-with-error-building-wheel-for-cmake-on-raspberry-pi-4/3316)

<div class="topic-metadata">

**Author:** [@Ken\_Whitmore](https://discourse.cmake.org/u/Ken_Whitmore)\
**Replies:** 4\
**Last updated:** [May 22, 2021, 3:19am UTC](https://discourse.cmake.org/t/i-need-help-with-error-building-wheel-for-cmake-on-raspberry-pi-4/3316 "2021-05-22T03:19:07Z")

</div>

In order to install frequent-cron on my Raspberry Pi 4B, I’m trying to install cmake. To do so, I tried… sudo pip install cmake I expected it to set up cmake, but I’m getting the following output instead: pi@raspberr…

---

## [How to do "link-time polymorphism" right?](https://discourse.cmake.org/t/how-to-do-link-time-polymorphism-right/3381)

<div class="topic-metadata">

**Author:** [@Adam\_Badura](https://discourse.cmake.org/u/Adam_Badura)\
**Replies:** 1\
**Last updated:** [May 21, 2021, 11:11am UTC](https://discourse.cmake.org/t/how-to-do-link-time-polymorphism-right/3381 "2021-05-21T11:11:44Z")

</div>

In our project, we are doing “link-time polymorphism” to provide variants of the product and for testability. The second scenario is of interest here. We have a library (.so). For it, there are two targets: one provides…

---

## [cmake support for dyndep capability of ninja for own targets](https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378)

<div class="topic-metadata">

**Author:** [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Replies:** 2\
**Last updated:** [May 20, 2021, 3:35pm UTC](https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378 "2021-05-20T15:35:54Z")

</div>

Hi, I know ninja’s dyndep feature is used by cmake for fortran compiling (especially handling modules) I would like to use these dyndep feature for the process of generating files in build step (only using ninja). But…

---

## [ExternalProject\_Add + SOVERSION ?](https://discourse.cmake.org/t/externalproject-add-soversion/3367)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 1\
**Last updated:** [May 19, 2021, 4:08pm UTC](https://discourse.cmake.org/t/externalproject-add-soversion/3367 "2021-05-19T16:08:06Z")

</div>

Can I use SOVERSION on an external project? The external project build system does not create any symlinks to its so files.

---

## [External project does not use parallel jobs](https://discourse.cmake.org/t/external-project-does-not-use-parallel-jobs/3359)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 3\
**Last updated:** [May 19, 2021, 10:33am UTC](https://discourse.cmake.org/t/external-project-does-not-use-parallel-jobs/3359 "2021-05-19T10:33:09Z")

</div>

I have an external project created with ExternalProject\_Add, but this target is always being built with only one thread. Why doesn’t cmake pass the jobs flag to the external project build system?

---

## [How to discard/not use a target from imported CMake file](https://discourse.cmake.org/t/how-to-discard-not-use-a-target-from-imported-cmake-file/3361)

<div class="topic-metadata">

**Author:** [@theoremseeker](https://discourse.cmake.org/u/theoremseeker)\
**Replies:** 2\
**Last updated:** [May 18, 2021, 6:24pm UTC](https://discourse.cmake.org/t/how-to-discard-not-use-a-target-from-imported-cmake-file/3361 "2021-05-18T18:24:06Z")

</div>

I would like to use the Antlr framework in a project. I’m using CMake to build the project. I would like to use the SHARED library version of Antlr, not the STATIC one. Its CMake file contains targets for both. Antlr’s…

---

## [Environment variables and --warn-uninitialized](https://discourse.cmake.org/t/environment-variables-and-warn-uninitialized/3356)

<div class="topic-metadata">

**Author:** [@Panu](https://discourse.cmake.org/u/Panu)\
**Replies:** 1\
**Last updated:** [May 18, 2021, 1:04pm UTC](https://discourse.cmake.org/t/environment-variables-and-warn-uninitialized/3356 "2021-05-18T13:04:12Z")

</div>

Environment variables can be used in if command: if ($ENV{FOO}) message(STATUS “bar”) endif () This works as expected but produces a warning if cmake is executed with --warn-uninitialized and if FOO is not defined.…

---

## [Regex match exclude '\]' character](https://discourse.cmake.org/t/regex-match-exclude-character/3348)

<div class="topic-metadata">

**Author:** [@Person-93](https://discourse.cmake.org/u/Person-93)\
**Replies:** 0\
**Last updated:** [May 17, 2021, 2:59pm UTC](https://discourse.cmake.org/t/regex-match-exclude-character/3348 "2021-05-17T14:59:06Z")

</div>

I am trying to use regex to match bracketed text. It seems that cmake doesn’t like when I try to exclude a ‘\]’ in middle. I tested my regex here and it works as expected. I thought it would work for cmake as well. As fa…

---

## [Extract folders from include\_directories(SYSTEM)](https://discourse.cmake.org/t/extract-folders-from-include-directories-system/3303)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 4\
**Last updated:** [May 17, 2021, 7:01am UTC](https://discourse.cmake.org/t/extract-folders-from-include-directories-system/3303 "2021-05-17T07:01:16Z")

</div>

How can i read these include directories later? They are added to directory property INCLUDE\_DIRECTORIES, but how do I know which ones where added with SYSTEM and which were not?

---

## [How to make users of a library depend on its plugins](https://discourse.cmake.org/t/how-to-make-users-of-a-library-depend-on-its-plugins/3340)

<div class="topic-metadata">

**Author:** [@AnyOldName3](https://discourse.cmake.org/u/AnyOldName3)\
**Replies:** 0\
**Last updated:** [May 16, 2021, 11:23pm UTC](https://discourse.cmake.org/t/how-to-make-users-of-a-library-depend-on-its-plugins/3340 "2021-05-16T23:23:17Z")

</div>

In a project I work on, one of our dependencies, OpenSceneGraph, has a system where one component, osgDB, provides a uniform interface for loading lots of different types of file, and the loaders for individual files are…

---

## [mpool cmake program keep errors finaly I don't understant why cmake keep errors who seems repairs](https://discourse.cmake.org/t/mpool-cmake-program-keep-errors-finaly-i-dont-understant-why-cmake-keep-errors-who-seems-repairs/3330)

<div class="topic-metadata">

**Author:** [@Azaretdodo](https://discourse.cmake.org/u/Azaretdodo)\
**Replies:** 3\
**Last updated:** [May 15, 2021, 2:13pm UTC](https://discourse.cmake.org/t/mpool-cmake-program-keep-errors-finaly-i-dont-understant-why-cmake-keep-errors-who-seems-repairs/3330 "2021-05-15T14:13:53Z")

</div>

Hello, I am in work on mpool program for add solid state peripherial to open mpi program : I keep errors following : ""CMake Error at CMakeLists.txt:221 (add\_subdirectory): add\_subdirectory given source “scritps/ude…

---

## [Rerun custom command if project was reconfigured](https://discourse.cmake.org/t/rerun-custom-command-if-project-was-reconfigured/3328)

<div class="topic-metadata">

**Author:** [@Person-93](https://discourse.cmake.org/u/Person-93)\
**Replies:** 9\
**Last updated:** [May 15, 2021, 2:10pm UTC](https://discourse.cmake.org/t/rerun-custom-command-if-project-was-reconfigured/3328 "2021-05-15T14:10:24Z")

</div>

I want a custom command to be considered out of date if the project was reconfigured. My current solution is to touch a specific file in the build tree and make the command depend on it, but I get a warning that byproduc…

---

## [Using set\_tests\_properties for setting or unsetting multiple variables](https://discourse.cmake.org/t/using-set-tests-properties-for-setting-or-unsetting-multiple-variables/1612)

<div class="topic-metadata">

**Author:** [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)\
**Replies:** 6\
**Last updated:** [May 15, 2021, 12:36am UTC](https://discourse.cmake.org/t/using-set-tests-properties-for-setting-or-unsetting-multiple-variables/1612 "2021-05-15T00:36:05Z")

</div>

I’d like to use CTest to run some Python scripts; however, I need to run them with a different version of Python from the one which my system defaults to. Getting the tests to run with the correct version of Python is e…

---

## [\[resolved\] How do I debug missing find\_package module (CUDAToolkit) on a specific machine?](https://discourse.cmake.org/t/resolved-how-do-i-debug-missing-find-package-module-cudatoolkit-on-a-specific-machine/3327)

<div class="topic-metadata">

**Author:** [@EricAtORS](https://discourse.cmake.org/u/EricAtORS)\
**Replies:** 2\
**Last updated:** [May 14, 2021, 7:08pm UTC](https://discourse.cmake.org/t/resolved-how-do-i-debug-missing-find-package-module-cudatoolkit-on-a-specific-machine/3327 "2021-05-14T19:08:27Z")

</div>

Hi, I have a cmake project that is using find\_package(CUDAToolkit). I get this error: -- Could NOT find CUDAToolkit (missing: CUDAToolkit\_DIR) CMake Error at cmake/find\_voreen\_libraries.cmake:40 (find\_package): Coul…

---

## [How to create dynamic lib of \`libgit2\` using CMake](https://discourse.cmake.org/t/how-to-create-dynamic-lib-of-libgit2-using-cmake/3305)

<div class="topic-metadata">

**Author:** [@nivekithan](https://discourse.cmake.org/u/nivekithan)\
**Replies:** 5\
**Last updated:** [May 12, 2021, 5:49pm UTC](https://discourse.cmake.org/t/how-to-create-dynamic-lib-of-libgit2-using-cmake/3305 "2021-05-12T17:49:20Z")

</div>

First of all I have no experience with c and its ecosystem so the questions I ask could be too basic. I am trying to create dart bindings for libgit2. To do that I have to create dynamic library. I followed the steps fr…

---

## [FetchContent with authentication](https://discourse.cmake.org/t/fetchcontent-with-authentication/3293)

<div class="topic-metadata">

**Author:** [@kinoko](https://discourse.cmake.org/u/kinoko)\
**Replies:** 5\
**Last updated:** [May 12, 2021, 8:49am UTC](https://discourse.cmake.org/t/fetchcontent-with-authentication/3293 "2021-05-12T08:49:48Z")

</div>

I am trying to get FetchContent to download a pre-compiled library from a gitlab repository that requires authentication. On command line it looks like this: curl --header ‘PRIVATE-TOKEN: afw7f9sd87f’ https://repo.url/…

---

## [Detect VERBOSE build in a macro?](https://discourse.cmake.org/t/detect-verbose-build-in-a-macro/3296)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 3\
**Last updated:** [May 11, 2021, 10:17pm UTC](https://discourse.cmake.org/t/detect-verbose-build-in-a-macro/3296 "2021-05-11T22:17:45Z")

</div>

I have a macro currently that runs an add\_custom\_command to compile f2py code in a model of mine. In order to keep the make install step output “clean”, I run this command with \>& /dev/null because f2py is noisy. Very no…

---

## [Controlling link order with imported (INTERFACE) targets](https://discourse.cmake.org/t/controlling-link-order-with-imported-interface-targets/3295)

<div class="topic-metadata">

**Author:** [@brentd](https://discourse.cmake.org/u/brentd)\
**Replies:** 0\
**Last updated:** [May 11, 2021, 8:14pm UTC](https://discourse.cmake.org/t/controlling-link-order-with-imported-interface-targets/3295 "2021-05-11T20:14:27Z")

</div>

I have a project using the FFTW3 library and also trying to detect if the Intel MKL library is present. If it is present, I want to link the MKL before I link the FFTW library to enable the FFTW library to use the MKL. …

---

## [Generated sources and dependencies in Visual Studio](https://discourse.cmake.org/t/generated-sources-and-dependencies-in-visual-studio/3289)

<div class="topic-metadata">

**Author:** [@Maarten\_Braakhekke](https://discourse.cmake.org/u/Maarten_Braakhekke)\
**Replies:** 4\
**Last updated:** [May 11, 2021, 6:28am UTC](https://discourse.cmake.org/t/generated-sources-and-dependencies-in-visual-studio/3289 "2021-05-11T06:28:34Z")

</div>

I have a Fortran project which I’m porting to Intel Visual Fortran (parallel studio) on Windows. CMake (in my case) generates the Visual Studio solution and project files. A number of the source files are generated in p…

---

## [execute\_process() vs add\_custom\_command()](https://discourse.cmake.org/t/execute-process-vs-add-custom-command/3286)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 2\
**Last updated:** [May 10, 2021, 1:48pm UTC](https://discourse.cmake.org/t/execute-process-vs-add-custom-command/3286 "2021-05-10T13:48:03Z")

</div>

Simple question: When should I use one of them? Or a little biased: Why/When should I use execute\_process() over add\_custom\_command()? The difference between those two is, that execute\_process() works at configure t…

---

## [add target for python script](https://discourse.cmake.org/t/add-target-for-python-script/3283)

<div class="topic-metadata">

**Author:** [@Tzlil\_Gavra](https://discourse.cmake.org/u/Tzlil_Gavra)\
**Replies:** 1\
**Last updated:** [May 9, 2021, 9:29pm UTC](https://discourse.cmake.org/t/add-target-for-python-script/3283 "2021-05-09T21:29:36Z")

</div>

Hi It might be weird, but I happen to need to add a target to a project that is not a C program with main, but a script python. I’m looking for something like add\_executable(), but for my custom command. Something sim…

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

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