# Usage

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

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

**Page:** 40

---

## [Workflow presets not working in CMakeUserPresets](https://discourse.cmake.org/t/workflow-presets-not-working-in-cmakeuserpresets/8905)

<div class="topic-metadata">

**Author:** [@Braden](https://discourse.cmake.org/u/Braden)\
**Replies:** 2\
**Last updated:** [September 9, 2023, 7:46pm UTC](https://discourse.cmake.org/t/workflow-presets-not-working-in-cmakeuserpresets/8905 "2023-09-09T19:46:38Z")

</div>

Has anyone had success getting workflow presets to work in CMakeUserPresets? If I just include a single configure step, it works fine: { "version": 6, "cmakeMinimumRequired": { "major": 3, "minor": 25, …

---

## [CMake error inability to find C and C++ compiler in Visual Studio 2019 when generator set to Visual Studio 16 2019](https://discourse.cmake.org/t/cmake-error-inability-to-find-c-and-c-compiler-in-visual-studio-2019-when-generator-set-to-visual-studio-16-2019/8880)

<div class="topic-metadata">

**Author:** [@TryerGit](https://discourse.cmake.org/u/TryerGit)\
**Replies:** 5\
**Last updated:** [September 6, 2023, 5:23pm UTC](https://discourse.cmake.org/t/cmake-error-inability-to-find-c-and-c-compiler-in-visual-studio-2019-when-generator-set-to-visual-studio-16-2019/8880 "2023-09-06T17:23:57Z")

</div>

Hello, I have a project that I have natively compiled/built under VS 2019 (CL.exe, MSBuild.exe via .vcxproj and .sln files). I am able to build this under CMake as well when the generator is set to Ninja. However, when…

---

## [Undefined reference problems - Fortran](https://discourse.cmake.org/t/undefined-reference-problems-fortran/8837)

<div class="topic-metadata">

**Author:** [@Junru](https://discourse.cmake.org/u/Junru)\
**Replies:** 11\
**Last updated:** [September 6, 2023, 1:55am UTC](https://discourse.cmake.org/t/undefined-reference-problems-fortran/8837 "2023-09-06T01:55:10Z")

</div>

My objective is to link my object with the static lib files like opt/intel/mkl/lib/intel64/libmkl\_intel\_ilp64.a opt/intel/mkl/lib/intel64/libmkl\_sequential.a opt/intel/mkl/lib/intel64/libmkl\_core.a I have add some co…

---

## [Trying to include \<dirent.h\> into my cmake build](https://discourse.cmake.org/t/trying-to-include-dirent-h-into-my-cmake-build/8889)

<div class="topic-metadata">

**Author:** [@brody711](https://discourse.cmake.org/u/brody711)\
**Replies:** 1\
**Last updated:** [September 5, 2023, 10:57pm UTC](https://discourse.cmake.org/t/trying-to-include-dirent-h-into-my-cmake-build/8889 "2023-09-05T22:57:59Z")

</div>

Hello everyone, I’m very new to using cmake and installed it so that I could use the opencv2 library. However, I need to be able to use the \<dirent.h\> header file which is being pulled from my system path at “C:\\msys64\\…

---

## [Installing and configuring CDash](https://discourse.cmake.org/t/installing-and-configuring-cdash/8199)

<div class="topic-metadata">

**Author:** [@eamoc](https://discourse.cmake.org/u/eamoc)\
**Replies:** 2\
**Last updated:** [September 5, 2023, 7:55pm UTC](https://discourse.cmake.org/t/installing-and-configuring-cdash/8199 "2023-09-05T19:55:43Z")

</div>

Hi, I am trying to set yup CDash as per the instructions in: I am supposed to be directed to install.php, but I get a 503 Error. The setup doesnt provide an install.php. I tried running on my nginx server (with mariad…

---

## [Make command's equivalent in CMake for CPLEX library on Linux](https://discourse.cmake.org/t/make-commands-equivalent-in-cmake-for-cplex-library-on-linux/8873)

<div class="topic-metadata">

**Author:** [@TryerGit](https://discourse.cmake.org/u/TryerGit)\
**Replies:** 2\
**Last updated:** [September 4, 2023, 4:12pm UTC](https://discourse.cmake.org/t/make-commands-equivalent-in-cmake-for-cplex-library-on-linux/8873 "2023-09-04T16:12:44Z")

</div>

Hello, I have so far been using make to link to the CPLEX library. This library does not offer any cmake support but they provide the following guidance to link to their library: Setting up CPLEX on GNU/Linux/macOS - I…

---

## [Relying on relative includes (quoted) or explicit include directory flags](https://discourse.cmake.org/t/relying-on-relative-includes-quoted-or-explicit-include-directory-flags/6070)

<div class="topic-metadata">

**Author:** [@developer](https://discourse.cmake.org/u/developer)\
**Replies:** 3\
**Last updated:** [September 2, 2023, 12:41pm UTC](https://discourse.cmake.org/t/relying-on-relative-includes-quoted-or-explicit-include-directory-flags/6070 "2023-09-02T12:41:52Z")

</div>

Say you have a simple library like. / lib /-- foo.h /-- foo.cpp with a CMakeLists.txt like add\_library(lib) target\_sources(lib PRIVATE foo.cpp foo.h ) target\_include\_directories(lib PUBLIC # or INT…

---

## [ctest\_submit errors when sending https to experimental "self-signed" CDash server](https://discourse.cmake.org/t/ctest-submit-errors-when-sending-https-to-experimental-self-signed-cdash-server/8861)

<div class="topic-metadata">

**Author:** [@dlrdave](https://discourse.cmake.org/u/dlrdave)\
**Replies:** 2\
**Last updated:** [September 1, 2023, 4:42pm UTC](https://discourse.cmake.org/t/ctest-submit-errors-when-sending-https-to-experimental-self-signed-cdash-server/8861 "2023-09-01T16:42:24Z")

</div>

When attempting to send results to an experimental CDash server using ctest\_submit and an https URL, I am getting the following error message (which makes sense): Error when uploading file:... Error message was: schanne…

---

## [Undefined reference during project compilation](https://discourse.cmake.org/t/undefined-reference-during-project-compilation/8850)

<div class="topic-metadata">

**Author:** [@sabyasachi\_chatterje](https://discourse.cmake.org/u/sabyasachi_chatterje)\
**Replies:** 1\
**Last updated:** [September 1, 2023, 11:25am UTC](https://discourse.cmake.org/t/undefined-reference-during-project-compilation/8850 "2023-09-01T11:25:51Z")

</div>

Hello, I am trying to compile a project (based on the FEM library deal ii) with multiple source and header files. I am new to CMake. In the main directory, there is main.cc file. All other files including header and sou…

---

## [How to globally set extra linker option like -lstdc++fs](https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842)

<div class="topic-metadata">

**Author:** [@G\_T](https://discourse.cmake.org/u/G_T)\
**Replies:** 2\
**Last updated:** [August 31, 2023, 3:30pm UTC](https://discourse.cmake.org/t/how-to-globally-set-extra-linker-option-like-lstdc-fs/8842 "2023-08-31T15:30:25Z")

</div>

I’m trying to build some third-party software which is failing as I’m using gcc8. I have to pass -lstdc++fs as linker option. I cannot change cmake files so I would like to know if there is a way to set extra linker opt…

---

## [CMake library target brought in thru Conan - when linked to executable I can't get rid of full-path to library](https://discourse.cmake.org/t/cmake-library-target-brought-in-thru-conan-when-linked-to-executable-i-cant-get-rid-of-full-path-to-library/8847)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 6\
**Last updated:** [August 31, 2023, 1:34pm UTC](https://discourse.cmake.org/t/cmake-library-target-brought-in-thru-conan-when-linked-to-executable-i-cant-get-rid-of-full-path-to-library/8847 "2023-08-31T13:34:14Z")

</div>

I’m building a test application that links against a library provided by a Conan package. Through the use of some autogenerated CMake provided by Conan, that library is linked against as a target, such as: consumed-lib:…

---

## [Portable way of invoking the C preprocessor](https://discourse.cmake.org/t/portable-way-of-invoking-the-c-preprocessor/8825)

<div class="topic-metadata">

**Author:** [@erlendaasland](https://discourse.cmake.org/u/erlendaasland)\
**Replies:** 2\
**Last updated:** [August 30, 2023, 11:51am UTC](https://discourse.cmake.org/t/portable-way-of-invoking-the-c-preprocessor/8825 "2023-08-30T11:51:39Z")

</div>

I’ve been searching the web (including the CMake docs) for a portable way of invoking the preprocessor. In my case, specifically the C preprocessor. Until now, I haven’t found promising results, so unless someone can po…

---

## [Trying to statically link curl directory for CMake on Linux: undefined reference to \`curl\_easy\_init'](https://discourse.cmake.org/t/trying-to-statically-link-curl-directory-for-cmake-on-linux-undefined-reference-to-curl-easy-init/8835)

<div class="topic-metadata">

**Author:** [@HallofFamer](https://discourse.cmake.org/u/HallofFamer)\
**Replies:** 2\
**Last updated:** [August 29, 2023, 5:09pm UTC](https://discourse.cmake.org/t/trying-to-statically-link-curl-directory-for-cmake-on-linux-undefined-reference-to-curl-easy-init/8835 "2023-08-29T17:09:12Z")

</div>

I am able to get CMake to work on Windows, and on Linux I am struggling with CURL. Cant get vcpkg to work there, and I’ve decided to use static linking instead as its safe to assume most linux users do not change the def…

---

## [Do CMakePresets and CMakeUserPresets have to use the same version?](https://discourse.cmake.org/t/do-cmakepresets-and-cmakeuserpresets-have-to-use-the-same-version/8444)

<div class="topic-metadata">

**Author:** [@gcampbell-msft](https://discourse.cmake.org/u/gcampbell-msft)\
**Replies:** 3\
**Last updated:** [August 29, 2023, 6:34am UTC](https://discourse.cmake.org/t/do-cmakepresets-and-cmakeuserpresets-have-to-use-the-same-version/8444 "2023-08-29T06:34:29Z")

</div>

How does CMake handle the versions of CMakePresets versus CMakeUserPresets? Does the version have to be the same? If not, which version takes precedence? If so, does it simply exit with an error because the versions di…

---

## [Setting compiler flags in CMakeLists.txt](https://discourse.cmake.org/t/setting-compiler-flags-in-cmakelists-txt/8820)

<div class="topic-metadata">

**Author:** [@morpheus](https://discourse.cmake.org/u/morpheus)\
**Replies:** 3\
**Last updated:** [August 28, 2023, 1:51am UTC](https://discourse.cmake.org/t/setting-compiler-flags-in-cmakelists-txt/8820 "2023-08-28T01:51:42Z")

</div>

In my CMakeLists.txt I have: SET( CMAKE\_CXX\_FLAGS "-Ofast -DNDEBUG -std=c++20 -march=native -fpic -ftree-vectorize") However I found that CMake also adds following flags: -O3 -DNDEBUG -std=gnu++20 -arch arm64 I foun…

---

## [A lot of includes notification appears in building with "NMake Makefiles" generator and VS2019 in Japanese locale](https://discourse.cmake.org/t/a-lot-of-includes-notification-appears-in-building-with-nmake-makefiles-generator-and-vs2019-in-japanese-locale/4275)

<div class="topic-metadata">

**Author:** [@tmishima](https://discourse.cmake.org/u/tmishima)\
**Replies:** 9\
**Last updated:** [August 26, 2023, 5:18am UTC](https://discourse.cmake.org/t/a-lot-of-includes-notification-appears-in-building-with-nmake-makefiles-generator-and-vs2019-in-japanese-locale/4275 "2023-08-26T05:18:46Z")

</div>

When I try to build C applications with “NMake Makefiles” generator and VS2019 in Japanese locale, a lot of includes notification appears on the command prompt screen and so I tend to miss important messages. Here is a …

---

## [VS\_DEBUGGER\_ENVIRONMENT doesn't work for RelWithDebInfo](https://discourse.cmake.org/t/vs-debugger-environment-doesnt-work-for-relwithdebinfo/8802)

<div class="topic-metadata">

**Author:** [@Paul\_Baumer](https://discourse.cmake.org/u/Paul_Baumer)\
**Replies:** 0\
**Last updated:** [August 22, 2023, 4:10pm UTC](https://discourse.cmake.org/t/vs-debugger-environment-doesnt-work-for-relwithdebinfo/8802 "2023-08-22T16:10:57Z")

</div>

I have the following cmake line to set the debugger environment in Visual Studio. set\_property(TARGET Jing PROPERTY VS\_DEBUGGER\_ENVIRONMENT "DATA\_DIR=data-xyz" ) This works fine for Release and Debug configurations in …

---

## [Best practice for c++20 modules?](https://discourse.cmake.org/t/best-practice-for-c-20-modules/8800)

<div class="topic-metadata">

**Author:** [@Glad](https://discourse.cmake.org/u/Glad)\
**Replies:** 2\
**Last updated:** [August 22, 2023, 2:39pm UTC](https://discourse.cmake.org/t/best-practice-for-c-20-modules/8800 "2023-08-22T14:39:39Z")

</div>

Hi, Using CMake 3.27+ and clang 16/17+ (or gcc 13.2+), what would be the best way to have a project B import a module generated in a project A, out of tree ? I am on Linux. Many examples out there are not out-of-tree. …

---

## [CMake with vcpkg: CMAKE\_C\_COMPILER not set error on Ubuntu, but works fine on Windows](https://discourse.cmake.org/t/cmake-with-vcpkg-cmake-c-compiler-not-set-error-on-ubuntu-but-works-fine-on-windows/8791)

<div class="topic-metadata">

**Author:** [@HallofFamer](https://discourse.cmake.org/u/HallofFamer)\
**Replies:** 5\
**Last updated:** [August 22, 2023, 11:52am UTC](https://discourse.cmake.org/t/cmake-with-vcpkg-cmake-c-compiler-not-set-error-on-ubuntu-but-works-fine-on-windows/8791 "2023-08-22T11:52:29Z")

</div>

Hi, I am trying to set up a C project to be cross-platform with CMake and vcpkg. It works fine for me on windows, but on linux ubuntu sandbox it gives me this error when I run the following commands: git clone -b master…

---

## [Linker does not link libc.a](https://discourse.cmake.org/t/linker-does-not-link-libc-a/8711)

<div class="topic-metadata">

**Author:** [@everedero](https://discourse.cmake.org/u/everedero)\
**Replies:** 10\
**Last updated:** [August 21, 2023, 1:07pm UTC](https://discourse.cmake.org/t/linker-does-not-link-libc-a/8711 "2023-08-21T13:07:24Z")

</div>

I am migrating a project from STM32CubeIDE to CMake. It is a cross-compiled ARM project using the standard libraries (not nanolib). With CMake, it fails to link libc.a and links libg.a instead, with an error in CMakeErro…

---

## [How do I set the compiler version for Visual Studio generator with cmake presets](https://discourse.cmake.org/t/how-do-i-set-the-compiler-version-for-visual-studio-generator-with-cmake-presets/8779)

<div class="topic-metadata">

**Author:** [@Orhun\_Birsoy](https://discourse.cmake.org/u/Orhun_Birsoy)\
**Replies:** 1\
**Last updated:** [August 20, 2023, 11:31pm UTC](https://discourse.cmake.org/t/how-do-i-set-the-compiler-version-for-visual-studio-generator-with-cmake-presets/8779 "2023-08-20T23:31:55Z")

</div>

I have “14.36-17.6” and “14.37-17.7” build tools installed with VS 17.7.1. I would like to specify the compiler version to be used in a CMakePresets.json file. My CMakePresets.json file looks like the following: { "…

---

## [My first Fortran program with CMake](https://discourse.cmake.org/t/my-first-fortran-program-with-cmake/8685)

<div class="topic-metadata">

**Author:** [@Xahid](https://discourse.cmake.org/u/Xahid)\
**Replies:** 20\
**Last updated:** [August 20, 2023, 12:21pm UTC](https://discourse.cmake.org/t/my-first-fortran-program-with-cmake/8685 "2023-08-20T12:21:50Z")

</div>

This is my first time using CMake and I have just installed it. cmake version 3.27.1 CMake suite maintained and supported by Kitware (kitware.com/cmake). Now, I am trying to run the following project: GitHub - samans…

---

## [CTest performance drops when large number of tests defined](https://discourse.cmake.org/t/ctest-performance-drops-when-large-number-of-tests-defined/8725)

<div class="topic-metadata">

**Author:** [@another-pjohnson](https://discourse.cmake.org/u/another-pjohnson)\
**Replies:** 9\
**Last updated:** [August 18, 2023, 9:41pm UTC](https://discourse.cmake.org/t/ctest-performance-drops-when-large-number-of-tests-defined/8725 "2023-08-18T21:41:02Z")

</div>

I am using ctest as an infrastructure for randomized testing and I’m seeing some serious perf issues when the number of unique test grows beyond some bounds. Test are constructed within the test directory’s CMakeLists.t…

---

## [correct usage of CMP0011](https://discourse.cmake.org/t/correct-usage-of-cmp0011/7965)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 5\
**Last updated:** [August 18, 2023, 5:19pm UTC](https://discourse.cmake.org/t/correct-usage-of-cmp0011/7965 "2023-08-18T17:19:45Z")

</div>

Hi, I’m doing something like this: INSTALL(SCRIPT "Path/Script.cmake") In Script.cmake I’m doing a if (var IN\_LIST list) which, according to cmake warnings, requires CMP0057 being set to NEW. Yet it seems that Script.…

---

## [Tutorial command in cmake tutorial exercise](https://discourse.cmake.org/t/tutorial-command-in-cmake-tutorial-exercise/8757)

<div class="topic-metadata">

**Author:** [@Xahid](https://discourse.cmake.org/u/Xahid)\
**Replies:** 7\
**Last updated:** [August 18, 2023, 12:39pm UTC](https://discourse.cmake.org/t/tutorial-command-in-cmake-tutorial-exercise/8757 "2023-08-18T12:39:23Z")

</div>

I am following the tutorial: Step 1: A Basic Starting Point — CMake 3.27.3 Documentation The command: Tutorial 4294967296 shows the error:

---

## [How to continue a workflow when a prior step failed?](https://discourse.cmake.org/t/how-to-continue-a-workflow-when-a-prior-step-failed/8474)

<div class="topic-metadata">

**Author:** [@phread](https://discourse.cmake.org/u/phread)\
**Replies:** 3\
**Last updated:** [August 18, 2023, 12:38pm UTC](https://discourse.cmake.org/t/how-to-continue-a-workflow-when-a-prior-step-failed/8474 "2023-08-18T12:38:29Z")

</div>

I have a number of build steps in my workflow. It is acceptable for some build steps to fail. How do I continue the workflow even though a step fails?

---

## [CMakeWorkflowPresets: How to keep it as simple as possible?](https://discourse.cmake.org/t/cmakeworkflowpresets-how-to-keep-it-as-simple-as-possible/8735)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 4\
**Last updated:** [August 18, 2023, 12:23pm UTC](https://discourse.cmake.org/t/cmakeworkflowpresets-how-to-keep-it-as-simple-as-possible/8735 "2023-08-18T12:23:47Z")

</div>

I try to use CMake Presets with workflows, but without too many permutations. So I decided to have only a debug and a release workflow. The user should be able to control the Compiler or Toolchain used. bash-3.2$ cmake…

---

## [removing a bad include from pkg-config package](https://discourse.cmake.org/t/removing-a-bad-include-from-pkg-config-package/8760)

<div class="topic-metadata">

**Author:** [@Sergey\_Fukanchik](https://discourse.cmake.org/u/Sergey_Fukanchik)\
**Replies:** 6\
**Last updated:** [August 18, 2023, 9:41am UTC](https://discourse.cmake.org/t/removing-a-bad-include-from-pkg-config-package/8760 "2023-08-18T09:41:25Z")

</div>

Library curlpp in it’s pkg-config --cflags has: -Iinclude -I/usr/include/x86\_64-linux-gnu cmake rejects relative -Iinclude: CMake Error in src/CMakeLists.txt: Target "PkgConfig…

---

## [Example or Sample of CPack Generator for NuGet](https://discourse.cmake.org/t/example-or-sample-of-cpack-generator-for-nuget/8761)

<div class="topic-metadata">

**Author:** [@f.brier](https://discourse.cmake.org/u/f.brier)\
**Replies:** 1\
**Last updated:** [August 17, 2023, 10:41pm UTC](https://discourse.cmake.org/t/example-or-sample-of-cpack-generator-for-nuget/8761 "2023-08-17T22:41:23Z")

</div>

Today I bought Professional CMake, 15th Edition which says, “CMake 3.13 added a special External generator which doesn’t produce packages itself, but instead creates a JSON file which some other process can consume to pr…

---

## [how to include .node extentions in cmake](https://discourse.cmake.org/t/how-to-include-node-extentions-in-cmake/8751)

<div class="topic-metadata">

**Author:** [@shokarta](https://discourse.cmake.org/u/shokarta)\
**Replies:** 1\
**Last updated:** [August 17, 2023, 2:02pm UTC](https://discourse.cmake.org/t/how-to-include-node-extentions-in-cmake/8751 "2023-08-17T14:02:32Z")

</div>

Hello gurus, can I kindly ask you what all do i need to put into cmakelists.txt if i have fresh project? I have compiled node-rfc extention of node.js so now i have the build folder (c:\\Qt\\nodejs\\node\_modules\\npm\\node\_…

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

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