# Code

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

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

**Page:** 21

---

## [cmake\_path(APPEND) with a variable gives unexpected result](https://discourse.cmake.org/t/cmake-path-append-with-a-variable-gives-unexpected-result/11002)

<div class="topic-metadata">

**Author:** [@johan.derek](https://discourse.cmake.org/u/johan.derek)\
**Replies:** 1\
**Last updated:** [June 12, 2024, 12:05pm UTC](https://discourse.cmake.org/t/cmake-path-append-with-a-variable-gives-unexpected-result/11002 "2024-06-12T12:05:44Z")

</div>

I’m using CMake 3.29.0 on Ubuntu 20.04.6 LTS The objective is to create an application configuration file that is generated with user-configurable directories in ccmake. What I want to do is: Specify a project root d…

---

## [How to install() additional runtime (DLL) dependencies of an IMPORTED target?](https://discourse.cmake.org/t/how-to-install-additional-runtime-dll-dependencies-of-an-imported-target/7508)

<div class="topic-metadata">

**Author:** [@ignus2](https://discourse.cmake.org/u/ignus2)\
**Replies:** 7\
**Last updated:** [June 11, 2024, 4:57pm UTC](https://discourse.cmake.org/t/how-to-install-additional-runtime-dll-dependencies-of-an-imported-target/7508 "2024-06-11T16:57:29Z")

</div>

Porting an old project to CMake, Windows only. One of our modules uses an external SDK (header files, DLL, import library, debug/release). I encapsulate the external SDK like so: set(EXTERNAL\_SDK\_DIR "/some/dir/to/sdk")…

---

## [How to deal with failing file(MAKE\_DIRECTORY](https://discourse.cmake.org/t/how-to-deal-with-failing-file-make-directory/10953)

<div class="topic-metadata">

**Author:** [@oweissbarth\_syk](https://discourse.cmake.org/u/oweissbarth_syk)\
**Replies:** 3\
**Last updated:** [June 10, 2024, 8:13pm UTC](https://discourse.cmake.org/t/how-to-deal-with-failing-file-make-directory/10953 "2024-06-10T20:13:54Z")

</div>

Hi, I am trying to create a directory using file(MAKE\_DIRECTORY …). I want to handle the failure case: abort the configuration and print a custom error message. The call to file(MAKE\_DIRECTORY …) is somewhere deep in …

---

## [Ninja: Unneeded build target dependency when using add\_custom\_command to generate a cpp file](https://discourse.cmake.org/t/ninja-unneeded-build-target-dependency-when-using-add-custom-command-to-generate-a-cpp-file/10903)

<div class="topic-metadata">

**Author:** [@psoftware](https://discourse.cmake.org/u/psoftware)\
**Replies:** 9\
**Last updated:** [June 10, 2024, 4:55pm UTC](https://discourse.cmake.org/t/ninja-unneeded-build-target-dependency-when-using-add-custom-command-to-generate-a-cpp-file/10903 "2024-06-10T16:55:04Z")

</div>

Hi there! I am struggling in removing a compile dependency in my project that makes use of add\_custom\_command. Consider this simple snippet: cmake\_minimum\_required(VERSION 3.12) project(test-cmake-customcommand-depend…

---

## [VS multi-config: how to set different install dir for Release/Debug](https://discourse.cmake.org/t/vs-multi-config-how-to-set-different-install-dir-for-release-debug/7736)

<div class="topic-metadata">

**Author:** [@ignus2](https://discourse.cmake.org/u/ignus2)\
**Replies:** 4\
**Last updated:** [June 10, 2024, 12:56pm UTC](https://discourse.cmake.org/t/vs-multi-config-how-to-set-different-install-dir-for-release-debug/7736 "2024-06-10T12:56:11Z")

</div>

There’s a single variable CMAKE\_INSTALL\_PREFIX which controls the install location, but I’d like to install to separate locations depending on Release/Debug builds. I’m using multi-config VS generator. The current work…

---

## [find\_package for Interface library](https://discourse.cmake.org/t/find-package-for-interface-library/10972)

<div class="topic-metadata">

**Author:** [@pawel](https://discourse.cmake.org/u/pawel)\
**Replies:** 1\
**Last updated:** [June 8, 2024, 12:00pm UTC](https://discourse.cmake.org/t/find-package-for-interface-library/10972 "2024-06-08T12:00:45Z")

</div>

Hello, I have written a simple package with only one header file. Currently I’m trying to fetch my library from directory and then add it using find\_package. In addition, I’m unable to install directory of header file i…

---

## [How to manager transitive dependencies ?](https://discourse.cmake.org/t/how-to-manager-transitive-dependencies/10957)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 0\
**Last updated:** [June 6, 2024, 12:42pm UTC](https://discourse.cmake.org/t/how-to-manager-transitive-dependencies/10957 "2024-06-06T12:42:41Z")

</div>

Hello, I have a static library called LibA which depends on some DLL. Today, these DLL are copied in the install\\deps directory when calling the install() command. A second library, called LibB, fetches LibA to link to…

---

## [Cleaning external\_project / fetch\_content SUBBUILD\_DIR directories?](https://discourse.cmake.org/t/cleaning-external-project-fetch-content-subbuild-dir-directories/9834)

<div class="topic-metadata">

**Author:** [@anthonya](https://discourse.cmake.org/u/anthonya)\
**Replies:** 9\
**Last updated:** [June 5, 2024, 1:22am UTC](https://discourse.cmake.org/t/cleaning-external-project-fetch-content-subbuild-dir-directories/9834 "2024-06-05T01:22:13Z")

</div>

Hey all, I’m encountering an issue that I don’t know how to solve. With CMake 3.24, --fresh was added as an option that is super helpful when writing iterations of a CMake build. Even with that option, I’m seeing that …

---

## [Expressing runtime dependencies in INTERFACE\_LINK\_LIBRARIES](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-interface-link-libraries/10934)

<div class="topic-metadata">

**Author:** [@emaschino](https://discourse.cmake.org/u/emaschino)\
**Replies:** 0\
**Last updated:** [June 3, 2024, 1:49pm UTC](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-interface-link-libraries/10934 "2024-06-03T13:49:57Z")

</div>

Hi, I don’t know how this is specific to Android development, but here it is. For Android Studio to properly pack in an .apk file the runtime dependencies (the .so libraries) of an exported target (being a shared libra…

---

## [How to disable system directory search for file(GET\_RUNTIME\_DEPENDENCIES](https://discourse.cmake.org/t/how-to-disable-system-directory-search-for-file-get-runtime-dependencies/2014)

<div class="topic-metadata">

**Author:** [@Warmyone](https://discourse.cmake.org/u/Warmyone)\
**Replies:** 3\
**Last updated:** [May 31, 2024, 10:18am UTC](https://discourse.cmake.org/t/how-to-disable-system-directory-search-for-file-get-runtime-dependencies/2014 "2024-05-31T10:18:20Z")

</div>

We are building an executable with the visual studio compiler. When deploying we want to include the msvc redist dll’s as customers might not have installed them. Furthermore, we do not want to use those located in sys…

---

## [Correctly locating target output file in multi config builds.](https://discourse.cmake.org/t/correctly-locating-target-output-file-in-multi-config-builds/10913)

<div class="topic-metadata">

**Author:** [@marksibly](https://discourse.cmake.org/u/marksibly)\
**Replies:** 1\
**Last updated:** [May 28, 2024, 1:48am UTC](https://discourse.cmake.org/t/correctly-locating-target-output-file-in-multi-config-builds/10913 "2024-05-28T01:48:21Z")

</div>

Hi, I have a cmake project that generates an output file that I want to install. For ‘single config’ builds (eg: makefile/ninja builds) the target output file is simply located in the ${CMAKE\_CURRENT\_BINARY\_DIR}, but f…

---

## [Make testable the encapsulated code of a library](https://discourse.cmake.org/t/make-testable-the-encapsulated-code-of-a-library/10887)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 1\
**Last updated:** [May 23, 2024, 10:55am UTC](https://discourse.cmake.org/t/make-testable-the-encapsulated-code-of-a-library/10887 "2024-05-23T10:55:48Z")

</div>

Hello, I made a library, and I followed the classical pattern where the implementation is put in a src directory, and the interface in a include/MyLib directory. So the consumers may refer to functions exposed in the la…

---

## [Static Library Package Configuration: Why is there a need for INTERFACE\_LINK\_LIBRARIES?](https://discourse.cmake.org/t/static-library-package-configuration-why-is-there-a-need-for-interface-link-libraries/10873)

<div class="topic-metadata">

**Author:** [@rocketsandsuch](https://discourse.cmake.org/u/rocketsandsuch)\
**Replies:** 1\
**Last updated:** [May 22, 2024, 7:53am UTC](https://discourse.cmake.org/t/static-library-package-configuration-why-is-there-a-need-for-interface-link-libraries/10873 "2024-05-22T07:53:54Z")

</div>

Core Question: Why do consumers of static library packages via find\_package require the need to have all the dependencies noted in the INTERFACE\_LINK\_LIBRARIES property? In my scenario, I cannot guarantee the environmen…

---

## [How to set the usage requirements (includes) for current project](https://discourse.cmake.org/t/how-to-set-the-usage-requirements-includes-for-current-project/10865)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 3\
**Last updated:** [May 18, 2024, 2:53pm UTC](https://discourse.cmake.org/t/how-to-set-the-usage-requirements-includes-for-current-project/10865 "2024-05-18T14:53:23Z")

</div>

Hello, I have a library project, whose code and the main CMakeLists.txt are a src directory. The root contains a CMakeLists.txt with some general settings and the install() stuff. Thanks to the install() commands, the…

---

## [Circular dependency, weak symbols](https://discourse.cmake.org/t/circular-dependency-weak-symbols/10741)

<div class="topic-metadata">

**Author:** [@ra-kal](https://discourse.cmake.org/u/ra-kal)\
**Replies:** 1\
**Last updated:** [May 18, 2024, 12:51pm UTC](https://discourse.cmake.org/t/circular-dependency-weak-symbols/10741 "2024-05-18T12:51:45Z")

</div>

Hi, I need to solve problem with linking firmware. Because of circuar dependencies in my code I’m forced to create static libraries. I had to increase the LINK\_INTERFACE\_MULTIPLICITY to 3 otherwise build fails with unre…

---

## [FetchContent, find\_package, and FeatureSummary](https://discourse.cmake.org/t/fetchcontent-find-package-and-featuresummary/10867)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 1\
**Last updated:** [May 17, 2024, 9:56pm UTC](https://discourse.cmake.org/t/fetchcontent-find-package-and-featuresummary/10867 "2024-05-17T21:56:09Z")

</div>

Hello, are there any best practices or patterns how to properly use FetchContent, FeatureSummary and FindPackageName modules? For example, if I want to integrate FeatureSummary with FetchContent there is additional code…

---

## [From-source shared dependency](https://discourse.cmake.org/t/from-source-shared-dependency/10860)

<div class="topic-metadata">

**Author:** [@hainest](https://discourse.cmake.org/u/hainest)\
**Replies:** 0\
**Last updated:** [May 15, 2024, 12:16pm UTC](https://discourse.cmake.org/t/from-source-shared-dependency/10860 "2024-05-15T12:16:48Z")

</div>

SuperProject consumes my project, MyProject, via CMake. Both projects have a common dependency CommonDep. CommonDep isn’t a CMake project, so MyProject provides a FindCommonDep.cmake that uses find\_path/find\_library to m…

---

## [Swift c++ interoperability ,cmake is failing to send macros to hpp (used in swift through module.map)](https://discourse.cmake.org/t/swift-c-interoperability-cmake-is-failing-to-send-macros-to-hpp-used-in-swift-through-module-map/10857)

<div class="topic-metadata">

**Author:** [@aman2022](https://discourse.cmake.org/u/aman2022)\
**Replies:** 0\
**Last updated:** [May 15, 2024, 7:45am UTC](https://discourse.cmake.org/t/swift-c-interoperability-cmake-is-failing-to-send-macros-to-hpp-used-in-swift-through-module-map/10857 "2024-05-15T07:45:30Z")

</div>

So we making a cross platform application, with c++ as the dominant language and swift used only where required to facilitate cross-platform support for Apple products, We are developing in a layered architecture , with …

---

## [Object Files](https://discourse.cmake.org/t/object-files/10846)

<div class="topic-metadata">

**Author:** [@RoachMan](https://discourse.cmake.org/u/RoachMan)\
**Replies:** 2\
**Last updated:** [May 14, 2024, 3:03pm UTC](https://discourse.cmake.org/t/object-files/10846 "2024-05-14T15:03:09Z")

</div>

Hi I am trying to add google test to an existing project. My test project needs to link against a file called Settings.obj which is an artifact of another project. This a multi config visual studio application. I hav…

---

## [CMAKE toolchain does not set the compiler option -std to gnu17 or c++17 although I have added "set(CMAKE\_CXX\_STANDARD 17)" in CMakeLists.txt.](https://discourse.cmake.org/t/cmake-toolchain-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-have-added-set-cmake-cxx-standard-17-in-cmakelists-txt/10770)

<div class="topic-metadata">

**Author:** [@sahu.swapnil25](https://discourse.cmake.org/u/sahu.swapnil25)\
**Replies:** 3\
**Last updated:** [May 14, 2024, 2:00pm UTC](https://discourse.cmake.org/t/cmake-toolchain-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-have-added-set-cmake-cxx-standard-17-in-cmakelists-txt/10770 "2024-05-14T14:00:26Z")

</div>

This is regarding the build of a project by new compiler that I have configured in cmake toolchain file. For new compiler, I have configured CMAKE\_CXX\_COMPILER and CMAKE\_CXX\_COMPILER\_ID. Also, for c++17 feature I have s…

---

## [Embedding .pdb files in my DLLs, static .LIBs and .EXE on Windows MSVC](https://discourse.cmake.org/t/embedding-pdb-files-in-my-dlls-static-libs-and-exe-on-windows-msvc/10751)

<div class="topic-metadata">

**Author:** [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)\
**Replies:** 9\
**Last updated:** [May 14, 2024, 1:19pm UTC](https://discourse.cmake.org/t/embedding-pdb-files-in-my-dlls-static-libs-and-exe-on-windows-msvc/10751 "2024-05-14T13:19:40Z")

</div>

I have a complex multithreading program that, sadly, it is exhibiting random crashes for a couple of users on Windows. My program is a complex one, that compiles multiple static and dynamic libraries into, finally, an .…

---

## [CMake for Clang-LLVM wasm binaries](https://discourse.cmake.org/t/cmake-for-clang-llvm-wasm-binaries/10848)

<div class="topic-metadata">

**Author:** [@spino17](https://discourse.cmake.org/u/spino17)\
**Replies:** 0\
**Last updated:** [May 13, 2024, 2:21pm UTC](https://discourse.cmake.org/t/cmake-for-clang-llvm-wasm-binaries/10848 "2024-05-13T14:21:04Z")

</div>

Hey, I am new to C/C++ ecosystem and CMake appears almost everywhere as the de-facto build tool. I want to write a C++ tool which does some analysis on AST and I am interested in using LibTooling by following: https://…

---

## [The CMAKE\_C\_COMPILER / CMAKE\_ASM\_COMPILER: arm-none-eabi-gcc is not a full path and was not found in the PATH.](https://discourse.cmake.org/t/the-cmake-c-compiler-cmake-asm-compiler-arm-none-eabi-gcc-is-not-a-full-path-and-was-not-found-in-the-path/10842)

<div class="topic-metadata">

**Author:** [@Daniel\_Vollmer](https://discourse.cmake.org/u/Daniel_Vollmer)\
**Replies:** 2\
**Last updated:** [May 12, 2024, 6:00am UTC](https://discourse.cmake.org/t/the-cmake-c-compiler-cmake-asm-compiler-arm-none-eabi-gcc-is-not-a-full-path-and-was-not-found-in-the-path/10842 "2024-05-12T06:00:26Z")

</div>

Hello friends, I’ve recently started working with CMake and have run into a problem that I’ve been sitting on for a few days and can’t find a solution to. I have an application (based on a ThreadX RTOS) which I want to…

---

## [A very strange make problem existed in Cmake add\_library functions](https://discourse.cmake.org/t/a-very-strange-make-problem-existed-in-cmake-add-library-functions/10837)

<div class="topic-metadata">

**Author:** [@Junru](https://discourse.cmake.org/u/Junru)\
**Replies:** 0\
**Last updated:** [May 11, 2024, 8:35am UTC](https://discourse.cmake.org/t/a-very-strange-make-problem-existed-in-cmake-add-library-functions/10837 "2024-05-11T08:35:10Z")

</div>

Hi friends, Is there anyone who met the strange problem when making project on the linux or win system? demotest.zip (1.2 KB) Cmake on the linux platform: Cmake on the windows platform: However, after I change…

---

## [failed to link the ".a" library into the project](https://discourse.cmake.org/t/failed-to-link-the-a-library-into-the-project/10812)

<div class="topic-metadata">

**Author:** [@Vinay\_hs](https://discourse.cmake.org/u/Vinay_hs)\
**Replies:** 4\
**Last updated:** [May 8, 2024, 7:02am UTC](https://discourse.cmake.org/t/failed-to-link-the-a-library-into-the-project/10812 "2024-05-08T07:02:19Z")

</div>

HI, I created a static library named “libadd.a” using e2 Studio IDE. Later, I initiated a Renesas microcontroller project in Visual Studio Code utilizing the Renesas Build Utilities extension. Unfortunately, I faced cha…

---

## [Developing a PoC on an existing code base](https://discourse.cmake.org/t/developing-a-poc-on-an-existing-code-base/10814)

<div class="topic-metadata">

**Author:** [@epistax](https://discourse.cmake.org/u/epistax)\
**Replies:** 0\
**Last updated:** [May 7, 2024, 2:31pm UTC](https://discourse.cmake.org/t/developing-a-poc-on-an-existing-code-base/10814 "2024-05-07T14:31:38Z")

</div>

Hello there, tldr: How do I use cmake the right way? I am developing a proof of concept for an existing code base with a completely foreign build system (SCons). The important bits: We have sources and projects compl…

---

## [Variable evaluation in command parameters](https://discourse.cmake.org/t/variable-evaluation-in-command-parameters/10809)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 1\
**Last updated:** [May 7, 2024, 7:06am UTC](https://discourse.cmake.org/t/variable-evaluation-in-command-parameters/10809 "2024-05-07T07:06:17Z")

</div>

Hello, I am trying to understand why a target in some CMakeLists.txt is built with VS 2022, whereas it is supposed to be build with the VS 2017 generator. I didn’t code this CMakeLists, but somethings seems strange to …

---

## [CMAKE Wix Patch unclosed token error](https://discourse.cmake.org/t/cmake-wix-patch-unclosed-token-error/10807)

<div class="topic-metadata">

**Author:** [@mgerhardy](https://discourse.cmake.org/u/mgerhardy)\
**Replies:** 2\
**Last updated:** [May 5, 2024, 8:41pm UTC](https://discourse.cmake.org/t/cmake-wix-patch-unclosed-token-error/10807 "2024-05-05T20:41:11Z")

</div>

I have this wixpatch.xml file \<?xml version="1.0" encoding="UTF-8"?\> \<CPackWiXPatch\> \<!-- Fragment ID is from: \<your build dir\>/\_CPack\_Packages/win64/WIX/files.wxs --\> \<CPackWiXFragment Id="CM\_CP\_voxedit.voxedit.veng…

---

## [CMAKE\_GENERATOR\_TOOLSET's toolset and version keys gives unexpected results with vs2022/vs2019?](https://discourse.cmake.org/t/cmake-generator-toolsets-toolset-and-version-keys-gives-unexpected-results-with-vs2022-vs2019/10800)

<div class="topic-metadata">

**Author:** [@StewMcC](https://discourse.cmake.org/u/StewMcC)\
**Replies:** 2\
**Last updated:** [May 4, 2024, 7:03pm UTC](https://discourse.cmake.org/t/cmake-generator-toolsets-toolset-and-version-keys-gives-unexpected-results-with-vs2022-vs2019/10800 "2024-05-04T19:03:19Z")

</div>

CMake Version: 3.27.8 no policy overrides VS/MSVC installs: VS2019/14.29.30133, VS2022/14.34.31933 I am trying to customize a windows toolchain file to specify the toolset requirements for visual studio when using a Vi…

---

## [Two versions of VTK](https://discourse.cmake.org/t/two-versions-of-vtk/10772)

<div class="topic-metadata">

**Author:** [@hitbuyi](https://discourse.cmake.org/u/hitbuyi)\
**Replies:** 4\
**Last updated:** [May 4, 2024, 9:11am UTC](https://discourse.cmake.org/t/two-versions-of-vtk/10772 "2024-05-04T09:11:51Z")

</div>

I installed two versions of VTK in my ubuntu20.04 1, VTK9.1.0 in customed path /home/hitbuyi/PCL/VTK\_9.1 in ~/.bashrc, I set the environment varibles like this export LD\_LIBRARY\_PATH=$LD\_LIBRARY\_PATH:/home/hitbuy…

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

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