# Code

**URL:** https://discourse.cmake.org/c/code/11.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

---

## [CMake clean target is not cleaning .pdb file (debug symbols)](https://discourse.cmake.org/t/cmake-clean-target-is-not-cleaning-pdb-file-debug-symbols/6936)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 2\
**Last updated:** [November 29, 2022, 9:44am UTC](https://discourse.cmake.org/t/cmake-clean-target-is-not-cleaning-pdb-file-debug-symbols/6936 "2022-11-29T09:44:00Z")

</div>

Cmake clean target is not cleaning .pdb files generated by compiler in debug build. Its only deleting .exe targets from CMAKE\_RUNTIME\_OUTPUT\_DIRECTORY directory. How can we delete .pdb file also as part of cmake clean ta…

---

## [FindPython3 and shared libs](https://discourse.cmake.org/t/findpython3-and-shared-libs/6726)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 2\
**Last updated:** [November 24, 2022, 8:36am UTC](https://discourse.cmake.org/t/findpython3-and-shared-libs/6726 "2022-11-24T08:36:16Z")

</div>

I was doing find\_package(Python3 COMPONENTS Interpreter Development) on Ubuntu bionic machines without specifying any hints for static or shared libs, so it found the shared libs which this application requires and all w…

---

## [How to add a file to the cpack archive that needs to be downloaded first using cmake?](https://discourse.cmake.org/t/how-to-add-a-file-to-the-cpack-archive-that-needs-to-be-downloaded-first-using-cmake/6939)

<div class="topic-metadata">

**Author:** [@RaisinTen](https://discourse.cmake.org/u/RaisinTen)\
**Replies:** 4\
**Last updated:** [November 24, 2022, 8:22am UTC](https://discourse.cmake.org/t/how-to-add-a-file-to-the-cpack-archive-that-needs-to-be-downloaded-first-using-cmake/6939 "2022-11-24T08:22:23Z")

</div>

I need a way to include the esbuild binary from the node\_modules directory of my project in the cpack archive in a way that npm ci, which downloads the esbuild package from npm, gets run before the copy operation is star…

---

## [Help with packaging a test suite + main project together](https://discourse.cmake.org/t/help-with-packaging-a-test-suite-main-project-together/6901)

<div class="topic-metadata">

**Author:** [@thehans](https://discourse.cmake.org/u/thehans)\
**Replies:** 4\
**Last updated:** [November 23, 2022, 11:26pm UTC](https://discourse.cmake.org/t/help-with-packaging-a-test-suite-main-project-together/6901 "2022-11-23T23:26:23Z")

</div>

I have a project where I would like to generate 2 ZIP archives using CPack. The first is straightforward packaging of an executable and supporting files which is already working. The second package I am trying to build…

---

## [recplacing linker script option](https://discourse.cmake.org/t/recplacing-linker-script-option/6926)

<div class="topic-metadata">

**Author:** [@JojoS62](https://discourse.cmake.org/u/JojoS62)\
**Replies:** 2\
**Last updated:** [November 22, 2022, 7:26pm UTC](https://discourse.cmake.org/t/recplacing-linker-script-option/6926 "2022-11-22T19:26:03Z")

</div>

I have an arm-eabi-none environment (mbed-os) and want to add a custom linker script option to the build system. The current system uses a fixed linker script, assigned to the used target mcu/board. The original script …

---

## [MACOSX\_PACKAGE\_LOCATION and INTERFACE\_SOURCES](https://discourse.cmake.org/t/macosx-package-location-and-interface-sources/4277)

<div class="topic-metadata">

**Author:** [@christophe-calmejane](https://discourse.cmake.org/u/christophe-calmejane)\
**Replies:** 7\
**Last updated:** [November 22, 2022, 4:12pm UTC](https://discourse.cmake.org/t/macosx-package-location-and-interface-sources/4277 "2022-11-22T16:12:17Z")

</div>

Hi, am I doing something wrong with this code, or is there a bug. (Note: My real project uses this technique to copy a .framework to the main .app, I just changed the code to copy a simple text file, the result being t…

---

## [CHECK\_TYPE\_SIZE regression in CMake-3.25.0](https://discourse.cmake.org/t/check-type-size-regression-in-cmake-3-25-0/6923)

<div class="topic-metadata">

**Author:** [@lassoan](https://discourse.cmake.org/u/lassoan)\
**Replies:** 4\
**Last updated:** [November 21, 2022, 11:08pm UTC](https://discourse.cmake.org/t/check-type-size-regression-in-cmake-3-25-0/6923 "2022-11-21T23:08:24Z")

</div>

When configuring DCMTK project CHECK\_TYPE\_SIZE function started to fail when switched to CMake-3.25.0, on Windows, using VS 2022, x64. It works well when using CMake-3.24.3. Multiple other people have reported the same …

---

## [cmake \_\_FILE\_NAME\_\_ in a portable way?](https://discourse.cmake.org/t/cmake-file-name-in-a-portable-way/6918)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 3\
**Last updated:** [November 21, 2022, 2:09pm UTC](https://discourse.cmake.org/t/cmake-file-name-in-a-portable-way/6918 "2022-11-21T14:09:03Z")

</div>

gcc 12 has \_\_FILE\_\_NAME\_\_ defined which is a great improvement to \_\_FILE\_\_ for reducing the string contamination in the binaries. In the lack of gcc 12, is there a way to have cmake generate a base file name to the pre-p…

---

## [Pass optional arguments to \`ExternalProject\_Add\` using a variable](https://discourse.cmake.org/t/pass-optional-arguments-to-externalproject-add-using-a-variable/6910)

<div class="topic-metadata">

**Author:** [@jhlegarreta](https://discourse.cmake.org/u/jhlegarreta)\
**Replies:** 2\
**Last updated:** [November 20, 2022, 2:13pm UTC](https://discourse.cmake.org/t/pass-optional-arguments-to-externalproject-add-using-a-variable/6910 "2022-11-20T14:13:11Z")

</div>

Hi CMake folks, we have a case in ITK where we would like to pass some additional arguments to the ExternalProject\_Add command depending on the CMake version: The approach does not seem to work: CMake does not underst…

---

## [Difference between quote and non-quote variable](https://discourse.cmake.org/t/difference-between-quote-and-non-quote-variable/6906)

<div class="topic-metadata">

**Author:** [@nitro2](https://discourse.cmake.org/u/nitro2)\
**Replies:** 1\
**Last updated:** [November 19, 2022, 11:11pm UTC](https://discourse.cmake.org/t/difference-between-quote-and-non-quote-variable/6906 "2022-11-19T23:11:26Z")

</div>

In Cmake tutorial, solution for TODO 10: target\_include\_directories(Tutorial PUBLIC "${PROJECT\_BINARY\_DIR}" ${EXTRA\_INCLUDES} ) I wonder …

---

## [How to install a custom target ?](https://discourse.cmake.org/t/how-to-install-a-custom-target/670)

<div class="topic-metadata">

**Author:** [@yann](https://discourse.cmake.org/u/yann)\
**Replies:** 3\
**Last updated:** [November 18, 2022, 6:20pm UTC](https://discourse.cmake.org/t/how-to-install-a-custom-target/670 "2022-11-18T18:20:04Z")

</div>

I am creating a target to generate a script using add\_custom\_target(). Now I want to install it, but: install(TARGETS) fails with “install TARGETS given target “script” which is not an executable, library, or module.”…

---

## [How to properly use bracket arguments in install(code)?](https://discourse.cmake.org/t/how-to-properly-use-bracket-arguments-in-install-code/6889)

<div class="topic-metadata">

**Author:** [@shakfu](https://discourse.cmake.org/u/shakfu)\
**Replies:** 4\
**Last updated:** [November 18, 2022, 2:18pm UTC](https://discourse.cmake.org/t/how-to-properly-use-bracket-arguments-in-install-code/6889 "2022-11-18T14:18:40Z")

</div>

I have been studying an example, by Ivan Onyshenko, which demonstrates how to use fixup\_bundle and how cmake and cpack can create, for macOS, a bundle and also copy .dylib dependencies into that bundle. That’s all fine.…

---

## [Create a dissasembly from a single c file](https://discourse.cmake.org/t/create-a-dissasembly-from-a-single-c-file/6868)

<div class="topic-metadata">

**Author:** [@patsv](https://discourse.cmake.org/u/patsv)\
**Replies:** 6\
**Last updated:** [November 18, 2022, 7:17am UTC](https://discourse.cmake.org/t/create-a-dissasembly-from-a-single-c-file/6868 "2022-11-18T07:17:01Z")

</div>

Hi, I want to compile and produce an assembly file from a c file. Am translating some makefiles where one produces a single dissasembly file from a c file to determine some info about how this compiler aligns data and s…

---

## [Is there a way to add a resource file to Visual Studio project and copy it to the executable directory?](https://discourse.cmake.org/t/is-there-a-way-to-add-a-resource-file-to-visual-studio-project-and-copy-it-to-the-executable-directory/6886)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.cmake.org/u/Jack)\
**Replies:** 8\
**Last updated:** [November 17, 2022, 4:32pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-add-a-resource-file-to-visual-studio-project-and-copy-it-to-the-executable-directory/6886 "2022-11-17T16:32:56Z")

</div>

I have some text files that I want to add to the Visual Studio project. I can’t add it to the add\_executable() call because I get this error: Cannot find source file: my\_text\_file.txt Tried extensions .c .C .…

---

## [Add command line options to my installer (CPack + NSIS)](https://discourse.cmake.org/t/add-command-line-options-to-my-installer-cpack-nsis/6882)

<div class="topic-metadata">

**Author:** [@Lotte1990](https://discourse.cmake.org/u/Lotte1990)\
**Replies:** 3\
**Last updated:** [November 17, 2022, 2:28pm UTC](https://discourse.cmake.org/t/add-command-line-options-to-my-installer-cpack-nsis/6882 "2022-11-17T14:28:03Z")

</div>

Hello, I would like to add some command line options to my installer that I create using CPack and NSIS. Example: instead of running “myinstaller.exe”, I would like to run “myinstaller.exe --noshortcut” which then omit…

---

## [CMake + Presets/Toolchain for iOS - Problem to find libs with find\_package](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642)

<div class="topic-metadata">

**Author:** [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)\
**Replies:** 9\
**Last updated:** [November 16, 2022, 2:54pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642 "2022-11-16T14:54:10Z")

</div>

Hi everyone, I’m facing something strange and I can’t figure out if it’s actually a bug or a misunderstanding of the system. I use the preset system to manage the different OS with toolchain. Here is an extract of my …

---

## [remove\_definitions("NDEBUG") doesn't seem to remove the macro from the build.](https://discourse.cmake.org/t/remove-definitions-ndebug-doesnt-seem-to-remove-the-macro-from-the-build/6876)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.cmake.org/u/Jack)\
**Replies:** 2\
**Last updated:** [November 16, 2022, 12:45pm UTC](https://discourse.cmake.org/t/remove-definitions-ndebug-doesnt-seem-to-remove-the-macro-from-the-build/6876 "2022-11-16T12:45:55Z")

</div>

I’m in a CMake hierarchy where at its root, someone has put in add\_compile\_definitions("NDEBUG") So, I’m trying to remove it without affecting the other projects. I figured putting remove\_definitions("NDEBUG") int…

---

## [Use case for TEST\_INCLUDE\_FILES directory property?](https://discourse.cmake.org/t/use-case-for-test-include-files-directory-property/6864)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 4\
**Last updated:** [November 14, 2022, 10:08pm UTC](https://discourse.cmake.org/t/use-case-for-test-include-files-directory-property/6864 "2022-11-14T22:08:58Z")

</div>

What is the intended use case for the TEST\_INCLUDE\_FILES directory property? The docs say: A list of cmake files that will be included when ctest is run. If you specify TEST\_INCLUDE\_FILES, those files will be included…

---

## [How to import (link) external .so library](https://discourse.cmake.org/t/how-to-import-link-external-so-library/6858)

<div class="topic-metadata">

**Author:** [@Mathew](https://discourse.cmake.org/u/Mathew)\
**Replies:** 1\
**Last updated:** [November 14, 2022, 12:16am UTC](https://discourse.cmake.org/t/how-to-import-link-external-so-library/6858 "2022-11-14T00:16:11Z")

</div>

Hi there, I need help to link an external library into my main.cpp. I downloaded and compiled a TPM\_ibmtss1.6.0 project from the internet and got the libraries ibmtss.so, ibmtssutils.so and ibmtssutils12.so. Now, I have…

---

## [Escaping generator expressions in ExternalProject\_Add](https://discourse.cmake.org/t/escaping-generator-expressions-in-externalproject-add/6855)

<div class="topic-metadata">

**Author:** [@mihe](https://discourse.cmake.org/u/mihe)\
**Replies:** 2\
**Last updated:** [November 13, 2022, 11:01am UTC](https://discourse.cmake.org/t/escaping-generator-expressions-in-externalproject-add/6855 "2022-11-13T11:01:25Z")

</div>

As far as I can tell, you’re able to pass generator expressions to CMake through the command-line and have them be evaluated appropriately. This comes in handy when wanting to set CMAKE\_MSVC\_RUNTIME\_LIBRARY for some thir…

---

## [install lib with deb (lock)](https://discourse.cmake.org/t/install-lib-with-deb-lock/6682)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 5\
**Last updated:** [November 12, 2022, 12:38am UTC](https://discourse.cmake.org/t/install-lib-with-deb-lock/6682 "2022-11-12T00:38:14Z")

</div>

I use the CPACK\_DEBIAN\_PACKAGE\_CONTROL\_EXTRA to install some library with deb. preinstall script apt-get install -y lshw But get the error Fetched 1194 kB in 2s (698 kB/s) Reading package lists... haha E: Could not…

---

## [CPACK\_WIX\_TEMPLATE function](https://discourse.cmake.org/t/cpack-wix-template-function/6850)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 0\
**Last updated:** [November 12, 2022, 12:30am UTC](https://discourse.cmake.org/t/cpack-wix-template-function/6850 "2022-11-12T00:30:40Z")

</div>

Hi, I try to use cpack to process the wix. And the WIX.template.in is reference on set(CPACK\_WIX\_TEMPLATE ${CMAKE\_CURRENT\_SOURCE\_DIR}/cmake/wix.template.in) set(CPACK\_WIX\_EXTENSIONS "WixUtilExtension") Then …

---

## [Swig doesn't generate Python-file when called via CMake](https://discourse.cmake.org/t/swig-doesnt-generate-python-file-when-called-via-cmake/6806)

<div class="topic-metadata">

**Author:** [@ottmar-zittlau](https://discourse.cmake.org/u/ottmar-zittlau)\
**Replies:** 2\
**Last updated:** [November 10, 2022, 4:41pm UTC](https://discourse.cmake.org/t/swig-doesnt-generate-python-file-when-called-via-cmake/6806 "2022-11-10T16:41:56Z")

</div>

Hi, I want to run Swig from CMake. My CMakeLists.txt looks like this: cmake\_minimum\_required(VERSION 3.22.0) project(PyTest CXX) find\_package(SWIG 4.0 REQUIRED python) include(UseSWIG) set(UseSWIG\_MODULE\_VERSION 1) …

---

## [How can we request to rebuild INSTALL project in visual studio (build INSTALL project is available)](https://discourse.cmake.org/t/how-can-we-request-to-rebuild-install-project-in-visual-studio-build-install-project-is-available/6819)

<div class="topic-metadata">

**Author:** [@Nico](https://discourse.cmake.org/u/Nico)\
**Replies:** 0\
**Last updated:** [November 9, 2022, 9:26am UTC](https://discourse.cmake.org/t/how-can-we-request-to-rebuild-install-project-in-visual-studio-build-install-project-is-available/6819 "2022-11-09T09:26:18Z")

</div>

Hello, It is possible to request that visual studio builds the install project through: set(CMAKE\_VS\_INCLUDE\_INSTALL\_TO\_DEFAULT\_BUILD 1) It is possible to request that it is built at execution time when deactivating “…

---

## [cmake include directories error in Vs Code](https://discourse.cmake.org/t/cmake-include-directories-error-in-vs-code/6798)

<div class="topic-metadata">

**Author:** [@Dr-Itachi](https://discourse.cmake.org/u/Dr-Itachi)\
**Replies:** 6\
**Last updated:** [November 7, 2022, 4:50pm UTC](https://discourse.cmake.org/t/cmake-include-directories-error-in-vs-code/6798 "2022-11-07T16:50:02Z")

</div>

Hi. I’m having cmake include directories errors when I import my project from STM32CubeIDE in VS Code using the Microsoft Embedded Tools extension. I don’t know what is need to be done here as things are auto generated. …

---

## [CMake 3.17.5 cmake\_policy(SET CMP0095 NEW) not working](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767)

<div class="topic-metadata">

**Author:** [@prakashcv13](https://discourse.cmake.org/u/prakashcv13)\
**Replies:** 8\
**Last updated:** [November 7, 2022, 12:54pm UTC](https://discourse.cmake.org/t/cmake-3-17-5-cmake-policy-set-cmp0095-new-not-working/6767 "2022-11-07T12:54:41Z")

</div>

Hi All, In our project, the main CMakeLists.txt has the below two lines at the very beginning - cmake\_minimum\_required(VERSION 3.16) cmake\_policy(SET CMP0095 NEW) Also, we are setting CMAKE\_INSTALL\_RPATH set(CMAKE\_I…

---

## [Use exported targets and find\_package on build path](https://discourse.cmake.org/t/use-exported-targets-and-find-package-on-build-path/6796)

<div class="topic-metadata">

**Author:** [@ottmar-zittlau](https://discourse.cmake.org/u/ottmar-zittlau)\
**Replies:** 1\
**Last updated:** [November 7, 2022, 12:45pm UTC](https://discourse.cmake.org/t/use-exported-targets-and-find-package-on-build-path/6796 "2022-11-07T12:45:25Z")

</div>

Hi, I’m trying to understand the whole packaging process. For this, I created a project with the following folder structure main folder CMakeLists.txt – lib – – lib\_1 – – – CMakeLists.txt – – – … – – lib\_2 – – –…

---

## [ninja command line too long](https://discourse.cmake.org/t/ninja-command-line-too-long/3086)

<div class="topic-metadata">

**Author:** [@erichschroeter](https://discourse.cmake.org/u/erichschroeter)\
**Replies:** 5\
**Last updated:** [November 7, 2022, 12:40pm UTC](https://discourse.cmake.org/t/ninja-command-line-too-long/3086 "2022-11-07T12:40:01Z")

</div>

I am getting a The command line is too long. error when building on Windows using CMake 3.20.0 and Ninja 1.10.2. I have tried the answer for cmake-command-line-too-long-windows, but it did not work. The actual command …

---

## [How to check that the current compiler is GCC/MSYS when using Ninja generator?](https://discourse.cmake.org/t/how-to-check-that-the-current-compiler-is-gcc-msys-when-using-ninja-generator/6698)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 7\
**Last updated:** [November 6, 2022, 8:25am UTC](https://discourse.cmake.org/t/how-to-check-that-the-current-compiler-is-gcc-msys-when-using-ninja-generator/6698 "2022-11-06T08:25:04Z")

</div>

Problem Descriptions There is a variable called MSYS, which is set True when we’re using MSYS Makefiles generator. However, it will be EMPTY if we’re using Ninja or Ninja Multi-Config generator. I’m wondering that is th…

---

## [/usr/bin/ld: cannot find X No such file or directory](https://discourse.cmake.org/t/usr-bin-ld-cannot-find-x-no-such-file-or-directory/6784)

<div class="topic-metadata">

**Author:** [@jepperaskdk](https://discourse.cmake.org/u/jepperaskdk)\
**Replies:** 6\
**Last updated:** [November 6, 2022, 7:52am UTC](https://discourse.cmake.org/t/usr-bin-ld-cannot-find-x-no-such-file-or-directory/6784 "2022-11-06T07:52:29Z")

</div>

I’m trying to include this library in my project: I’m using FetchContent which succesfully populates \_deps/lspcpp-build, \_deps/lspcpp-src, \_deps/lspcpp-subbuild: FetchContent\_Declare( lspcpp GIT\_REPOSITORY htt…

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

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