# Code

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

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

**Page:** 37

---

## [execute\_process buffering](https://discourse.cmake.org/t/execute-process-buffering/7579)

<div class="topic-metadata">

**Author:** [@Baruch\_Burstein](https://discourse.cmake.org/u/Baruch_Burstein)\
**Replies:** 3\
**Last updated:** [March 10, 2023, 3:45am UTC](https://discourse.cmake.org/t/execute-process-buffering/7579 "2023-03-10T03:45:14Z")

</div>

I am using execute\_process to run a process that can take some time (specifically - docker build). I want to see the output from the process as it is generated since it lets me know where it is up to and how much longer …

---

## [Installer Has Qt Deploy Fixes But Archive Does Not](https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594)

<div class="topic-metadata">

**Author:** [@JohnRED](https://discourse.cmake.org/u/JohnRED)\
**Replies:** 2\
**Last updated:** [March 8, 2023, 6:18pm UTC](https://discourse.cmake.org/t/installer-has-qt-deploy-fixes-but-archive-does-not/7594 "2023-03-08T18:18:04Z")

</div>

I have a Qt application that runs the deploy command during installation and packaging. This works correctly when generating a Wix installer. However, when trying to create an archive, e.g. 7z, command is ran but the f…

---

## [Is there are way to read dependencies of cmake built library?](https://discourse.cmake.org/t/is-there-are-way-to-read-dependencies-of-cmake-built-library/7592)

<div class="topic-metadata">

**Author:** [@hihig2001](https://discourse.cmake.org/u/hihig2001)\
**Replies:** 3\
**Last updated:** [March 8, 2023, 2:05pm UTC](https://discourse.cmake.org/t/is-there-are-way-to-read-dependencies-of-cmake-built-library/7592 "2023-03-08T14:05:39Z")

</div>

Hi, I’m trying to use a cmake-ninja built library from another buildsystem. the problem is that, my cmake library internally built with vcpkg. which means that the library depends on several other libraries. currently…

---

## [Linking against CUDA::cuda\_driver not working right with libcuda stub, wants libcuda.so.1 not libcuda.so](https://discourse.cmake.org/t/linking-against-cuda-cuda-driver-not-working-right-with-libcuda-stub-wants-libcuda-so-1-not-libcuda-so/7455)

<div class="topic-metadata">

**Author:** [@eugenewalker](https://discourse.cmake.org/u/eugenewalker)\
**Replies:** 12\
**Last updated:** [March 7, 2023, 11:40pm UTC](https://discourse.cmake.org/t/linking-against-cuda-cuda-driver-not-working-right-with-libcuda-stub-wants-libcuda-so-1-not-libcuda-so/7455 "2023-03-07T23:40:17Z")

</div>

We build our project cusz using CMake so that it links against CUDA::cuda\_driver. For CI we build inside a Docker container where we have to rely on linking against the libcuda.so stub in the absence of the actual CUDA d…

---

## [Best practice for project / target naming](https://discourse.cmake.org/t/best-practice-for-project-target-naming/7608)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 3\
**Last updated:** [March 7, 2023, 10:19pm UTC](https://discourse.cmake.org/t/best-practice-for-project-target-naming/7608 "2023-03-07T22:19:57Z")

</div>

Hi, I do have some problems with naming my targets / project. I do have a project / group called my\_project and then multiple seperate repos, which mostly all define one library. Currently my projects therefore have th…

---

## [LD\_LIBRARY\_PATH for ExternalProject](https://discourse.cmake.org/t/ld-library-path-for-externalproject/7606)

<div class="topic-metadata">

**Author:** [@magras](https://discourse.cmake.org/u/magras)\
**Replies:** 1\
**Last updated:** [March 7, 2023, 7:25pm UTC](https://discourse.cmake.org/t/ld-library-path-for-externalproject/7606 "2023-03-07T19:25:20Z")

</div>

I’m porting a plugin for llvm compiler to cmake. Functional tests obviously require different toolchain, so I extracted tests into a separate project. With some hacks it almost works. The problem is the toolchain adds a …

---

## [Link separate library files per architecture for imported library](https://discourse.cmake.org/t/link-separate-library-files-per-architecture-for-imported-library/7576)

<div class="topic-metadata">

**Author:** [@triplef](https://discourse.cmake.org/u/triplef)\
**Replies:** 6\
**Last updated:** [March 4, 2023, 6:21pm UTC](https://discourse.cmake.org/t/link-separate-library-files-per-architecture-for-imported-library/7576 "2023-03-04T18:21:50Z")

</div>

Our project links to a number of pre-compiled 3rd party libraries, for which we set up “find modules” using find\_library(), find\_package\_handle\_standard\_args(), and add\_library(... IMPORTED). On macOS some of these libr…

---

## [IMPORTED\_LOCATION not set for imported target](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target/7587)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 0\
**Last updated:** [March 2, 2023, 10:53am UTC](https://discourse.cmake.org/t/imported-location-not-set-for-imported-target/7587 "2023-03-02T10:53:57Z")

</div>

Hi, I do get the following error IMPORTED\_LOCATION not set for imported target sub::sub and don’t know exactly how to resolve it. I set up a small sample repository, which uses ros2 though: GitHub - Leon0402/Sample-Ros…

---

## [CMake Error: install(EXPORT "OpenCVModules" ...) includes target "opencv\_dnn" which requires target \<target\> that is not in any export set.](https://discourse.cmake.org/t/cmake-error-install-export-opencvmodules-includes-target-opencv-dnn-which-requires-target-target-that-is-not-in-any-export-set/7572)

<div class="topic-metadata">

**Author:** [@tridjam](https://discourse.cmake.org/u/tridjam)\
**Replies:** 1\
**Last updated:** [March 1, 2023, 3:40pm UTC](https://discourse.cmake.org/t/cmake-error-install-export-opencvmodules-includes-target-opencv-dnn-which-requires-target-target-that-is-not-in-any-export-set/7572 "2023-03-01T15:40:26Z")

</div>

My task is to build OpenCV with OpenVino. I download OpenCV sources and OpenVino runtime. During the build I get mistakes: CMake Error: install(EXPORT "OpenCVModules" ...) includes target "opencv\_dnn" which requires tar…

---

## [Directory scoping for set\_property(SOURCE ...) or set\_source\_files\_properties](https://discourse.cmake.org/t/directory-scoping-for-set-property-source-or-set-source-files-properties/7493)

<div class="topic-metadata">

**Author:** [@JoeM](https://discourse.cmake.org/u/JoeM)\
**Replies:** 4\
**Last updated:** [February 27, 2023, 8:28pm UTC](https://discourse.cmake.org/t/directory-scoping-for-set-property-source-or-set-source-files-properties/7493 "2023-02-27T20:28:14Z")

</div>

I don’t understand what the DIRECTORY scoping does to these commands. That’s sort of the preamble question. The main question is if it’s possible to change/append the COMPILE\_OPTIONS for all the source files in a given …

---

## [Incremental build with generated headers must run twice](https://discourse.cmake.org/t/incremental-build-with-generated-headers-must-run-twice/7449)

<div class="topic-metadata">

**Author:** [@ConcernedPanda](https://discourse.cmake.org/u/ConcernedPanda)\
**Replies:** 8\
**Last updated:** [February 26, 2023, 11:33pm UTC](https://discourse.cmake.org/t/incremental-build-with-generated-headers-must-run-twice/7449 "2023-02-26T23:33:09Z")

</div>

I’m in the process of transitioning a legacy project into cmake, and I’ve hit a snag using a custom\_command to generate header files. On a clean build, everything works perfectly, the headers are generated and the code …

---

## [(cmake beginner) LNK 2019 with all library. what did i do wrong](https://discourse.cmake.org/t/cmake-beginner-lnk-2019-with-all-library-what-did-i-do-wrong/7434)

<div class="topic-metadata">

**Author:** [@superdu](https://discourse.cmake.org/u/superdu)\
**Replies:** 4\
**Last updated:** [February 23, 2023, 10:27pm UTC](https://discourse.cmake.org/t/cmake-beginner-lnk-2019-with-all-library-what-did-i-do-wrong/7434 "2023-02-23T22:27:15Z")

</div>

Hello every one. I’m a beginner in cmake. I try to rebuild a project that i did on QT with qmake but this time with cmake but i have a lot of difficulties to make it work. all libraries in subdirectory return an error ln…

---

## [External project; cmake not re-building when source time stamp changes](https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 2\
**Last updated:** [February 20, 2023, 8:47pm UTC](https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499 "2023-02-20T20:47:48Z")

</div>

I have an external project built by cmake (ExternalProject\_Add), but cmake does not detect if any of the source files inside the external gets an updated time stamp. The only way seems to be to force it happening by sett…

---

## [FetchContent\_Declare ignores GIT\_TAG](https://discourse.cmake.org/t/fetchcontent-declare-ignores-git-tag/7502)

<div class="topic-metadata">

**Author:** [@bugblatterbeast](https://discourse.cmake.org/u/bugblatterbeast)\
**Replies:** 1\
**Last updated:** [February 20, 2023, 4:53pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-ignores-git-tag/7502 "2023-02-20T16:53:51Z")

</div>

FetchContent\_Declare( Project GIT\_REPOSITORY git@SERVER\_ADDRESS:group/project.git GIT\_TAG f0f0cce200188f4bab4cc30cba18615bef2420c0 GIT\_SHALLOW TRUE ) FetchContent\_MakeAvailable(Project) I’ve also tried “…

---

## [Is install() of a target with EXCLUDE\_FROM\_ALL == TRUE really undefined?](https://discourse.cmake.org/t/is-install-of-a-target-with-exclude-from-all-true-really-undefined/5666)

<div class="topic-metadata">

**Author:** [@jobor](https://discourse.cmake.org/u/jobor)\
**Replies:** 13\
**Last updated:** [February 17, 2023, 6:30am UTC](https://discourse.cmake.org/t/is-install-of-a-target-with-exclude-from-all-true-really-undefined/5666 "2023-02-17T06:30:18Z")

</div>

In the documentation of the install command we can read: Installing a target with the EXCLUDE\_FROM\_ALL target property set to TRUE has undefined behavior. I wonder whether this is really the case. Installation seems…

---

## [Canonical way to set the Visual Studio solution (.sln) filename?](https://discourse.cmake.org/t/canonical-way-to-set-the-visual-studio-solution-sln-filename/7482)

<div class="topic-metadata">

**Author:** [@vinniefalco](https://discourse.cmake.org/u/vinniefalco)\
**Replies:** 0\
**Last updated:** [February 17, 2023, 2:07am UTC](https://discourse.cmake.org/t/canonical-way-to-set-the-visual-studio-solution-sln-filename/7482 "2023-02-17T02:07:30Z")

</div>

I am trying to control the filename of the Visual Studio solution generated when using CMake: if( NOT DEFINED BOOST\_PROJECT\_NAME ) set( BOOST\_PROJECT\_NAME "Boost" ) endif() project( ${BOOST\_PROJECT\_NAME} VERSION 1.82.…

---

## [protobuf\_generate\_cpp: version in repo won't generate grpc files](https://discourse.cmake.org/t/protobuf-generate-cpp-version-in-repo-wont-generate-grpc-files/6000)

<div class="topic-metadata">

**Author:** [@JRHeisey](https://discourse.cmake.org/u/JRHeisey)\
**Replies:** 3\
**Last updated:** [February 16, 2023, 12:32am UTC](https://discourse.cmake.org/t/protobuf-generate-cpp-version-in-repo-wont-generate-grpc-files/6000 "2023-02-16T00:32:02Z")

</div>

I want to use CMake to use protoc to generate the RPC files for cpp I am generating make files I enable various tracing outputs I can see the CMake flags --grpc\_out and --plugin in the CMake putput The CMake generated b…

---

## [static library with static library dependencies propagates its dependencies when exported as package](https://discourse.cmake.org/t/static-library-with-static-library-dependencies-propagates-its-dependencies-when-exported-as-package/7468)

<div class="topic-metadata">

**Author:** [@ppavacic](https://discourse.cmake.org/u/ppavacic)\
**Replies:** 2\
**Last updated:** [February 15, 2023, 12:01pm UTC](https://discourse.cmake.org/t/static-library-with-static-library-dependencies-propagates-its-dependencies-when-exported-as-package/7468 "2023-02-15T12:01:25Z")

</div>

Hello, I have library which we will call libB with statically linked dependencies libE.a, libF.a and libG.a (prebuilt) in target\_link\_dependencies(libB PRIVATE libE.a libF.a libG.a PUBLIC m). I have defined different pr…

---

## [Xcode 14: can't find libc.h when building via Make](https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451)

<div class="topic-metadata">

**Author:** [@Andrew](https://discourse.cmake.org/u/Andrew)\
**Replies:** 2\
**Last updated:** [February 13, 2023, 5:20am UTC](https://discourse.cmake.org/t/xcode-14-cant-find-libc-h-when-building-via-make/7451 "2023-02-13T05:20:37Z")

</div>

Building C code for MacOSX. Have a file that references libc.h. Xcode 13 (with command line tools installed): built fine from Xcode or Make Xcode 14 (with command line tools installed): builds fine from Xcode. Fails …

---

## [How to determine which architectures are available (Apple M1)?](https://discourse.cmake.org/t/how-to-determine-which-architectures-are-available-apple-m1/2401)

<div class="topic-metadata">

**Author:** [@fry](https://discourse.cmake.org/u/fry)\
**Replies:** 13\
**Last updated:** [February 10, 2023, 1:39pm UTC](https://discourse.cmake.org/t/how-to-determine-which-architectures-are-available-apple-m1/2401 "2023-02-10T13:39:22Z")

</div>

I have 2 different machines: an “old” Intel mac and a new M1 mac. On the new (M1) mac I can write this to build a universal binary: IF(APPLE) SET(CMAKE\_OSX\_ARCHITECTURES "x86\_64;arm64" CACHE STRING "Build architectur…

---

## [Making it the librarys responsibility to ensure shared objects are copied?](https://discourse.cmake.org/t/making-it-the-librarys-responsibility-to-ensure-shared-objects-are-copied/7412)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 0\
**Last updated:** [February 6, 2023, 8:24pm UTC](https://discourse.cmake.org/t/making-it-the-librarys-responsibility-to-ensure-shared-objects-are-copied/7412 "2023-02-06T20:24:35Z")

</div>

Before I write a proposal, I wanted to check my facts on how so/dylib/dll copy requirements are supposed to be stipulated in current CMake. Firstly this is separate to the install concern: putting everything into the bu…

---

## [How to add post install script to source rpm?](https://discourse.cmake.org/t/how-to-add-post-install-script-to-source-rpm/7409)

<div class="topic-metadata">

**Author:** [@bthomasz](https://discourse.cmake.org/u/bthomasz)\
**Replies:** 0\
**Last updated:** [February 6, 2023, 2:23pm UTC](https://discourse.cmake.org/t/how-to-add-post-install-script-to-source-rpm/7409 "2023-02-06T14:23:23Z")

</div>

Dear CMakers/CPackers, there is an internal legacy software at work that I am distributing via RPM-s. My problem is that both the binary and source RPMs need to do some configurations at install time. The binary one is …

---

## [How to redirect the hipcc compiler to my custom GPU compute libraries?](https://discourse.cmake.org/t/how-to-redirect-the-hipcc-compiler-to-my-custom-gpu-compute-libraries/7403)

<div class="topic-metadata">

**Author:** [@klausbu](https://discourse.cmake.org/u/klausbu)\
**Replies:** 0\
**Last updated:** [February 4, 2023, 12:56pm UTC](https://discourse.cmake.org/t/how-to-redirect-the-hipcc-compiler-to-my-custom-gpu-compute-libraries/7403 "2023-02-04T12:56:21Z")

</div>

I installed the AMD ROCm GPU compute stack on RHEL/AlmaLinux. This stack doesn’t support my GPU architecture so I made the necessary changes to relevant packages i.e. rocPRIM and rocThrust and installed alternative vers…

---

## [MingW64 Cross-Compiling with Extra Libraries](https://discourse.cmake.org/t/mingw64-cross-compiling-with-extra-libraries/7343)

<div class="topic-metadata">

**Author:** [@Xaldew](https://discourse.cmake.org/u/Xaldew)\
**Replies:** 1\
**Last updated:** [February 3, 2023, 2:53pm UTC](https://discourse.cmake.org/t/mingw64-cross-compiling-with-extra-libraries/7343 "2023-02-03T14:53:45Z")

</div>

This is a bit of weird thing that might be a bug, or just me doing something wrong. Given the MingW64 CMake toolchain file: set(CMAKE\_SYSTEM\_NAME Windows) set(TOOLCHAIN\_PREFIX x86\_64-w64-mingw32) # Cross compilers to…

---

## [Rules for locating find-module](https://discourse.cmake.org/t/rules-for-locating-find-module/7340)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 6\
**Last updated:** [February 1, 2023, 9:48pm UTC](https://discourse.cmake.org/t/rules-for-locating-find-module/7340 "2023-02-01T21:48:30Z")

</div>

What “rules” does cmake follow when locating a find-module? This document says " In Module mode, the command searches for a find module: a file named Find\<Package\>.cmake." For example: find\_package(PROJ MODULE\_ONLY) I…

---

## [Nested header file can not be found](https://discourse.cmake.org/t/nested-header-file-can-not-be-found/7375)

<div class="topic-metadata">

**Author:** [@BenEngbers](https://discourse.cmake.org/u/BenEngbers)\
**Replies:** 0\
**Last updated:** [February 1, 2023, 12:56pm UTC](https://discourse.cmake.org/t/nested-header-file-can-not-be-found/7375 "2023-02-01T12:56:52Z")

</div>

Hi, This is the first project in which I use cmAKE AND c++. In Eclipse CDT I have created a project which uses 2 shared objects, libBasexCpp and libBasexSocket: root |-- libBasexTest - libBasexTest.cpp |-- libBas…

---

## [How do I enable IPO for Release build type only?](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360)

<div class="topic-metadata">

**Author:** [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Replies:** 4\
**Last updated:** [January 30, 2023, 9:05am UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360 "2023-01-30T09:05:57Z")

</div>

In my project I have the following code to enable link time optimization on non-debug builds. include(CheckIPOSupported) check\_ipo\_supported(RESULT IPO\_SUPPORTED) if(IPO\_SUPPORTED AND (NOT CMAKE\_BUILD\_TYPE MATCHES Debug…

---

## [Staggering ctest starts](https://discourse.cmake.org/t/staggering-ctest-starts/7294)

<div class="topic-metadata">

**Author:** [@PaulK](https://discourse.cmake.org/u/PaulK)\
**Replies:** 5\
**Last updated:** [January 27, 2023, 1:17pm UTC](https://discourse.cmake.org/t/staggering-ctest-starts/7294 "2023-01-27T13:17:55Z")

</div>

Dear ctest community! I was wondering about a small problem I have with ctest tests: I have a test suite of, let’s say 100 tests. On average, these tests can run fine in parallel, however, when started in parallel ther…

---

## [CMAKE steps to generate VS2012 with Debugger PDB and Src file settings/configuration](https://discourse.cmake.org/t/cmake-steps-to-generate-vs2012-with-debugger-pdb-and-src-file-settings-configuration/7319)

<div class="topic-metadata">

**Author:** [@gagan\_hattar](https://discourse.cmake.org/u/gagan_hattar)\
**Replies:** 3\
**Last updated:** [January 26, 2023, 5:37pm UTC](https://discourse.cmake.org/t/cmake-steps-to-generate-vs2012-with-debugger-pdb-and-src-file-settings-configuration/7319 "2023-01-26T17:37:23Z")

</div>

We are setting the Debugging -\>Symbols (.pdb) and Common Properties \> Debug Source Files on Solution ‘Application’ Property Pages dialog in VS2012 IDE. Can we add these configurations in Cmake while generating VS2012 so…

---

## [Need help resolving cJSON cmake dependency](https://discourse.cmake.org/t/need-help-resolving-cjson-cmake-dependency/7306)

<div class="topic-metadata">

**Author:** [@Chrinkus](https://discourse.cmake.org/u/Chrinkus)\
**Replies:** 1\
**Last updated:** [January 26, 2023, 2:09pm UTC](https://discourse.cmake.org/t/need-help-resolving-cjson-cmake-dependency/7306 "2023-01-26T14:09:40Z")

</div>

I’ve been happily using FetchContent in my new projects to resolve dependencies and its been super slick. Now I need a JSON parser and cJSON has CMake build support so its a win! However the cJSON CMakeLists.txt file wa…

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

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