# Code

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

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

**Page:** 13

---

## [How to exclude the system dependency source file from installation?](https://discourse.cmake.org/t/how-to-exclude-the-system-dependency-source-file-from-installation/13427)

<div class="topic-metadata">

**Author:** [@stripe2933](https://discourse.cmake.org/u/stripe2933)\
**Replies:** 0\
**Last updated:** [January 18, 2025, 8:35am UTC](https://discourse.cmake.org/t/how-to-exclude-the-system-dependency-source-file-from-installation/13427 "2025-01-18T08:35:50Z")

</div>

I’m writing Vulkan helper library (named vku) with C++20 modules, and it uses /usr/local/include/vulkan/vulkan.cppm like this: add\_library(vku) target\_sources(vku PUBLIC FILE\_SET CXX\_MODULES BASE\_DIRS ${Vulkan\_I…

---

## [CustomBuildStep include generated obj files to link](https://discourse.cmake.org/t/custombuildstep-include-generated-obj-files-to-link/2527)

<div class="topic-metadata">

**Author:** [@gwg605](https://discourse.cmake.org/u/gwg605)\
**Replies:** 5\
**Last updated:** [January 17, 2025, 12:08am UTC](https://discourse.cmake.org/t/custombuildstep-include-generated-obj-files-to-link/2527 "2025-01-17T00:08:38Z")

</div>

I have custom build step for several files. These steps generate object files. How to add these object files to linker? add\_custom\_command( MAIN\_DEPENDENCY ${SOURCE\_FILE} OUTPUT ${OUTPUT\_FILES} ${COMMANDS} COMMENT…

---

## [install(RUNTIME\_DEPENDENCY\_SET appDeps) does nothing install?](https://discourse.cmake.org/t/install-runtime-dependency-set-appdeps-does-nothing-install/9741)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 20\
**Last updated:** [January 16, 2025, 10:26pm UTC](https://discourse.cmake.org/t/install-runtime-dependency-set-appdeps-does-nothing-install/9741 "2025-01-16T22:26:29Z")

</div>

With this example cmake\_minimum\_required(VERSION 3.14...3.28) project(CPMExampleBoost VERSION 0.1.2 LANGUAGES CXX) # ---- Create binary ---- add\_executable(CPMExampleBoost main.cpp) target\_compile\_features(CPMExample…

---

## ["FLAGS" literal is being output in link.txt, causing error](https://discourse.cmake.org/t/flags-literal-is-being-output-in-link-txt-causing-error/13263)

<div class="topic-metadata">

**Author:** [@DavidRV00](https://discourse.cmake.org/u/DavidRV00)\
**Replies:** 3\
**Last updated:** [January 15, 2025, 11:40pm UTC](https://discourse.cmake.org/t/flags-literal-is-being-output-in-link-txt-causing-error/13263 "2025-01-15T23:40:51Z")

</div>

Hello, I’m seeing an odd behavior when trying to build a Shared CUDA library using clang++ with CMake. Here’s a simple reproducible example if you wanna try it out yourself: GitHub - DavidRV00/cmake-clang-cuda-bug-repro…

---

## [Reading all lines of a file can not deal with "\[" character](https://discourse.cmake.org/t/reading-all-lines-of-a-file-can-not-deal-with-character/13397)

<div class="topic-metadata">

**Author:** [@Gornhoth](https://discourse.cmake.org/u/Gornhoth)\
**Replies:** 4\
**Last updated:** [January 15, 2025, 7:03pm UTC](https://discourse.cmake.org/t/reading-all-lines-of-a-file-can-not-deal-with-character/13397 "2025-01-15T19:03:21Z")

</div>

Hello, can anybody please help me figure out what is going wrong with how i try to read all lines of a file. I have the following input file which i want to have line by line: ExampleText\[\]; SecondExampleText; \[ Another…

---

## [Cmake install directory issues with multiple users](https://discourse.cmake.org/t/cmake-install-directory-issues-with-multiple-users/13403)

<div class="topic-metadata">

**Author:** [@leakec](https://discourse.cmake.org/u/leakec)\
**Replies:** 1\
**Last updated:** [January 15, 2025, 3:42pm UTC](https://discourse.cmake.org/t/cmake-install-directory-issues-with-multiple-users/13403 "2025-01-15T15:42:55Z")

</div>

I have a cmake project where multiple users may run “make install” (using the same build folder) at different times. This has worked great for us until recently, when we added an install(DIRECTORY …). The problem with in…

---

## [Linker issue for library dependencies](https://discourse.cmake.org/t/linker-issue-for-library-dependencies/13402)

<div class="topic-metadata">

**Author:** [@Giomo223](https://discourse.cmake.org/u/Giomo223)\
**Replies:** 0\
**Last updated:** [January 15, 2025, 11:19am UTC](https://discourse.cmake.org/t/linker-issue-for-library-dependencies/13402 "2025-01-15T11:19:23Z")

</div>

Hi everyone, I have a little issue with my Cmake configuration. This is the structure of my program: I have two different cmake files: 1- for exec.out, the executable which links a static library lib.a. 2- for lib.a…

---

## [What character encoding does configure\_file use?](https://discourse.cmake.org/t/what-character-encoding-does-configure-file-use/13387)

<div class="topic-metadata">

**Author:** [@JasonYundt](https://discourse.cmake.org/u/JasonYundt)\
**Replies:** 0\
**Last updated:** [January 13, 2025, 12:45pm UTC](https://discourse.cmake.org/t/what-character-encoding-does-configure-file-use/13387 "2025-01-13T12:45:15Z")

</div>

I’m currently working on contributing to Descent 3. Descent 3 is an open-source project that uses CMake. Descent 3’s source code is encoded in UTF-8 without any BOMs. I’m currently working on a pull request that uses CM…

---

## [launch.vs.json](https://discourse.cmake.org/t/launch-vs-json/5413)

<div class="topic-metadata">

**Author:** [@danme](https://discourse.cmake.org/u/danme)\
**Replies:** 6\
**Last updated:** [January 9, 2025, 6:49pm UTC](https://discourse.cmake.org/t/launch-vs-json/5413 "2025-01-09T18:49:54Z")

</div>

Hi, Is there any good way to get a PATH variable injected into the launch.vs.json file used for debugging a target. What I want is to avoid having to manually edit any configuration json files that Visual Studio uses. I…

---

## [How to make private sources public for unit tests ?](https://discourse.cmake.org/t/how-to-make-private-sources-public-for-unit-tests/13258)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 6\
**Last updated:** [January 9, 2025, 2:35pm UTC](https://discourse.cmake.org/t/how-to-make-private-sources-public-for-unit-tests/13258 "2025-01-09T14:35:01Z")

</div>

Hello, I have a project with a CMakeLists.txt at the root, and two directories: src and test. src builds a library, and test builds an executable testing the library. In src, when I define access levels for sources, I…

---

## [Supporting local customization -- preset or include?](https://discourse.cmake.org/t/supporting-local-customization-preset-or-include/13355)

<div class="topic-metadata">

**Author:** [@rsalz](https://discourse.cmake.org/u/rsalz)\
**Replies:** 0\
**Last updated:** [January 8, 2025, 3:53pm UTC](https://discourse.cmake.org/t/supporting-local-customization-preset-or-include/13355 "2025-01-08T15:53:38Z")

</div>

I’m converting an OpenSSL fork (GitHub - quictls/quictls: The official repository for the QuicTLS project.) to cmake. There are currently 120 variables controlling the build. Is there any advice on when to use a preset f…

---

## [\[43998\] How to implement different CMake functions with the same name?](https://discourse.cmake.org/t/43998-how-to-implement-different-cmake-functions-with-the-same-name/13349)

<div class="topic-metadata">

**Author:** [@Salomon](https://discourse.cmake.org/u/Salomon)\
**Replies:** 1\
**Last updated:** [January 8, 2025, 10:13am UTC](https://discourse.cmake.org/t/43998-how-to-implement-different-cmake-functions-with-the-same-name/13349 "2025-01-08T10:13:42Z")

</div>

Hello, How can I simply & cleanly implement different functions which share the same name? Here is a first attempt: Function Calling: common.cmake: get\_extension(MACRO\_EXTENSION) Implementation 1: cpp/CMakeLists.t…

---

## [How to specify interface link libraries of imported targets](https://discourse.cmake.org/t/how-to-specify-interface-link-libraries-of-imported-targets/13348)

<div class="topic-metadata">

**Author:** [@ottmar-zittlau](https://discourse.cmake.org/u/ottmar-zittlau)\
**Replies:** 1\
**Last updated:** [January 8, 2025, 9:21am UTC](https://discourse.cmake.org/t/how-to-specify-interface-link-libraries-of-imported-targets/13348 "2025-01-08T09:21:26Z")

</div>

Hi, I’m trying to build a library with cyclic dependencies. The whole thing involves four entities: two imported static libraries (libA and libB) both are defined in a “…-config.cmake” file, that is imported via fi…

---

## [Swift/C++ interop.](https://discourse.cmake.org/t/swift-c-interop/13296)

<div class="topic-metadata">

**Author:** [@eyalamir](https://discourse.cmake.org/u/eyalamir)\
**Replies:** 8\
**Last updated:** [January 7, 2025, 11:53pm UTC](https://discourse.cmake.org/t/swift-c-interop/13296 "2025-01-07T23:53:56Z")

</div>

I’m trying to use the relatively-new interop feature of Swift and C++. Apple provides this example repo: But their interop example only compiles using the Ninja generator, and fails with the Xcode generator. Is there…

---

## [What is the right way to use RPATH on UNIX?](https://discourse.cmake.org/t/what-is-the-right-way-to-use-rpath-on-unix/13335)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 1\
**Last updated:** [January 7, 2025, 11:27pm UTC](https://discourse.cmake.org/t/what-is-the-right-way-to-use-rpath-on-unix/13335 "2025-01-07T23:27:15Z")

</div>

I found this cmake snipped: # - A workaround to correctly resolve installed runtime dependencies on unix for now # Include this module in the main CMakeLists.txt before adding targets to make use include(GNUInstallDirs…

---

## [Multi-value keywords in cmake\_parse\_arguments()](https://discourse.cmake.org/t/multi-value-keywords-in-cmake-parse-arguments/13337)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 1\
**Last updated:** [January 7, 2025, 4:33pm UTC](https://discourse.cmake.org/t/multi-value-keywords-in-cmake-parse-arguments/13337 "2025-01-07T16:33:44Z")

</div>

Hello, can someone perhaps confirm if this is a feature or a side effect that should be avoided: function(foo) cmake\_parse\_arguments( PARSE\_ARGV 0 PARSED\_ARGS # prefix "" # options "" # one-value …

---

## [ExternalProject\_Add commands with wildcard](https://discourse.cmake.org/t/externalproject-add-commands-with-wildcard/13289)

<div class="topic-metadata">

**Author:** [@DKLind](https://discourse.cmake.org/u/DKLind)\
**Replies:** 5\
**Last updated:** [January 7, 2025, 2:32pm UTC](https://discourse.cmake.org/t/externalproject-add-commands-with-wildcard/13289 "2025-01-07T14:32:03Z")

</div>

I have a little problem with ExternalProject\_Add when I try to use a command with a wildcard ‘\*’. The command statement is generated with quotes around the wildcard statement which causes the command to fail. For exampl…

---

## [Ninja always rebuilds an internal target causing issues on target](https://discourse.cmake.org/t/ninja-always-rebuilds-an-internal-target-causing-issues-on-target/13327)

<div class="topic-metadata">

**Author:** [@christophe-calmejane](https://discourse.cmake.org/u/christophe-calmejane)\
**Replies:** 0\
**Last updated:** [January 3, 2025, 2:11pm UTC](https://discourse.cmake.org/t/ninja-always-rebuilds-an-internal-target-causing-issues-on-target/13327 "2025-01-03T14:11:27Z")

</div>

Here is a sample project: cmake\_minimum\_required(VERSION 3.30) project(myLib) add\_library(${PROJECT\_NAME} SHARED myLib.cpp) set\_target\_properties(${PROJECT\_NAME} PROPERTIES VERSION "1.2.3.4" SOVERSION "1") add\_custom…

---

## [Local install vs install for CPack generator](https://discourse.cmake.org/t/local-install-vs-install-for-cpack-generator/10815)

<div class="topic-metadata">

**Author:** [@jwuttke](https://discourse.cmake.org/u/jwuttke)\
**Replies:** 1\
**Last updated:** [January 1, 2025, 9:59pm UTC](https://discourse.cmake.org/t/local-install-vs-install-for-cpack-generator/10815 "2025-01-01T21:59:11Z")

</div>

If we rerun cmake after make install in our project, we get CMake warnings Cannot generate a safe runtime search path for target ... because files in some directories may conflict with libraries in implicit director…

---

## [clang-tidy and CXX\_MODULES: error: module 'fmt' not found?](https://discourse.cmake.org/t/clang-tidy-and-cxx-modules-error-module-fmt-not-found/13268)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 3\
**Last updated:** [December 31, 2024, 2:46pm UTC](https://discourse.cmake.org/t/clang-tidy-and-cxx-modules-error-module-fmt-not-found/13268 "2024-12-31T14:46:13Z")

</div>

/usr/local/bin/cmake -E \_\_run\_co\_compile --tidy="clang-tidy-18;--header-filter=^/home/runner/work/fmt-module/fmt-module/;--extra-arg-before=--driver-mode=g++" --source=/home/runner/work/fmt-module/fmt-module/tests/header…

---

## [CMake Error: Output CMakeFiles/fmt.dir/module/fmt.cc.o provides the \`fmt\` module but it is not found in a \`FILE\_SET\` of type \`CXX\_MODULES\`](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 3\
**Last updated:** [December 30, 2024, 11:22pm UTC](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269 "2024-12-30T23:22:23Z")

</div>

FAILED: CMakeFiles/fmt.dir/CXX.dd /Users/runner/work/fmt-module/fmt-module/build/CMakeFiles/fmt.dir/CXXModules.json CMakeFiles/fmt.dir/module/fmt.cc.o.modmap CMakeFiles/fmt.dir/module/format.cc.o.modmap CMakeFiles/fmt.di…

---

## [PATCH\_COMMAND stopped working 3.27.7 --\> 3.30.5](https://discourse.cmake.org/t/patch-command-stopped-working-3-27-7-3-30-5/13287)

<div class="topic-metadata">

**Author:** [@nncarlson](https://discourse.cmake.org/u/nncarlson)\
**Replies:** 2\
**Last updated:** [December 30, 2024, 9:58pm UTC](https://discourse.cmake.org/t/patch-command-stopped-working-3-27-7-3-30-5/13287 "2024-12-30T21:58:57Z")

</div>

I have the following command to download a tar.gz file, unpack it, and apply a patch file: FetchContent\_Populate(${PROJECT\_NAME} URL ${url} PATCH\_COMMAND patch -p1 \< ${PROJECT\_SOURCE\_DIR}/mumps-nag.patch) This works…

---

## [How to Enable CMake parallel compile](https://discourse.cmake.org/t/how-to-enable-cmake-parallel-compile/13265)

<div class="topic-metadata">

**Author:** [@ElbertZ](https://discourse.cmake.org/u/ElbertZ)\
**Replies:** 2\
**Last updated:** [December 30, 2024, 6:50am UTC](https://discourse.cmake.org/t/how-to-enable-cmake-parallel-compile/13265 "2024-12-30T06:50:49Z")

</div>

I try to parallel compile a c++ project with Visual Studio 2022. However It cost 4 minute in Visual Studio2022 or using command instead of 1minute in VSCode, VisualStudio2022 and using command will cost more time and le…

---

## [Help troubleshooting bad link line argument](https://discourse.cmake.org/t/help-troubleshooting-bad-link-line-argument/13285)

<div class="topic-metadata">

**Author:** [@nncarlson](https://discourse.cmake.org/u/nncarlson)\
**Replies:** 0\
**Last updated:** [December 29, 2024, 3:01pm UTC](https://discourse.cmake.org/t/help-troubleshooting-bad-link-line-argument/13285 "2024-12-29T15:01:19Z")

</div>

I’m linking a shared library that depends on a large number of third-party libraries. The source for my library is primarily Fortran and the NAG Fortran compiler is being used to do the linking. It’s unique in that it ca…

---

## [CMAKE\_MAKE\_PROGRAM issue 3.28.6-1.1](https://discourse.cmake.org/t/cmake-make-program-issue-3-28-6-1-1/13239)

<div class="topic-metadata">

**Author:** [@Trampas\_Stern](https://discourse.cmake.org/u/Trampas_Stern)\
**Replies:** 2\
**Last updated:** [December 28, 2024, 4:23pm UTC](https://discourse.cmake.org/t/cmake-make-program-issue-3-28-6-1-1/13239 "2024-12-28T16:23:10Z")

</div>

In my CMakeLists.txt I set the CMAKE\_MAKE\_PROGRAM to the specific version of ninja I want to use (which is same version as in my path). set(CMAKE\_MAKE\_PROGRAM “${CMAKE\_SOURCE\_DIR}/xpacks/@xpack-dev-tools/ninja-build/.c…

---

## [cmake with arm-none-eabi-gcc doesn't include/link default headers and libraries](https://discourse.cmake.org/t/cmake-with-arm-none-eabi-gcc-doesnt-include-link-default-headers-and-libraries/13254)

<div class="topic-metadata">

**Author:** [@b.e.nazarenko](https://discourse.cmake.org/u/b.e.nazarenko)\
**Replies:** 2\
**Last updated:** [December 24, 2024, 6:38am UTC](https://discourse.cmake.org/t/cmake-with-arm-none-eabi-gcc-doesnt-include-link-default-headers-and-libraries/13254 "2024-12-24T06:38:45Z")

</div>

Moving my project from eclipse to cmake. Made a simple arm-none-eabi toolchain file (got it from STM32 CubeMX), and it works fine. But when I tried to use anything from root includes (math.h for example), it didn’t work.…

---

## [Method for allowing generate Makefiles to internally environment variables](https://discourse.cmake.org/t/method-for-allowing-generate-makefiles-to-internally-environment-variables/13248)

<div class="topic-metadata">

**Author:** [@leakec](https://discourse.cmake.org/u/leakec)\
**Replies:** 0\
**Last updated:** [December 21, 2024, 4:24pm UTC](https://discourse.cmake.org/t/method-for-allowing-generate-makefiles-to-internally-environment-variables/13248 "2024-12-21T16:24:06Z")

</div>

I use cmake to compile projects with many subdirectories that can be built independently. Sometimes, during debugging, I’d like to recompile just one of those subdirectories with a different optimization level for debugg…

---

## [ExternalProject fails on Windows with strange errors:](https://discourse.cmake.org/t/externalproject-fails-on-windows-with-strange-errors/13244)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 3\
**Last updated:** [December 20, 2024, 7:09pm UTC](https://discourse.cmake.org/t/externalproject-fails-on-windows-with-strange-errors/13244 "2024-12-20T19:09:01Z")

</div>

I need to build and install an old openssl lib both in debug and release on windows. Unfortunately, the does not work out of the box. with this setup ExternalProject\_Add( openssl DOWNLOAD\_EXTRACT\_TIMESTAMP TRUE …

---

## [Is it possible to add\_subdirectory() after another target has finished installing ( configure second subdirectory after first subdirectory is finished installing )](https://discourse.cmake.org/t/is-it-possible-to-add-subdirectory-after-another-target-has-finished-installing-configure-second-subdirectory-after-first-subdirectory-is-finished-installing/13217)

<div class="topic-metadata">

**Author:** [@n22](https://discourse.cmake.org/u/n22)\
**Replies:** 7\
**Last updated:** [December 20, 2024, 11:45am UTC](https://discourse.cmake.org/t/is-it-possible-to-add-subdirectory-after-another-target-has-finished-installing-configure-second-subdirectory-after-first-subdirectory-is-finished-installing/13217 "2024-12-20T11:45:52Z")

</div>

I tried add\_custom\_target with POST\_BUILD and manually installing it there then adding a dependency to the library build by the second subdirectory on that target but it doesn’t do it and i can’t force it to not be confi…

---

## [Codesign Macos dylib when using Ninja](https://discourse.cmake.org/t/codesign-macos-dylib-when-using-ninja/13232)

<div class="topic-metadata">

**Author:** [@Aliaksandr\_Nemychenk](https://discourse.cmake.org/u/Aliaksandr_Nemychenk)\
**Replies:** 1\
**Last updated:** [December 19, 2024, 9:01pm UTC](https://discourse.cmake.org/t/codesign-macos-dylib-when-using-ninja/13232 "2024-12-19T21:01:47Z")

</div>

Are there any specific flags for CMake to codesign libraries on Macos when using Ninja. (similar to CMAKE\_XCODE\_ATTRIBUTE\_CODE\_SIGN\_IDENTITY) ?

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

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