# Code

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

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

**Page:** 30

---

## [CMake Error Code 1: Troubleshooting Build Issue with SFML and MinGW](https://discourse.cmake.org/t/cmake-error-code-1-troubleshooting-build-issue-with-sfml-and-mingw/8985)

<div class="topic-metadata">

**Author:** [@luka](https://discourse.cmake.org/u/luka)\
**Replies:** 6\
**Last updated:** [October 12, 2023, 12:40pm UTC](https://discourse.cmake.org/t/cmake-error-code-1-troubleshooting-build-issue-with-sfml-and-mingw/8985 "2023-10-12T12:40:35Z")

</div>

Hello fellow developers, I hope you’re all doing well. I’m currently working on one of my first projects using SFML and CMake, and I’ve run into an issue that I could use some help with. What’s puzzling is that the prog…

---

## [Swig and Java Package Flag option not working](https://discourse.cmake.org/t/swig-and-java-package-flag-option-not-working/9183)

<div class="topic-metadata">

**Author:** [@Trevor\_Cash1](https://discourse.cmake.org/u/Trevor_Cash1)\
**Replies:** 2\
**Last updated:** [October 11, 2023, 11:31pm UTC](https://discourse.cmake.org/t/swig-and-java-package-flag-option-not-working/9183 "2023-10-11T23:31:01Z")

</div>

Hello All, I am using CMake and UseSwig() to create some java bindings. All seems to work - but I get an error when trying to pass the “-package” option on to swig (in order to wrap the created java into a java package) …

---

## [Proper way to use OpenMP: target\_link\_libraries() enough?](https://discourse.cmake.org/t/proper-way-to-use-openmp-target-link-libraries-enough/9158)

<div class="topic-metadata">

**Author:** [@szhorvat](https://discourse.cmake.org/u/szhorvat)\
**Replies:** 3\
**Last updated:** [October 9, 2023, 11:38pm UTC](https://discourse.cmake.org/t/proper-way-to-use-openmp-target-link-libraries-enough/9158 "2023-10-09T23:38:57Z")

</div>

With a project that uses OpenMP, is it sufficient to set target\_link\_libraries(... OpenMP::OpenMP\_C) or do we need to set compiler options (in addition to linker options) separately? The following test project works fin…

---

## [Precompile library, .a with header, included with the source? Embedded target.](https://discourse.cmake.org/t/precompile-library-a-with-header-included-with-the-source-embedded-target/9150)

<div class="topic-metadata">

**Author:** [@apullin](https://discourse.cmake.org/u/apullin)\
**Replies:** 5\
**Last updated:** [October 7, 2023, 11:13pm UTC](https://discourse.cmake.org/t/precompile-library-a-with-header-included-with-the-source-embedded-target/9150 "2023-10-07T23:13:13Z")

</div>

OK, I wanted to get some feedback on something. I am using CMake to build for embedded targets, and ran into something that was surprisingly challenging to do. It is not uncommon to be given pre-compiled libraries as .…

---

## [CMAKE ’ing a CUDA static library of kernels issues](https://discourse.cmake.org/t/cmake-ing-a-cuda-static-library-of-kernels-issues/9141)

<div class="topic-metadata">

**Author:** [@irudkin](https://discourse.cmake.org/u/irudkin)\
**Replies:** 3\
**Last updated:** [October 6, 2023, 7:33am UTC](https://discourse.cmake.org/t/cmake-ing-a-cuda-static-library-of-kernels-issues/9141 "2023-10-06T07:33:45Z")

</div>

I have the following source files: cudakernels.cu library.cu staticlibfnscudakernel.h I have the following two issues that I am bouncing between: /usr/bin/ld: cannot find CMakeFiles/StaticLibOfFnsCUDAKernelcmake\_d.dir/…

---

## [try to avoid GIT\_TAG and replace it with GIT\_REMOTE\_NAME so that the repository don't get downloaded and compiled each time](https://discourse.cmake.org/t/try-to-avoid-git-tag-and-replace-it-with-git-remote-name-so-that-the-repository-dont-get-downloaded-and-compiled-each-time/9108)

<div class="topic-metadata">

**Author:** [@bytecounter](https://discourse.cmake.org/u/bytecounter)\
**Replies:** 4\
**Last updated:** [October 6, 2023, 3:16am UTC](https://discourse.cmake.org/t/try-to-avoid-git-tag-and-replace-it-with-git-remote-name-so-that-the-repository-dont-get-downloaded-and-compiled-each-time/9108 "2023-10-06T03:16:06Z")

</div>

Hello, i have a question: i read in the docs that when i use GIT\_TAG with externalproject he is not able to check wether he has to checkout and build fresh becaues GIT\_TAG can change in a repository. So i try to use GI…

---

## [File set "xyz" is listed in interface file sets of W but has not been exported](https://discourse.cmake.org/t/file-set-xyz-is-listed-in-interface-file-sets-of-w-but-has-not-been-exported/9131)

<div class="topic-metadata">

**Author:** [@MathiasMagnus](https://discourse.cmake.org/u/MathiasMagnus)\
**Replies:** 7\
**Last updated:** [October 5, 2023, 3:06pm UTC](https://discourse.cmake.org/t/file-set-xyz-is-listed-in-interface-file-sets-of-w-but-has-not-been-exported/9131 "2023-10-05T15:06:32Z")

</div>

I am getting the error in the title in the following script, but I could not resolve it any way I tried. set(LIB\_NAME Useful) if(USEFUL\_BUILD\_SHARED\_LIBS) add\_library(${LIB\_NAME} SHARED) else() add\_library(${LIB\_NAME…

---

## [How to force cmake use -MMD flag instead of -MD](https://discourse.cmake.org/t/how-to-force-cmake-use-mmd-flag-instead-of-md/9120)

<div class="topic-metadata">

**Author:** [@Valeryan](https://discourse.cmake.org/u/Valeryan)\
**Replies:** 10\
**Last updated:** [October 4, 2023, 10:37am UTC](https://discourse.cmake.org/t/how-to-force-cmake-use-mmd-flag-instead-of-md/9120 "2023-10-04T10:37:36Z")

</div>

Tool chain used is arm-none-eabi-gcc. I need to compile the project using -MMD flag. I’ve try CMAKE\_C\_FLAGS and add\_compile\_options(). Nothing is work. CMake will append -MD automatically. I believe when compiler se…

---

## [Object libraries and the Ninja generator](https://discourse.cmake.org/t/object-libraries-and-the-ninja-generator/9138)

<div class="topic-metadata">

**Author:** [@plevold](https://discourse.cmake.org/u/plevold)\
**Replies:** 2\
**Last updated:** [October 4, 2023, 10:18am UTC](https://discourse.cmake.org/t/object-libraries-and-the-ninja-generator/9138 "2023-10-04T10:18:15Z")

</div>

I’m struggling with using the Ninja generator for a project that contains an object library. This seems to be exactly what’s been discussed in Issue 24411 and in How to add dependencies to an object library \[for ninja ge…

---

## [Tutorial -\> static / dynamic Libraries on Windows](https://discourse.cmake.org/t/tutorial-static-dynamic-libraries-on-windows/9034)

<div class="topic-metadata">

**Author:** [@didamain](https://discourse.cmake.org/u/didamain)\
**Replies:** 1\
**Last updated:** [October 3, 2023, 10:37am UTC](https://discourse.cmake.org/t/tutorial-static-dynamic-libraries-on-windows/9034 "2023-10-03T10:37:07Z")

</div>

Hey guys, I’m trying to understand several things regarding the building of static/shared libraries on Windows. As the tutorial states in step 10: the BUILD\_SHARED\_LIBS options offers an switch for either building a st…

---

## [Help with RPATH and install prefix](https://discourse.cmake.org/t/help-with-rpath-and-install-prefix/9095)

<div class="topic-metadata">

**Author:** [@buxtonpaul](https://discourse.cmake.org/u/buxtonpaul)\
**Replies:** 4\
**Last updated:** [October 2, 2023, 9:36am UTC](https://discourse.cmake.org/t/help-with-rpath-and-install-prefix/9095 "2023-10-02T09:36:17Z")

</div>

Hi, I am trying to produce a project that is relocatable at install time with it’s own shared libraries. Such that someone could either install it system wide by just running the installer, or could install it in a user…

---

## [How does add\_subdirectory(... SYSTEM) work?](https://discourse.cmake.org/t/how-does-add-subdirectory-system-work/7198)

<div class="topic-metadata">

**Author:** [@nicks](https://discourse.cmake.org/u/nicks)\
**Replies:** 14\
**Last updated:** [September 30, 2023, 6:59pm UTC](https://discourse.cmake.org/t/how-does-add-subdirectory-system-work/7198 "2023-09-30T18:59:15Z")

</div>

Hi all, fairly new to cmake. I have a library that I want to use in my project but want its files to be treated as system header files when included in my own code. Here’s my directory structure: top src1 src2 src3…

---

## [Static library dependencies](https://discourse.cmake.org/t/static-library-dependencies/9068)

<div class="topic-metadata">

**Author:** [@YusakuGodai](https://discourse.cmake.org/u/YusakuGodai)\
**Replies:** 4\
**Last updated:** [September 27, 2023, 2:48am UTC](https://discourse.cmake.org/t/static-library-dependencies/9068 "2023-09-27T02:48:12Z")

</div>

So, let’s say I have separate libraries A, B & C in separate project folders. C is a static library but it’s CMake is unimportant for this example. B’s CMakeLists.txt looks something like this: add\_library(B STATIC b.c…

---

## [Apply toolchain after SystemSpecific](https://discourse.cmake.org/t/apply-toolchain-after-systemspecific/9064)

<div class="topic-metadata">

**Author:** [@kossnikita](https://discourse.cmake.org/u/kossnikita)\
**Replies:** 1\
**Last updated:** [September 27, 2023, 12:06am UTC](https://discourse.cmake.org/t/apply-toolchain-after-systemspecific/9064 "2023-09-27T00:06:07Z")

</div>

I use toolchain for cc65 compiler: set(CMAKE\_SYSTEM\_NAME Generic) set(CMAKE\_SYSTEM\_PROCESSOR 6502) ... ... set(CMAKE\_LINK\_LIBRARY\_FLAG "") And use this like cmake -DCMAKE\_TOOLCHAIN\_FILE=cc65.cmake -Bbuild In this case…

---

## [No way to set Visual Studio generation to use \`EnableEnhancedInstructionSet\` with a value of \`NotSet\`](https://discourse.cmake.org/t/no-way-to-set-visual-studio-generation-to-use-enableenhancedinstructionset-with-a-value-of-notset/8892)

<div class="topic-metadata">

**Author:** [@StewMcC](https://discourse.cmake.org/u/StewMcC)\
**Replies:** 4\
**Last updated:** [September 26, 2023, 11:30pm UTC](https://discourse.cmake.org/t/no-way-to-set-visual-studio-generation-to-use-enableenhancedinstructionset-with-a-value-of-notset/8892 "2023-09-26T23:30:29Z")

</div>

I have a project that wishes to set EnableEnhancedInstructionSet to a “NotSet” value for visual studio generation, I currently have to handle this via VS\_USER\_PROPS, which seems a bit like a hack. On testing noticed tha…

---

## [Experimenting with FetchContent - issue with Jansson](https://discourse.cmake.org/t/experimenting-with-fetchcontent-issue-with-jansson/9079)

<div class="topic-metadata">

**Author:** [@Andrew](https://discourse.cmake.org/u/Andrew)\
**Replies:** 6\
**Last updated:** [September 26, 2023, 4:30am UTC](https://discourse.cmake.org/t/experimenting-with-fetchcontent-issue-with-jansson/9079 "2023-09-26T04:30:19Z")

</div>

Starting to wrap my head around FetchContent, so tried some demo code using Jansson library. App CMakeLists.txt: cmake\_minimum\_required( VERSION 3.24 ) project( FetchContentTest VERSION 0.1 DESCRIPTION "Test use of …

---

## [Why does externalproject downloads and compiles every time ?](https://discourse.cmake.org/t/why-does-externalproject-downloads-and-compiles-every-time/9070)

<div class="topic-metadata">

**Author:** [@bytecounter](https://discourse.cmake.org/u/bytecounter)\
**Replies:** 6\
**Last updated:** [September 24, 2023, 9:03pm UTC](https://discourse.cmake.org/t/why-does-externalproject-downloads-and-compiles-every-time/9070 "2023-09-24T21:03:29Z")

</div>

Hello, i’m using externalproject alot but he downloads and builds the targets everytime i build it. why is this happening?

---

## [i think i changed nothing but now cmake --build . don't want to work anymore](https://discourse.cmake.org/t/i-think-i-changed-nothing-but-now-cmake-build-dont-want-to-work-anymore/9069)

<div class="topic-metadata">

**Author:** [@bytecounter](https://discourse.cmake.org/u/bytecounter)\
**Replies:** 3\
**Last updated:** [September 24, 2023, 6:53pm UTC](https://discourse.cmake.org/t/i-think-i-changed-nothing-but-now-cmake-build-dont-want-to-work-anymore/9069 "2023-09-24T18:53:13Z")

</div>

i made a few local changes and now cmake --build . won’t work anymore, here is the git diff output: https://paste.debian.net/1292989/ when i run cmake . i get the following error: https://paste.debian.net/1292990/

---

## [Replicating qmake project that uses MinGW and static Qt build](https://discourse.cmake.org/t/replicating-qmake-project-that-uses-mingw-and-static-qt-build/9049)

<div class="topic-metadata">

**Author:** [@retif](https://discourse.cmake.org/u/retif)\
**Replies:** 3\
**Last updated:** [September 24, 2023, 8:01am UTC](https://discourse.cmake.org/t/replicating-qmake-project-that-uses-mingw-and-static-qt-build/9049 "2023-09-24T08:01:05Z")

</div>

I am building a Qt application on Windows using static Qt build made with MinGW and using MinGW to compile the application itself too (MinGW wasn’t my choice, unfortunately I have to use it for this project). The applic…

---

## [Xcode generation for iOS build succed but can’t install](https://discourse.cmake.org/t/xcode-generation-for-ios-build-succed-but-can-t-install/9053)

<div class="topic-metadata">

**Author:** [@Manuel\_Rinaldi](https://discourse.cmake.org/u/Manuel_Rinaldi)\
**Replies:** 2\
**Last updated:** [September 24, 2023, 2:55am UTC](https://discourse.cmake.org/t/xcode-generation-for-ios-build-succed-but-can-t-install/9053 "2023-09-24T02:55:24Z")

</div>

Hi I am trying to use CMake to develop a cross-platform game engine. I have found my way though to generate an XCode project for iPhone anyway it does compile but it can’t be installed on my iPhone it fails on loading t…

---

## [Replace add\_subdirectory with find\_package](https://discourse.cmake.org/t/replace-add-subdirectory-with-find-package/9029)

<div class="topic-metadata">

**Author:** [@Andrew](https://discourse.cmake.org/u/Andrew)\
**Replies:** 2\
**Last updated:** [September 22, 2023, 1:06pm UTC](https://discourse.cmake.org/t/replace-add-subdirectory-with-find-package/9029 "2023-09-22T13:06:36Z")

</div>

I have an environment where multiple products on multiple platforms build using a variety of libraries. Historically, we have assembled CMake projects with liberal use of add\_subdirectory. I’d prefer to use something b…

---

## [find\_package(Python) fails with "standalone" python](https://discourse.cmake.org/t/find-package-python-fails-with-standalone-python/9017)

<div class="topic-metadata">

**Author:** [@StefanD](https://discourse.cmake.org/u/StefanD)\
**Replies:** 2\
**Last updated:** [September 21, 2023, 12:34am UTC](https://discourse.cmake.org/t/find-package-python-fails-with-standalone-python/9017 "2023-09-21T00:34:56Z")

</div>

I am running into issues with finding Python in combination with a “standalone” (static) python. This is a minimal CMakeLists.txt I use for testing: cmake\_minimum\_required(VERSION 3.16) project(foo) find\_package(Python…

---

## [Setting linker prefix for CMAKE\_BUILD\_RPATH](https://discourse.cmake.org/t/setting-linker-prefix-for-cmake-build-rpath/8981)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.cmake.org/u/torrance)\
**Replies:** 6\
**Last updated:** [September 18, 2023, 1:14pm UTC](https://discourse.cmake.org/t/setting-linker-prefix-for-cmake-build-rpath/8981 "2023-09-18T13:14:42Z")

</div>

BUILD\_RPATH is being automatically populated on one of my machines and during linking is output as: nvcc \[...\] -o test -Wl,-rpath,/usr/path/something:/usr/path/anotherthing \[...\] (Yes, I’m linking with nvcc. And yes, …

---

## [Windows icon for Windows 11 Installed Apps and Classic Control Panel](https://discourse.cmake.org/t/windows-icon-for-windows-11-installed-apps-and-classic-control-panel/8949)

<div class="topic-metadata">

**Author:** [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)\
**Replies:** 3\
**Last updated:** [September 16, 2023, 11:57am UTC](https://discourse.cmake.org/t/windows-icon-for-windows-11-installed-apps-and-classic-control-panel/8949 "2023-09-16T11:57:35Z")

</div>

I have an icon for the shortcut and for the application window (an .ico file) which is used when minimized, added as a resource. However, my application does not have an icon for Windows 11’s Settings-\>Installed Apps li…

---

## [find\_program without knowing specific directory structure](https://discourse.cmake.org/t/find-program-without-knowing-specific-directory-structure/8907)

<div class="topic-metadata">

**Author:** [@fry](https://discourse.cmake.org/u/fry)\
**Replies:** 6\
**Last updated:** [September 15, 2023, 3:39pm UTC](https://discourse.cmake.org/t/find-program-without-knowing-specific-directory-structure/8907 "2023-09-15T15:39:57Z")

</div>

I need to find an executable in an SDK where the structure can vary (including the names of intermediary folders). I just know that the executable will be under some root folder, but I don’t know at which level exactly. …

---

## [find\_package for non-installer third party module/library/package](https://discourse.cmake.org/t/find-package-for-non-installer-third-party-module-library-package/8954)

<div class="topic-metadata">

**Author:** [@HellMaster](https://discourse.cmake.org/u/HellMaster)\
**Replies:** 5\
**Last updated:** [September 13, 2023, 10:18pm UTC](https://discourse.cmake.org/t/find-package-for-non-installer-third-party-module-library-package/8954 "2023-09-13T22:18:45Z")

</div>

Hey guys, I’ve got a project which requires a fast-dds library (GitHub - eProsima/Fast-DDS: The most complete DDS - Proven: Plenty of success cases.). This library relies on several third party libraries. Those are incl…

---

## [How to use InstallRequiredSystemLibraries module or install the RUNTIME\_DEPENDENCY\_SET](https://discourse.cmake.org/t/how-to-use-installrequiredsystemlibraries-module-or-install-the-runtime-dependency-set/8913)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 6\
**Last updated:** [September 13, 2023, 7:51pm UTC](https://discourse.cmake.org/t/how-to-use-installrequiredsystemlibraries-module-or-install-the-runtime-dependency-set/8913 "2023-09-13T19:51:50Z")

</div>

With this CMakeLists.txt cmake\_minimum\_required(VERSION 3.21...3.27) project(Hello VERSION 0.0.1 LANGUAGES CXX) find\_package(fmt REQUIRED) add\_executable(${PROJECT\_NAME} main.cpp) target\_link\_libraries(${PROJECT\_NAME…

---

## [Cross compiling Qt app on Linux host for MacOS target.](https://discourse.cmake.org/t/cross-compiling-qt-app-on-linux-host-for-macos-target/8953)

<div class="topic-metadata">

**Author:** [@sigidagi](https://discourse.cmake.org/u/sigidagi)\
**Replies:** 10\
**Last updated:** [September 13, 2023, 5:42pm UTC](https://discourse.cmake.org/t/cross-compiling-qt-app-on-linux-host-for-macos-target/8953 "2023-09-13T17:42:13Z")

</div>

On my Linux machine I have MacOS sdk and Qt5 headers and precompiled libraries for MacOS. Configuration part using cmake runs without problem: Configure sigis:qt-example$ cmake --preset x86\_64-macos-qt-zig Preset CMak…

---

## [CMake Error at cmake\_install.cmake:(file) Multiple conflicting paths found for ...](https://discourse.cmake.org/t/cmake-error-at-cmake-install-cmake-file-multiple-conflicting-paths-found-for/8950)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 1\
**Last updated:** [September 13, 2023, 11:27am UTC](https://discourse.cmake.org/t/cmake-error-at-cmake-install-cmake-file-multiple-conflicting-paths-found-for/8950 "2023-09-13T11:27:11Z")

</div>

I try to work with install(RUNTIME\_DEPENDENCY\_SET … ) install(TARGETS ${PROJECT\_NAME} RUNTIME COMPONENT ${PROJECT\_NAME}) install(IMPORTED\_RUNTIME\_ARTIFACTS ${PROJECT\_NAME} RUNTIME\_DEPENDENCY\_SET runtime\_dependency\_set…

---

## [add\_library, sources as list not producing DLL, no error either](https://discourse.cmake.org/t/add-library-sources-as-list-not-producing-dll-no-error-either/8922)

<div class="topic-metadata">

**Author:** [@Kirk\_Morgan](https://discourse.cmake.org/u/Kirk_Morgan)\
**Replies:** 1\
**Last updated:** [September 13, 2023, 3:05am UTC](https://discourse.cmake.org/t/add-library-sources-as-list-not-producing-dll-no-error-either/8922 "2023-09-13T03:05:52Z")

</div>

Hi, I’m trying to write a CMakeLists.txt file in VS Code using the Microsoft C compiler to make a DLL target. I never learned ‘make’ files the hard way so you may need to explain me some dumb. But I did get my whole pro…

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

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