# Code

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

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

**Page:** 19

---

## [Stripping pandoc version number](https://discourse.cmake.org/t/stripping-pandoc-version-number/11475)

<div class="topic-metadata">

**Author:** [@ramcdona](https://discourse.cmake.org/u/ramcdona)\
**Replies:** 2\
**Last updated:** [August 18, 2024, 12:44pm UTC](https://discourse.cmake.org/t/stripping-pandoc-version-number/11475 "2024-08-18T12:44:19Z")

</div>

I am using cmake-pandocology to find pandoc and work with its files (GitHub - jeetsukumaran/cmake-pandocology: Compile documents using Pandoc under the CMake build system) I need to make sure that the ${PANDOC\_EXECUTABL…

---

## [How to get the path of a not imported target?](https://discourse.cmake.org/t/how-to-get-the-path-of-a-not-imported-target/11459)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 4\
**Last updated:** [August 16, 2024, 9:40pm UTC](https://discourse.cmake.org/t/how-to-get-the-path-of-a-not-imported-target/11459 "2024-08-16T21:40:25Z")

</div>

with this code if(TARGET gtest-tidy-mwe) # deprecated: get\_target\_property(TGT\_LOCATION gtest-tidy-mwe LOCATION) set(TGT\_LOCATION $\<TARGET\_FILE:gtest-tidy-mwe\>) message(STATUS "set(TGT\_LOCATION $\<TARGET\_FILE…

---

## [FetchContent ignores CMAKE\_MODULE\_PATH set in subproject](https://discourse.cmake.org/t/fetchcontent-ignores-cmake-module-path-set-in-subproject/5486)

<div class="topic-metadata">

**Author:** [@mschmidtesd](https://discourse.cmake.org/u/mschmidtesd)\
**Replies:** 2\
**Last updated:** [August 15, 2024, 1:57pm UTC](https://discourse.cmake.org/t/fetchcontent-ignores-cmake-module-path-set-in-subproject/5486 "2024-08-15T13:57:14Z")

</div>

I have several self-contained CMake-based library projects. They all build fine when built on their own, but problems arise, when I try to use them in a main project in connection with FetchContent. One of the problems …

---

## [Object library install dir](https://discourse.cmake.org/t/object-library-install-dir/11421)

<div class="topic-metadata">

**Author:** [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)\
**Replies:** 2\
**Last updated:** [August 15, 2024, 1:19pm UTC](https://discourse.cmake.org/t/object-library-install-dir/11421 "2024-08-15T13:19:59Z")

</div>

Hey I want to install an object library but i met a problem with the directory where the object file are installed install(TARGETS ${PROJECT\_TARGET\_NAME} EXPORT "${PROJECT\_TARGET\_NAME}Targets" DESTINATI…

---

## [Where can I find a working example of IF IN\_LIST?](https://discourse.cmake.org/t/where-can-i-find-a-working-example-of-if-in-list/11437)

<div class="topic-metadata">

**Author:** [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)\
**Replies:** 1\
**Last updated:** [August 13, 2024, 5:30pm UTC](https://discourse.cmake.org/t/where-can-i-find-a-working-example-of-if-in-list/11437 "2024-08-13T17:30:29Z")

</div>

I am trying to create a test/assert like macro and cannot get the syntax correct I am obviusly not writing this macro correctly and I am getting confused/stuck :frowning: The macro I have is like this: macro( must\_be\_…

---

## [PRIVATE-becomes-PUBLIC behaviour for static libraries](https://discourse.cmake.org/t/private-becomes-public-behaviour-for-static-libraries/11430)

<div class="topic-metadata">

**Author:** [@malaterre](https://discourse.cmake.org/u/malaterre)\
**Replies:** 6\
**Last updated:** [August 13, 2024, 3:32pm UTC](https://discourse.cmake.org/t/private-becomes-public-behaviour-for-static-libraries/11430 "2024-08-13T15:32:53Z")

</div>

Hi there, AFAIK the following code: target\_link\_libraries(dcmimage PRIVATE ${PNG\_LIBRARIES}) imply that the PNG libraries will be added on the link line when linking against dcmimage. As such it is a expected behavior…

---

## [Not understanding why CMakeLists.txt is not finding my dependency.](https://discourse.cmake.org/t/not-understanding-why-cmakelists-txt-is-not-finding-my-dependency/11429)

<div class="topic-metadata">

**Author:** [@djryanash](https://discourse.cmake.org/u/djryanash)\
**Replies:** 1\
**Last updated:** [August 12, 2024, 12:42pm UTC](https://discourse.cmake.org/t/not-understanding-why-cmakelists-txt-is-not-finding-my-dependency/11429 "2024-08-12T12:42:00Z")

</div>

I’m new to C++ and CMake and trying to get started on a WASM audio synth project but having trouble linking the dependencies. └── 📁cpp-wasm-audio-synth └── 📁build └── cmake\_install.cmake └── Makefil…

---

## [cmake cross compile setup](https://discourse.cmake.org/t/cmake-cross-compile-setup/11424)

<div class="topic-metadata">

**Author:** [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)\
**Replies:** 0\
**Last updated:** [August 11, 2024, 6:15pm UTC](https://discourse.cmake.org/t/cmake-cross-compile-setup/11424 "2024-08-11T18:15:55Z")

</div>

Cross compiling using the Linux Kernel Makefile way seems super easy to me. One sets the CROSS\_COMPLE=/some/path/to/your-tripple-name- and it just works. ie: set(CROSS\_COMPILE “/some/absolute/path/to/special/gcc/fo…

---

## [Validating components in config file](https://discourse.cmake.org/t/validating-components-in-config-file/11408)

<div class="topic-metadata">

**Author:** [@ottmar-zittlau](https://discourse.cmake.org/u/ottmar-zittlau)\
**Replies:** 4\
**Last updated:** [August 9, 2024, 5:48am UTC](https://discourse.cmake.org/t/validating-components-in-config-file/11408 "2024-08-09T05:48:28Z")

</div>

Hi, in the Professional CMake Book (18th edition, p. 535) there is a blueprint for finding components: # Check all required components are available before trying to load any foreach(comp IN LISTS ${CMAKE\_FIND\_PACKAGE\_…

---

## [Linker error is being generated when I try to generate a seperate binary for tests only](https://discourse.cmake.org/t/linker-error-is-being-generated-when-i-try-to-generate-a-seperate-binary-for-tests-only/11399)

<div class="topic-metadata">

**Author:** [@Anthony](https://discourse.cmake.org/u/Anthony)\
**Replies:** 1\
**Last updated:** [August 7, 2024, 12:22pm UTC](https://discourse.cmake.org/t/linker-error-is-being-generated-when-i-try-to-generate-a-seperate-binary-for-tests-only/11399 "2024-08-07T12:22:29Z")

</div>

Error message: /usr/bin/ld: CMakeFiles/test.dir/test\_lexer.c.o: in function \`test\_next\_token': test\_lexer.c:(.text+0x11f): undefined reference to \`lexer\_create' /usr/bin/ld: test\_lexer.c:(.text+0x144): undefined referen…

---

## [Opinion on multiple configuration files when using COMPONENTS of find\_package](https://discourse.cmake.org/t/opinion-on-multiple-configuration-files-when-using-components-of-find-package/11387)

<div class="topic-metadata">

**Author:** [@andi\_schacherbauer](https://discourse.cmake.org/u/andi_schacherbauer)\
**Replies:** 0\
**Last updated:** [August 5, 2024, 4:03pm UTC](https://discourse.cmake.org/t/opinion-on-multiple-configuration-files-when-using-components-of-find-package/11387 "2024-08-05T16:03:35Z")

</div>

Hi, I just wanted to know if it is considered good practice if a CMake package (that supports COMPONENTS) consists of multiple package configuration files (Config.cmake or -config.cmake)? The book from @craig.scott sug…

---

## [Possible to base custom command on generator?](https://discourse.cmake.org/t/possible-to-base-custom-command-on-generator/11355)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 1\
**Last updated:** [July 31, 2024, 7:02am UTC](https://discourse.cmake.org/t/possible-to-base-custom-command-on-generator/11355 "2024-07-31T07:02:35Z")

</div>

All, I’m not sure how to do what I want, so I’m hoping the gurus here can help. In some code where we build Wavewatch in the model I work on, we have CMake like this: set (WW3ESMF\_F90) foreach(src\_file ${WW3ESMF\_FTN}) …

---

## [Building a Library](https://discourse.cmake.org/t/building-a-library/11350)

<div class="topic-metadata">

**Author:** [@undefined2001](https://discourse.cmake.org/u/undefined2001)\
**Replies:** 6\
**Last updated:** [July 30, 2024, 11:55am UTC](https://discourse.cmake.org/t/building-a-library/11350 "2024-07-30T11:55:10Z")

</div>

I want to make a library for my stm32 where i can use peripherals like #include “hardware/gpio.h” #include “hardware/uart.h” i have all the code but need to build that trying cmake but failing can anyone please help w…

---

## [two separate projects based on cmake](https://discourse.cmake.org/t/two-separate-projects-based-on-cmake/11328)

<div class="topic-metadata">

**Author:** [@v2panchal](https://discourse.cmake.org/u/v2panchal)\
**Replies:** 0\
**Last updated:** [July 26, 2024, 10:06am UTC](https://discourse.cmake.org/t/two-separate-projects-based-on-cmake/11328 "2024-07-26T10:06:38Z")

</div>

Hello We have two separate projects called A and B. Project A generated multiple libraries and Project B having multiple libraries and executables. Now Project B depends on Project A. so how can we make dependencies bet…

---

## [CPACK\_GENERATOR( flatpak? )](https://discourse.cmake.org/t/cpack-generator-flatpak/9568)

<div class="topic-metadata">

**Author:** [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)\
**Replies:** 4\
**Last updated:** [July 26, 2024, 5:04am UTC](https://discourse.cmake.org/t/cpack-generator-flatpak/9568 "2024-07-26T05:04:58Z")

</div>

I wonder if there’s a way from cmake to create a Flatpak release. I currently use the DEB, RPM and TGZ generators to distribute my software and I gather all DSO dependencies by running my own macro get\_runtime\_dependenc…

---

## [FetchContent\_Declare() UPDATE\_DISCONNECTED and vcpkg](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312)

<div class="topic-metadata">

**Author:** [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Replies:** 7\
**Last updated:** [July 26, 2024, 1:18am UTC](https://discourse.cmake.org/t/fetchcontent-declare-update-disconnected-and-vcpkg/11312 "2024-07-26T01:18:10Z")

</div>

After upgrading to CMake 3.30 simple FetchContent\_Declare() doesn’t work anymore with the vcpkg toolchain file used. My CI pipelines started failing like this. Here is the actual code. I’m replacing the GIT\_TAG with t…

---

## [Pass double quotes to batch script with execute\_process()](https://discourse.cmake.org/t/pass-double-quotes-to-batch-script-with-execute-process/11198)

<div class="topic-metadata">

**Author:** [@Zeranoe](https://discourse.cmake.org/u/Zeranoe)\
**Replies:** 3\
**Last updated:** [July 23, 2024, 5:03pm UTC](https://discourse.cmake.org/t/pass-double-quotes-to-batch-script-with-execute-process/11198 "2024-07-23T17:03:03Z")

</div>

I’m trying to execute a batch script with an argument that requires double quotes, something like script.bat "foo=bar". If this argument is passed in without the double quotes, you end up with %1 being “foo” and %2 being…

---

## [How to re-use sub-target header-files/dependencies](https://discourse.cmake.org/t/how-to-re-use-sub-target-header-files-dependencies/11266)

<div class="topic-metadata">

**Author:** [@ZweiEuro](https://discourse.cmake.org/u/ZweiEuro)\
**Replies:** 9\
**Last updated:** [July 20, 2024, 9:23am UTC](https://discourse.cmake.org/t/how-to-re-use-sub-target-header-files-dependencies/11266 "2024-07-20T09:23:30Z")

</div>

Hi! I have the following structure My project “example” depends on “wui” which inside of it has this statement: include(ExternalProject) ExternalProject\_Add(cJSON\_download GIT\_REPOSITORY https://github.com/DaveGamble/…

---

## [Moved discussion here from CLion issues about CMAKE\_BUILD\_TYPE, buildPresets vs configurePresets, and Ninja Multi-Config](https://discourse.cmake.org/t/moved-discussion-here-from-clion-issues-about-cmake-build-type-buildpresets-vs-configurepresets-and-ninja-multi-config/11289)

<div class="topic-metadata">

**Author:** [@Dennis\_Ferron](https://discourse.cmake.org/u/Dennis_Ferron)\
**Replies:** 0\
**Last updated:** [July 20, 2024, 4:32am UTC](https://discourse.cmake.org/t/moved-discussion-here-from-clion-issues-about-cmake-build-type-buildpresets-vs-configurepresets-and-ninja-multi-config/11289 "2024-07-20T04:32:21Z")

</div>

I filed a CLion issue concerning a regression with not passing the build type when using CMakePresets.json. Some of the follow up Q&A Craig Scott kindly provided led me to have more questions, but Craig suggested I move…

---

## [Let shared lib load other lib from relative path](https://discourse.cmake.org/t/let-shared-lib-load-other-lib-from-relative-path/11276)

<div class="topic-metadata">

**Author:** [@ZweiEuro](https://discourse.cmake.org/u/ZweiEuro)\
**Replies:** 2\
**Last updated:** [July 18, 2024, 10:51pm UTC](https://discourse.cmake.org/t/let-shared-lib-load-other-lib-from-relative-path/11276 "2024-07-18T22:51:35Z")

</div>

Hi! lets say I want to make a game, my game uses a library, which depends on another library. I want to ship all of this in one block like this: game | - Lib A | - Lib B (depends on LibA) | - Game.bin Assuming eve…

---

## [file(GET\_RUNTIME\_DEPENDENCIES ...) unable to resolve dependencies even if RUNPATH is set.](https://discourse.cmake.org/t/file-get-runtime-dependencies-unable-to-resolve-dependencies-even-if-runpath-is-set/11252)

<div class="topic-metadata">

**Author:** [@Gulasch](https://discourse.cmake.org/u/Gulasch)\
**Replies:** 1\
**Last updated:** [July 17, 2024, 11:16am UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-unable-to-resolve-dependencies-even-if-runpath-is-set/11252 "2024-07-17T11:16:08Z")

</div>

I am trying to install runtime dependencies on linux by calling file(GET\_RUNTIME\_DEPENDENCIES …) on my build output. According to the documentation of GET\_RUNTIME\_DEPENDENCIES, it uses objdump to look at the binaries’ RP…

---

## [CMake Error at CMakeLists.txt:249 (string): string sub-command COMPARE, mode EQUAL needs at least 5 arguments total to command.](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-249-string-string-sub-command-compare-mode-equal-needs-at-least-5-arguments-total-to-command/11151)

<div class="topic-metadata">

**Author:** [@dollPrincess](https://discourse.cmake.org/u/dollPrincess)\
**Replies:** 2\
**Last updated:** [July 16, 2024, 1:49am UTC](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-249-string-string-sub-command-compare-mode-equal-needs-at-least-5-arguments-total-to-command/11151 "2024-07-16T01:49:46Z")

</div>

I have downloaded a project called Febio Studio, for which I can have no help of those who I downloaded it from, and am running into a wall that I cannot comprehend. I hope someone here can shed some light to help this a…

---

## [Changing old FetchContent to comply with new restrictions](https://discourse.cmake.org/t/changing-old-fetchcontent-to-comply-with-new-restrictions/11253)

<div class="topic-metadata">

**Author:** [@Allen](https://discourse.cmake.org/u/Allen)\
**Replies:** 1\
**Last updated:** [July 15, 2024, 7:57pm UTC](https://discourse.cmake.org/t/changing-old-fetchcontent-to-comply-with-new-restrictions/11253 "2024-07-15T19:57:28Z")

</div>

We converted our ExternalProject code to use FetchContent\_Declare/FetchContent\_Populate and allow us to copy files/set args before calling add\_subdirectory. This worked very well until the latest version changed restrict…

---

## [Is it a normal practice to search for a configuration file inside the find module?](https://discourse.cmake.org/t/is-it-a-normal-practice-to-search-for-a-configuration-file-inside-the-find-module/11231)

<div class="topic-metadata">

**Author:** [@Daniel](https://discourse.cmake.org/u/Daniel)\
**Replies:** 2\
**Last updated:** [July 15, 2024, 6:03am UTC](https://discourse.cmake.org/t/is-it-a-normal-practice-to-search-for-a-configuration-file-inside-the-find-module/11231 "2024-07-15T06:03:51Z")

</div>

Consider the FLTK library. After building, this library provides only the configuration file without version support(i.e. FLTKConfig.cmake only). However, in my project I would like to using this library with the minimu…

---

## [add\_custom\_target COMMAND and star \* bypass shell expansion](https://discourse.cmake.org/t/add-custom-target-command-and-star-bypass-shell-expansion/11250)

<div class="topic-metadata">

**Author:** [@MM77](https://discourse.cmake.org/u/MM77)\
**Replies:** 1\
**Last updated:** [July 14, 2024, 11:18pm UTC](https://discourse.cmake.org/t/add-custom-target-command-and-star-bypass-shell-expansion/11250 "2024-07-14T23:18:49Z")

</div>

I create a list of arguments to pass to the COMMAND of add\_custom\_target list(APPEND MyOdbArgs "--default-pointer") list(APPEND MyOdbArgs "\*") the makefile generated contains snippet like cd /home/.../\<proj\>-build-rel…

---

## [Making a Cmake package for LLDB](https://discourse.cmake.org/t/making-a-cmake-package-for-lldb/11246)

<div class="topic-metadata">

**Author:** [@Narayan](https://discourse.cmake.org/u/Narayan)\
**Replies:** 1\
**Last updated:** [July 14, 2024, 3:55pm UTC](https://discourse.cmake.org/t/making-a-cmake-package-for-lldb/11246 "2024-07-14T15:55:23Z")

</div>

I want to generate a CMake config file to help link to other projects more easily. install(TARGETS liblldb EXPORT LLDBTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin INCLU…

---

## [Where to use \`cmake\_minimum\_required\`?](https://discourse.cmake.org/t/where-to-use-cmake-minimum-required/11237)

<div class="topic-metadata">

**Author:** [@Mateusz\_Pusz](https://discourse.cmake.org/u/Mateusz_Pusz)\
**Replies:** 2\
**Last updated:** [July 13, 2024, 10:05pm UTC](https://discourse.cmake.org/t/where-to-use-cmake-minimum-required/11237 "2024-07-13T22:05:45Z")

</div>

I would like to ask for a recommendation on how cmake\_minimum\_required should be used? Until now, I have been putting cmake\_minimum\_required in all the CMake scripts (not only top-level ones) to advertise the minimum ve…

---

## [RPM does not include \<exportname\>-\<config\>.cmake, results in IMPORTED\_LOCATION not set for imported target](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223)

<div class="topic-metadata">

**Author:** [@maxnoe](https://discourse.cmake.org/u/maxnoe)\
**Replies:** 6\
**Last updated:** [July 13, 2024, 6:20am UTC](https://discourse.cmake.org/t/rpm-does-not-include-exportname-config-cmake-results-in-imported-location-not-set-for-imported-target/11223 "2024-07-13T06:20:12Z")

</div>

I have a project where I export targets to make them findable via find\_package(ADH-APIS CONFIG). This all works fine if done via: $ cmake -S . -B build -DCMAKE\_BUILD\_TYPE=Release -DCMAKE\_INSTALL\_PREFIX=/tmp/adh-apis $ …

---

## [CMake 3.30 doesn't let me use $(ARCHS\_STANDARD) to set CMAKE\_OSX\_ARCHITECTURES](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209)

<div class="topic-metadata">

**Author:** [@Sidelobe](https://discourse.cmake.org/u/Sidelobe)\
**Replies:** 6\
**Last updated:** [July 11, 2024, 9:00am UTC](https://discourse.cmake.org/t/cmake-3-30-doesnt-let-me-use-archs-standard-to-set-cmake-osx-architectures/11209 "2024-07-11T09:00:22Z")

</div>

Cmake 3.30 seems to have broken my projects that build universal binaries (arm64;x86\_64) I use this to create universal binaries when building via Xcode: if(CMAKE\_GENERATOR STREQUAL "Xcode") set(CMAKE\_OSX\_ARCHITECTU…

---

## [list(SORT): Add support for SEMVER comparison](https://discourse.cmake.org/t/list-sort-add-support-for-semver-comparison/11163)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 2\
**Last updated:** [July 10, 2024, 9:56pm UTC](https://discourse.cmake.org/t/list-sort-add-support-for-semver-comparison/11163 "2024-07-10T21:56:59Z")

</div>

Hello, CMake Team. I hope that list(SORT) command can add support for SEMVER comparison. Up to version v3.30, the list(SORT) command can use the following three comparison methods for sorting: STRING: Sorts a list of…

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

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