# Code

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

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

**Page:** 61

---

## [Using cmake\_llvm\_rc when cross-compiling.](https://discourse.cmake.org/t/using-cmake-llvm-rc-when-cross-compiling/3125)

<div class="topic-metadata">

**Author:** [@Horyu](https://discourse.cmake.org/u/Horyu)\
**Replies:** 3\
**Last updated:** [April 12, 2021, 4:59pm UTC](https://discourse.cmake.org/t/using-cmake-llvm-rc-when-cross-compiling/3125 "2021-04-12T16:59:38Z")

</div>

Hi, I’m trying to cross-compiling libraries with CLang-cl and llvm-rc. First, CMake glues together the parameter key and the parameter value together which is not supported by llvm-rc. For example: /l0x409 -DGOOGLE\_PR…

---

## [How to process .mc files in CMakeLists.txt](https://discourse.cmake.org/t/how-to-process-mc-files-in-cmakelists-txt/3102)

<div class="topic-metadata">

**Author:** [@Bart\_Vandewoestyne](https://discourse.cmake.org/u/Bart_Vandewoestyne)\
**Replies:** 1\
**Last updated:** [April 8, 2021, 9:56am UTC](https://discourse.cmake.org/t/how-to-process-mc-files-in-cmakelists-txt/3102 "2021-04-08T09:56:59Z")

</div>

I am currently converting some legacy build system based on Perl scripts and qmake files to CMake, and came across the following issue: In our C++ code, we include a file FooBar.h, but there is only a FooBar.mc file in …

---

## [CMake 3.19 CMakePresets.json user stories](https://discourse.cmake.org/t/cmake-3-19-cmakepresets-json-user-stories/2001)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 4\
**Last updated:** [April 7, 2021, 5:27pm UTC](https://discourse.cmake.org/t/cmake-3-19-cmakepresets-json-user-stories/2001 "2021-04-07T17:27:55Z")

</div>

I am curious, what are some of the intended use cases for CMakePresets.json that’s new for CMake 3.19. Is for Visual Studio / IDE users to avoid a lot of set() statements in CMakeLists.txt? Say one has 2 or 3 common use …

---

## [Cmake adds extra unwanted quotes to msvc linker flags](https://discourse.cmake.org/t/cmake-adds-extra-unwanted-quotes-to-msvc-linker-flags/3085)

<div class="topic-metadata">

**Author:** [@cen](https://discourse.cmake.org/u/cen)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 7:24pm UTC](https://discourse.cmake.org/t/cmake-adds-extra-unwanted-quotes-to-msvc-linker-flags/3085 "2021-04-06T19:24:40Z")

</div>

CMAKE 3.20.0, msvc. How do I get rid of these extra quotes? Code: target\_link\_options(my PRIVATE "/BASE:0x76290000") Actual flag passed to linker: /BASE:""0x76290000"" Error: LNK1146 no argument specified with optio…

---

## [How to add a dependency on a compiler plugin](https://discourse.cmake.org/t/how-to-add-a-dependency-on-a-compiler-plugin/3077)

<div class="topic-metadata">

**Author:** [@zauguin](https://discourse.cmake.org/u/zauguin)\
**Replies:** 9\
**Last updated:** [April 6, 2021, 11:40am UTC](https://discourse.cmake.org/t/how-to-add-a-dependency-on-a-compiler-plugin/3077 "2021-04-06T11:40:15Z")

</div>

Hi, I have project which builds a compiler plugin (target plugin) and in another directory try to use the plugin (target simple). Therefore I need the plugin (which is basically just a shared object) to be compiled an…

---

## [Passing a CMake target to a library expecting a pre-installed library](https://discourse.cmake.org/t/passing-a-cmake-target-to-a-library-expecting-a-pre-installed-library/3059)

<div class="topic-metadata">

**Author:** [@delthas](https://discourse.cmake.org/u/delthas)\
**Replies:** 2\
**Last updated:** [April 6, 2021, 9:13am UTC](https://discourse.cmake.org/t/passing-a-cmake-target-to-a-library-expecting-a-pre-installed-library/3059 "2021-04-06T09:13:54Z")

</div>

Hi, I’m building a project that builds and depends on two libraries, libA and libB. I’m adding both libraries very simply with add\_subdirectory(libA/) and add\_subdirectory(libB/). I don’t own the code for libA and libB,…

---

## [Android create shared library from prebuilt static libraries](https://discourse.cmake.org/t/android-create-shared-library-from-prebuilt-static-libraries/3056)

<div class="topic-metadata">

**Author:** [@sierma](https://discourse.cmake.org/u/sierma)\
**Replies:** 1\
**Last updated:** [April 4, 2021, 8:40am UTC](https://discourse.cmake.org/t/android-create-shared-library-from-prebuilt-static-libraries/3056 "2021-04-04T08:40:33Z")

</div>

Hello, I am working on Android library project, trying to migrate my native building configuration from ndk-build to cmake. My project uses prebuilt static and dynamic libraries, no additional sources. Static libs are …

---

## [generated source by external project](https://discourse.cmake.org/t/generated-source-by-external-project/3081)

<div class="topic-metadata">

**Author:** [@MBZ](https://discourse.cmake.org/u/MBZ)\
**Replies:** 2\
**Last updated:** [April 3, 2021, 1:55pm UTC](https://discourse.cmake.org/t/generated-source-by-external-project/3081 "2021-04-03T13:55:44Z")

</div>

I have ExternalProject that builds static library libfoo.a My shared library is linked with foo.a using: target\_link\_libraries ( proj PRIVATE \<FULL\_PATH\>/libfoo.a ) But, I get an error: ninja: error: ‘\<FULL\_PATH\>/li…

---

## [Get filepaths for data of application](https://discourse.cmake.org/t/get-filepaths-for-data-of-application/3019)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 3\
**Last updated:** [April 2, 2021, 11:58am UTC](https://discourse.cmake.org/t/get-filepaths-for-data-of-application/3019 "2021-04-02T11:58:18Z")

</div>

Hi, I have an application, which stores a database and log files. When I install my application I want that these will be written to a place, where they belong. So perhaps (not an expert here) on Linux my database shoul…

---

## [Using ExternalProject to download a header-only library](https://discourse.cmake.org/t/using-externalproject-to-download-a-header-only-library/3046)

<div class="topic-metadata">

**Author:** [@PaulMoore](https://discourse.cmake.org/u/PaulMoore)\
**Replies:** 11\
**Last updated:** [April 1, 2021, 9:02am UTC](https://discourse.cmake.org/t/using-externalproject-to-download-a-header-only-library/3046 "2021-04-01T09:02:47Z")

</div>

My code is extremely simple, it’s a single C file: cmake\_minimum\_required(VERSION 3.19) project(MyApp) add\_executable(MyApp myapp.c) But I want to #include a header from an external library (specifically SQLite). There…

---

## [MinGW paths from Qt, import CMake project on windows](https://discourse.cmake.org/t/mingw-paths-from-qt-import-cmake-project-on-windows/3030)

<div class="topic-metadata">

**Author:** [@Jos](https://discourse.cmake.org/u/Jos)\
**Replies:** 3\
**Last updated:** [April 1, 2021, 8:08am UTC](https://discourse.cmake.org/t/mingw-paths-from-qt-import-cmake-project-on-windows/3030 "2021-04-01T08:08:38Z")

</div>

I have a cmake managed code that compiles fine from the commandline cmake\_minimum\_required(VERSION 3.13) set(CMAKE\_PROJECT\_NAME "testProject") project(${CMAKE\_PROJECT\_NAME}) set(CMAKE\_CXX\_STANDARD 17) set(CMAKE\_CXX\_ST…

---

## [How can I combine INTERFACE libraries with shared libraries?](https://discourse.cmake.org/t/how-can-i-combine-interface-libraries-with-shared-libraries/3027)

<div class="topic-metadata">

**Author:** [@eliasdaler](https://discourse.cmake.org/u/eliasdaler)\
**Replies:** 7\
**Last updated:** [March 29, 2021, 8:57pm UTC](https://discourse.cmake.org/t/how-can-i-combine-interface-libraries-with-shared-libraries/3027 "2021-03-29T20:57:13Z")

</div>

Hello. I have a situation like this. add\_library(lib INTERFACE) target\_sources(lib INTERFACE "${CMAKE\_CURRENT\_SOURCE\_DIR}/lib.cpp") target\_include\_directories(lib INTERFACE "${CMAKE\_CURRENT\_SOURCE\_DIR}") Next, I want …

---

## [Generator Expressions and Namespace in target\_link\_libraries](https://discourse.cmake.org/t/generator-expressions-and-namespace-in-target-link-libraries/3038)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 3\
**Last updated:** [March 29, 2021, 1:03pm UTC](https://discourse.cmake.org/t/generator-expressions-and-namespace-in-target-link-libraries/3038 "2021-03-29T13:03:42Z")

</div>

Yet another post in “Matt tries to learn Effective CMake”. This time, it’s generator expressions! So, I have a code where we want to link in a library only if an option() is true. So I have (simplified): target\_link\_li…

---

## [Option and configure\_file: How to be consistent?](https://discourse.cmake.org/t/option-and-configure-file-how-to-be-consistent/3028)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 2\
**Last updated:** [March 26, 2021, 3:00pm UTC](https://discourse.cmake.org/t/option-and-configure-file-how-to-be-consistent/3028 "2021-03-26T15:00:26Z")

</div>

Once again, I bare my CMake ignorance to the forum! In this case, it’s to do with option(). Namely, in some code I have, I added: option(HYDROSTATIC "Build FV dynamics as hydrostatic" ON) if (HYDROSTATIC) ...build as …

---

## [Qt autogen source files custom compilation flags](https://discourse.cmake.org/t/qt-autogen-source-files-custom-compilation-flags/3002)

<div class="topic-metadata">

**Author:** [@R2RT](https://discourse.cmake.org/u/R2RT)\
**Replies:** 7\
**Last updated:** [March 26, 2021, 6:28am UTC](https://discourse.cmake.org/t/qt-autogen-source-files-custom-compilation-flags/3002 "2021-03-26T06:28:48Z")

</div>

I want to customize warning flags in my Qt5 project. It can be done with with simple target\_compile\_options(Library PRIVATE /Wall). But, the Library target is Qt5 with AUTOMOC logic enabled. This makes autogenerated L…

---

## [How to set PLANTUML\_JAR\_PATH](https://discourse.cmake.org/t/how-to-set-plantuml-jar-path/3021)

<div class="topic-metadata">

**Author:** [@Kajtek](https://discourse.cmake.org/u/Kajtek)\
**Replies:** 4\
**Last updated:** [March 25, 2021, 9:01pm UTC](https://discourse.cmake.org/t/how-to-set-plantuml-jar-path/3021 "2021-03-25T21:01:05Z")

</div>

To simplify example I have a docs directory with the following content: plantuml.jar CMakeLists.txt index.md with embedded PlantUML CMakeLists.txt: set(PLANTUML\_JAR\_PATH "${CMAKE\_CURRENT\_SOURCE\_DIR}/plantuml.jar") d…

---

## [How to export target which depends on other target which is in multiple export sets?](https://discourse.cmake.org/t/how-to-export-target-which-depends-on-other-target-which-is-in-multiple-export-sets/3007)

<div class="topic-metadata">

**Author:** [@dbahadir](https://discourse.cmake.org/u/dbahadir)\
**Replies:** 3\
**Last updated:** [March 25, 2021, 8:57pm UTC](https://discourse.cmake.org/t/how-to-export-target-which-depends-on-other-target-which-is-in-multiple-export-sets/3007 "2021-03-25T20:57:49Z")

</div>

Problem I am currently writing CMakeLists.txt files for a larger code project which consists of a hierarchy of different CMake projects which can either be built alone or monolithic all together. Sadly, I am encounterin…

---

## [\[feature request\] a cross platform find GNU GCC macro](https://discourse.cmake.org/t/feature-request-a-cross-platform-find-gnu-gcc-macro/3017)

<div class="topic-metadata">

**Author:** [@fsffarimani](https://discourse.cmake.org/u/fsffarimani)\
**Replies:** 2\
**Last updated:** [March 25, 2021, 6:24pm UTC](https://discourse.cmake.org/t/feature-request-a-cross-platform-find-gnu-gcc-macro/3017 "2021-03-25T18:24:28Z")

</div>

Following this discussion, we have the issue that we can’t find the GNU GCC (gcc, g++, and gfortran) installed via HomeBrew on macOS. There might some temporary workaround for this specific issue, but it would be great i…

---

## [How to use pthread win32 with Cmake](https://discourse.cmake.org/t/how-to-use-pthread-win32-with-cmake/3004)

<div class="topic-metadata">

**Author:** [@TharinduBalasooriya](https://discourse.cmake.org/u/TharinduBalasooriya)\
**Replies:** 1\
**Last updated:** [March 25, 2021, 6:18pm UTC](https://discourse.cmake.org/t/how-to-use-pthread-win32-with-cmake/3004 "2021-03-25T18:18:31Z")

</div>

Can anyone tell me how to add pthread win32 to program the use CMake to build I added the following to Cmake List but still not working cmake\_minimum\_required(VERSION 3.5) project(FlexibleComputerLanguage) set(CMAKE\_CX…

---

## [Turning single executable project into multi-executable](https://discourse.cmake.org/t/turning-single-executable-project-into-multi-executable/2555)

<div class="topic-metadata">

**Author:** [@KKoovalsky](https://discourse.cmake.org/u/KKoovalsky)\
**Replies:** 2\
**Last updated:** [January 19, 2021, 9:28pm UTC](https://discourse.cmake.org/t/turning-single-executable-project-into-multi-executable/2555 "2021-01-19T21:28:22Z")

</div>

I am trying to create a project for an embedded device that is based on Zephyr ecosystem. The problem I struggle with is that it forces single-executable project. It uses CMake. The way how Zephyr suggest to create the …

---

## [Install executable](https://discourse.cmake.org/t/install-executable/2989)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 5\
**Last updated:** [March 22, 2021, 11:04pm UTC](https://discourse.cmake.org/t/install-executable/2989 "2021-03-22T23:04:45Z")

</div>

Hi, I currently can’t figure out how to install an application. Thought with modern cmake it should pretty much only be: add\_exectuable(Test ...) install(TARGETS Test) And that’s it. That does literally install every…

---

## [install(FILE ...) with custom\_target](https://discourse.cmake.org/t/install-file-with-custom-target/2984)

<div class="topic-metadata">

**Author:** [@ANaumann85](https://discourse.cmake.org/u/ANaumann85)\
**Replies:** 5\
**Last updated:** [March 22, 2021, 12:48am UTC](https://discourse.cmake.org/t/install-file-with-custom-target/2984 "2021-03-22T00:48:42Z")

</div>

Dear all, TL ; DR: Is there a way to let “install(FILES output )” add a dependency of the target “install” to the file “output” ? I am building additional files, which will be used only at install time. Parts of that i…

---

## [Excluding targets/libraries from top level](https://discourse.cmake.org/t/excluding-targets-libraries-from-top-level/2935)

<div class="topic-metadata">

**Author:** [@Q123](https://discourse.cmake.org/u/Q123)\
**Replies:** 9\
**Last updated:** [March 18, 2021, 6:09pm UTC](https://discourse.cmake.org/t/excluding-targets-libraries-from-top-level/2935 "2021-03-18T18:09:14Z")

</div>

Suppose I have a repo that contains code that is compiled for multiple applications, each with their own flavour of that code base (files, compile defines, options, etc). Within that code base I would have a cmakelists.…

---

## [Need correct CMake “$\<TARGET\_NAME:” usage to enable cross-export set INTERFACE\_LINK\_LIBRARY dependencies](https://discourse.cmake.org/t/need-correct-cmake-target-name-usage-to-enable-cross-export-set-interface-link-library-dependencies/2772)

<div class="topic-metadata">

**Author:** [@chissg](https://discourse.cmake.org/u/chissg)\
**Replies:** 6\
**Last updated:** [March 18, 2021, 1:18pm UTC](https://discourse.cmake.org/t/need-correct-cmake-target-name-usage-to-enable-cross-export-set-interface-link-library-dependencies/2772 "2021-03-18T13:18:01Z")

</div>

I have a target in an export set—plugins::support\_macros, say—that has an interface link dependence on a target in a different export set in the same package (e.g. libs::main\_lib). I understand that I need to express the…

---

## [Echo Command in cmakelist](https://discourse.cmake.org/t/echo-command-in-cmakelist/2957)

<div class="topic-metadata">

**Author:** [@deepan](https://discourse.cmake.org/u/deepan)\
**Replies:** 3\
**Last updated:** [March 15, 2021, 4:50pm UTC](https://discourse.cmake.org/t/echo-command-in-cmakelist/2957 "2021-03-15T16:50:20Z")

</div>

I want to add comments to cmakelist so that they appear during make. for exmaple, before starting a module, the command prompt should show “Starting module1”… makefile creators are using echo command. I want to know ho…

---

## [installing dependencies during build time with Ninja](https://discourse.cmake.org/t/installing-dependencies-during-build-time-with-ninja/2944)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 7\
**Last updated:** [March 12, 2021, 6:16pm UTC](https://discourse.cmake.org/t/installing-dependencies-during-build-time-with-ninja/2944 "2021-03-12T18:16:45Z")

</div>

As part of our build process, we also install some dependencies that we have. Here is a short mostly-reproduction of what that looks like: cmake\_minimum\_required(VERSION 3.17) project(wat) # this is a path on my machin…

---

## [CMake: Own Shared libray in Windows: error while loading shared libraries](https://discourse.cmake.org/t/cmake-own-shared-libray-in-windows-error-while-loading-shared-libraries/2949)

<div class="topic-metadata">

**Author:** [@Jos](https://discourse.cmake.org/u/Jos)\
**Replies:** 2\
**Last updated:** [March 12, 2021, 3:22pm UTC](https://discourse.cmake.org/t/cmake-own-shared-libray-in-windows-error-while-loading-shared-libraries/2949 "2021-03-12T15:22:36Z")

</div>

Hi people, I have a CMake project with the next structure: ├── CMakeLists.txt ├── app │ ├── CMakeLists.txt │ └── main.cpp │ └── theLib ├── CMakeLists.txt ├── internal │ ├── internal.cpp │ └── internal.…

---

## [From QMake to CMake. (Different path levels)](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843)

<div class="topic-metadata">

**Author:** [@Jos](https://discourse.cmake.org/u/Jos)\
**Replies:** 4\
**Last updated:** [March 11, 2021, 2:59pm UTC](https://discourse.cmake.org/t/from-qmake-to-cmake-different-path-levels/2843 "2021-03-11T14:59:29Z")

</div>

Hi evereyone, I’m trying to port a multilevel project from QMake to CMake. Below show I the desired structure: The location of the root CMakeLists.txt a path level before than the main and the lib is a requirement …

---

## [target link quoted options with variable](https://discourse.cmake.org/t/target-link-quoted-options-with-variable/2930)

<div class="topic-metadata">

**Author:** [@kmosk](https://discourse.cmake.org/u/kmosk)\
**Replies:** 11\
**Last updated:** [March 10, 2021, 10:02pm UTC](https://discourse.cmake.org/t/target-link-quoted-options-with-variable/2930 "2021-03-10T22:02:17Z")

</div>

Hi, I need to pass some unorthodox path arguments to the linker, like: -j"C:\\some path\\to directory\\parser";"C:\\some path\\to directory\\block" Now my CMakeLists.txt looks like: ... set(PATH\_1 ${PROJECT\_SOURCE\_DIR}/par…

---

## [Understanding the CMake \`COMPONENT\` keyword in the \`install\` command](https://discourse.cmake.org/t/understanding-the-cmake-component-keyword-in-the-install-command/971)

<div class="topic-metadata">

**Author:** [@tomhh](https://discourse.cmake.org/u/tomhh)\
**Replies:** 11\
**Last updated:** [March 10, 2021, 9:46pm UTC](https://discourse.cmake.org/t/understanding-the-cmake-component-keyword-in-the-install-command/971 "2021-03-10T21:46:51Z")

</div>

Hello there, I recently had a number of questions around the CMake COMPONENT keyword used in the CMake install command and using COMPONENTS in the CMake find\_package command. After watching excellent talks by both Craig…

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

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