# Code

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

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

**Page:** 42

---

## [CMake: how to generate self-package?](https://discourse.cmake.org/t/cmake-how-to-generate-self-package/6571)

<div class="topic-metadata">

**Author:** [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)\
**Replies:** 2\
**Last updated:** [October 9, 2022, 3:37am UTC](https://discourse.cmake.org/t/cmake-how-to-generate-self-package/6571 "2022-10-09T03:37:21Z")

</div>

I have implemented myself package, and I want to distribute the dll/lib. Currently, I can generate dll/lib with install. How can I generate the variable Self\_LIBRARIES just like ITK\_LIBRARIES? With Self\_LIBRARIES, user…

---

## [Select variable depending on build variant](https://discourse.cmake.org/t/select-variable-depending-on-build-variant/6627)

<div class="topic-metadata">

**Author:** [@Glad](https://discourse.cmake.org/u/Glad)\
**Replies:** 2\
**Last updated:** [October 8, 2022, 11:31am UTC](https://discourse.cmake.org/t/select-variable-depending-on-build-variant/6627 "2022-10-08T11:31:30Z")

</div>

Hi, I have a CMake file which has the following 3 lines, among many others: set(LIBS\_TYPE "\_dbg") set(CMAKE\_CONFIGURATION\_TYPES "Debug" "Release") target\_link\_libraries(${APP\_NAME} PUBLIC ${STATIC\_libs}/my\_lib${LIBS\_TY…

---

## [VTK v9.1/Qt 5.15.6/${VTK\_LIBRARIES} - dependencies wrong?](https://discourse.cmake.org/t/vtk-v9-1-qt-5-15-6-vtk-libraries-dependencies-wrong/6608)

<div class="topic-metadata">

**Author:** [@joeymukherjee](https://discourse.cmake.org/u/joeymukherjee)\
**Replies:** 7\
**Last updated:** [October 7, 2022, 6:05pm UTC](https://discourse.cmake.org/t/vtk-v9-1-qt-5-15-6-vtk-libraries-dependencies-wrong/6608 "2022-10-07T18:05:23Z")

</div>

I am running on a Mac using vtk9.1 and Qt 5.15.6. I installed these via brew. When I have ${VTK\_LIBRARIES} in my “target\_link\_libraries”, a random -isystem /usr/local/include shows up in my link line breaking my build. …

---

## [How to create a tarball with all the sources from FetchContents?](https://discourse.cmake.org/t/how-to-create-a-tarball-with-all-the-sources-from-fetchcontents/6618)

<div class="topic-metadata">

**Author:** [@mojca](https://discourse.cmake.org/u/mojca)\
**Replies:** 1\
**Last updated:** [October 7, 2022, 5:43pm UTC](https://discourse.cmake.org/t/how-to-create-a-tarball-with-all-the-sources-from-fetchcontents/6618 "2022-10-07T17:43:39Z")

</div>

Over the course of a few months since we started a project we realized that FetchContents has beaten us a number of times when upstream projects that we depend on rewrote git history, added a few commits on top of their …

---

## [How to write a proper configurePreset using MinGW compilers with "MinGW Makefiles" generator?](https://discourse.cmake.org/t/how-to-write-a-proper-configurepreset-using-mingw-compilers-with-mingw-makefiles-generator/6615)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 4\
**Last updated:** [October 7, 2022, 1:54pm UTC](https://discourse.cmake.org/t/how-to-write-a-proper-configurepreset-using-mingw-compilers-with-mingw-makefiles-generator/6615 "2022-10-07T13:54:02Z")

</div>

Problem Descriptions First of all, I already installed MinGW64 compiler in MSYS with running the following command: pacman -S mingw-w64-x86\_64-toolchain And I tried the following example of CMakePresets.json: ▶ Click to…

---

## [CMake install does nothing (macOS)](https://discourse.cmake.org/t/cmake-install-does-nothing-macos/6602)

<div class="topic-metadata">

**Author:** [@amzh](https://discourse.cmake.org/u/amzh)\
**Replies:** 2\
**Last updated:** [October 7, 2022, 10:04am UTC](https://discourse.cmake.org/t/cmake-install-does-nothing-macos/6602 "2022-10-07T10:04:56Z")

</div>

Hello, we 're trying to install 3rd party libraries, we’re using Xcode 12 on macOS Catalina. Problem is in that the setup does work on Windows machines with Visual Studio 17 but does not on a Mac one. Our script basica…

---

## [Cross platform in the IDE.](https://discourse.cmake.org/t/cross-platform-in-the-ide/6015)

<div class="topic-metadata">

**Author:** [@jshanab](https://discourse.cmake.org/u/jshanab)\
**Replies:** 10\
**Last updated:** [October 5, 2022, 11:52pm UTC](https://discourse.cmake.org/t/cross-platform-in-the-ide/6015 "2022-10-05T23:52:24Z")

</div>

I know cmake can generate makefiles for linux and vcproj and a sln for windows. Is there a way to create a project that opens and builds for windows in Visual Studio that also lets you use wsl:ubuntu to genrate makefile…

---

## [How to add symbolic links for loadable MODULE like for shared lib?](https://discourse.cmake.org/t/how-to-add-symbolic-links-for-loadable-module-like-for-shared-lib/6585)

<div class="topic-metadata">

**Author:** [@evilroach](https://discourse.cmake.org/u/evilroach)\
**Replies:** 9\
**Last updated:** [October 3, 2022, 6:18pm UTC](https://discourse.cmake.org/t/how-to-add-symbolic-links-for-loadable-module-like-for-shared-lib/6585 "2022-10-03T18:18:58Z")

</div>

I’m using cmake-3.16, and for other technical reason, I must use MODULE to make a dynamic loadable module(\*.so) in Linux instead of using SHARED. But with MODULE, cmake does NOT produce target files with name like “libD…

---

## [How to copy an auxiliary file in the build directory that will be updated by CMake when needed](https://discourse.cmake.org/t/how-to-copy-an-auxiliary-file-in-the-build-directory-that-will-be-updated-by-cmake-when-needed/6580)

<div class="topic-metadata">

**Author:** [@vmagnin](https://discourse.cmake.org/u/vmagnin)\
**Replies:** 3\
**Last updated:** [September 30, 2022, 6:49am UTC](https://discourse.cmake.org/t/how-to-copy-an-auxiliary-file-in-the-build-directory-that-will-be-updated-by-cmake-when-needed/6580 "2022-09-30T06:49:41Z")

</div>

Dear CMake community, I am developing and maintaining the gtk-fortran project since 2011. Its main build system is CMake. Although I have learned since 2016 to maintain myself the CMake part, I am far from being an expe…

---

## [Controlling Visual Studio options from CMake](https://discourse.cmake.org/t/controlling-visual-studio-options-from-cmake/6581)

<div class="topic-metadata">

**Author:** [@Naum\_Derzhi](https://discourse.cmake.org/u/Naum_Derzhi)\
**Replies:** 4\
**Last updated:** [September 29, 2022, 7:05pm UTC](https://discourse.cmake.org/t/controlling-visual-studio-options-from-cmake/6581 "2022-09-29T19:05:52Z")

</div>

When CMake generates VisualStudio solution and project for an application, the default setting for Project-\>Linker-\>System-\>Subsystem project parameter is Windows, but I need Console. Every time the solution is updated, …

---

## [How to set swift macros from cmake](https://discourse.cmake.org/t/how-to-set-swift-macros-from-cmake/6494)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 5\
**Last updated:** [September 29, 2022, 1:32pm UTC](https://discourse.cmake.org/t/how-to-set-swift-macros-from-cmake/6494 "2022-09-29T13:32:56Z")

</div>

I have a swift project which uses macros for conditional compilation. How to set macro: Go to Target → BuildSettings → Swift Compiler - Custom Flags → Active Compilation Conditions and add your macro (Ex: sample macro -…

---

## [Best practices for handling multiple calls to package-config.cmake across large projects](https://discourse.cmake.org/t/best-practices-for-handling-multiple-calls-to-package-config-cmake-across-large-projects/3472)

<div class="topic-metadata">

**Author:** [@sbolding](https://discourse.cmake.org/u/sbolding)\
**Replies:** 7\
**Last updated:** [September 28, 2022, 10:15pm UTC](https://discourse.cmake.org/t/best-practices-for-handling-multiple-calls-to-package-config-cmake-across-large-projects/3472 "2022-09-28T22:15:10Z")

</div>

Hello, I have some questions about what is considered best practice for writing a basic package config file when searching for dependencies, and I haven’t had much luck deducing it from the internet. To explain my ques…

---

## [example: check if write access to path](https://discourse.cmake.org/t/example-check-if-write-access-to-path/6535)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 3\
**Last updated:** [September 27, 2022, 7:10pm UTC](https://discourse.cmake.org/t/example-check-if-write-access-to-path/6535 "2022-09-27T19:10:07Z")

</div>

At CMake configure time I often need to test if a directory or file is writable. One example is to fatal\_error if CMAKE\_INSTALL\_PREFIX is not in a writable location for users not so experienced with CMake or building pro…

---

## [How to detect "dot" in PATH](https://discourse.cmake.org/t/how-to-detect-dot-in-path/6551)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 1\
**Last updated:** [September 27, 2022, 7:06pm UTC](https://discourse.cmake.org/t/how-to-detect-dot-in-path/6551 "2022-09-27T19:06:42Z")

</div>

All, This is a fun one. In trying to help a user of a library I help maintain, he was having all sorts of issues at CMake time. After a day or so of puzzling over --trace --debug-find output, I finally realized the issu…

---

## [target\_link\_libraries and list of PLATFORM\_IDs](https://discourse.cmake.org/t/target-link-libraries-and-list-of-platform-ids/6549)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 4\
**Last updated:** [September 27, 2022, 9:17am UTC](https://discourse.cmake.org/t/target-link-libraries-and-list-of-platform-ids/6549 "2022-09-27T09:17:02Z")

</div>

Hello, found this SO post that fails on 3.20 and I verified on 3.21.2 myself. That is, you can’t list several libraries under target\_link\_libraries with PLATFORM\_ID unless you put them in a list variable outside and the…

---

## [Add a compiled third library to CMakelists.txt](https://discourse.cmake.org/t/add-a-compiled-third-library-to-cmakelists-txt/6558)

<div class="topic-metadata">

**Author:** [@Judy\_Wei](https://discourse.cmake.org/u/Judy_Wei)\
**Replies:** 3\
**Last updated:** [September 26, 2022, 7:28pm UTC](https://discourse.cmake.org/t/add-a-compiled-third-library-to-cmakelists-txt/6558 "2022-09-26T19:28:48Z")

</div>

Hi, When I tried to add a precompiled third-party library OpenNetVM to my CMakelists.txt of a current project, I met an issue to call the functions of the third library. The third-party library has only Makefile and it …

---

## [One compilation database including external projects?](https://discourse.cmake.org/t/one-compilation-database-including-external-projects/6544)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 3\
**Last updated:** [September 26, 2022, 6:38am UTC](https://discourse.cmake.org/t/one-compilation-database-including-external-projects/6544 "2022-09-26T06:38:56Z")

</div>

Is there a way to get cmake to generate one compilation database (compile\_commands.json) for the entire project including external projects? Currently every external project gets its own db. Or is there a cmake way to me…

---

## [warning MSB4011: masm.props cannot be imported again.](https://discourse.cmake.org/t/warning-msb4011-masm-props-cannot-be-imported-again/6566)

<div class="topic-metadata">

**Author:** [@PaulS](https://discourse.cmake.org/u/PaulS)\
**Replies:** 0\
**Last updated:** [September 23, 2022, 11:22pm UTC](https://discourse.cmake.org/t/warning-msb4011-masm-props-cannot-be-imported-again/6566 "2022-09-23T23:22:18Z")

</div>

Hi, I’m using cmake to create the .sln/.vcxproj files for our Windows driver. Everything is working fine, except I get the following MSBUILD warning which I’d like to suppress or eliminate. warning MSB4011: “…\\BuildC…

---

## [CXX\_CLANG\_TIDY not running for library](https://discourse.cmake.org/t/cxx-clang-tidy-not-running-for-library/6547)

<div class="topic-metadata">

**Author:** [@DaAwesomeP](https://discourse.cmake.org/u/DaAwesomeP)\
**Replies:** 2\
**Last updated:** [September 22, 2022, 6:51pm UTC](https://discourse.cmake.org/t/cxx-clang-tidy-not-running-for-library/6547 "2022-09-22T18:51:14Z")

</div>

I am writing a library, and I cannot get clang-tidy to run on build. This is a headers-only library because all of the classes provided have templates, and you cannot define template class members outside of the template…

---

## [How to change the active solution configuration of visual studio](https://discourse.cmake.org/t/how-to-change-the-active-solution-configuration-of-visual-studio/6541)

<div class="topic-metadata">

**Author:** [@msilvestre](https://discourse.cmake.org/u/msilvestre)\
**Replies:** 5\
**Last updated:** [September 22, 2022, 12:25pm UTC](https://discourse.cmake.org/t/how-to-change-the-active-solution-configuration-of-visual-studio/6541 "2022-09-22T12:25:40Z")

</div>

Hi there, I’ve searched for this but didn’t find the solution. Is there any way of changing the active solution configuration of visual studio? When I open the visual studio solution I want to have RelWithDebugInfo …

---

## [Propagate install/strip target to external project](https://discourse.cmake.org/t/propagate-install-strip-target-to-external-project/6537)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 1\
**Last updated:** [September 21, 2022, 1:22pm UTC](https://discourse.cmake.org/t/propagate-install-strip-target-to-external-project/6537 "2022-09-21T13:22:18Z")

</div>

Is there a way to propagate the install/strip target also to external projects? My external project has an install step (without strip), but if the main project is invoked with install/strip I want to pass that strip ins…

---

## [MSVC: DELAYLOAD example](https://discourse.cmake.org/t/msvc-delayload-example/6534)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 2\
**Last updated:** [September 20, 2022, 6:26pm UTC](https://discourse.cmake.org/t/msvc-delayload-example/6534 "2022-09-20T18:26:51Z")

</div>

CMAKE\_LINK\_LIBRARY\_USING\_FEATURE is a nice addition to CMake. While there isn’t a delayload feature for MSVC-like compilers, as noted by Marc below /delayload can be accomplished in a compact way as in the following ex…

---

## [Just can't get the location of the project's source tree to CPack.](https://discourse.cmake.org/t/just-cant-get-the-location-of-the-projects-source-tree-to-cpack/6396)

<div class="topic-metadata">

**Author:** [@Lord-Kamina](https://discourse.cmake.org/u/Lord-Kamina)\
**Replies:** 3\
**Last updated:** [September 20, 2022, 11:33am UTC](https://discourse.cmake.org/t/just-cant-get-the-location-of-the-projects-source-tree-to-cpack/6396 "2022-09-20T11:33:27Z")

</div>

I’m trying to create an nsis installer via the GH Actions runners. I’ve defined some code in the INSTALL section, to copy and bundle all the libs (I’m using a shell script , rather than the built-in functionality). The…

---

## [Linking cpp files to a sub CMakeList that will compile to the Root Cmake Lists.](https://discourse.cmake.org/t/linking-cpp-files-to-a-sub-cmakelist-that-will-compile-to-the-root-cmake-lists/6503)

<div class="topic-metadata">

**Author:** [@luke\_zerafa](https://discourse.cmake.org/u/luke_zerafa)\
**Replies:** 1\
**Last updated:** [September 20, 2022, 12:08am UTC](https://discourse.cmake.org/t/linking-cpp-files-to-a-sub-cmakelist-that-will-compile-to-the-root-cmake-lists/6503 "2022-09-20T00:08:24Z")

</div>

Hello there. So i have this configuration of files: I placed the main CMakeLists.txt in the root folder, this creates an executable. In ./imgui/CMakeLists.txt I would like this CMakeList to point to specific cpp file…

---

## [Switching toolchains](https://discourse.cmake.org/t/switching-toolchains/6499)

<div class="topic-metadata">

**Author:** [@patsv](https://discourse.cmake.org/u/patsv)\
**Replies:** 1\
**Last updated:** [September 18, 2022, 12:43pm UTC](https://discourse.cmake.org/t/switching-toolchains/6499 "2022-09-18T12:43:00Z")

</div>

I am trying to create a buildflow for an embedded target that will first create some ntaive (host) tools and then compile the target application. After target compilkation the target code will be prepared to be flashed …

---

## [CMAKE\_STAGING\_PREFIX vs. CMAKE\_INSTALL\_PREFIX](https://discourse.cmake.org/t/cmake-staging-prefix-vs-cmake-install-prefix/6485)

<div class="topic-metadata">

**Author:** [@bradlit](https://discourse.cmake.org/u/bradlit)\
**Replies:** 1\
**Last updated:** [September 15, 2022, 10:19pm UTC](https://discourse.cmake.org/t/cmake-staging-prefix-vs-cmake-install-prefix/6485 "2022-09-15T22:19:08Z")

</div>

I’ve read the definitions in cmake-variables, but I’m still puzzled by the relationship between CMAKE\_STAGING\_PREFIX and CMAKE\_INSTALL\_PREFIX. Some simple experiments seem to indicate that the perform the same function,…

---

## [CMake installing or exporting in monorepo](https://discourse.cmake.org/t/cmake-installing-or-exporting-in-monorepo/6454)

<div class="topic-metadata">

**Author:** [@technic](https://discourse.cmake.org/u/technic)\
**Replies:** 8\
**Last updated:** [September 15, 2022, 4:09pm UTC](https://discourse.cmake.org/t/cmake-installing-or-exporting-in-monorepo/6454 "2022-09-15T16:09:59Z")

</div>

What is the difference between installing and exporting? I have a monorepo with few libs and apps added with add\_subdirectory() to root CMakeLists.txt. I want to be able to open a single app project separately (without n…

---

## [Compiler option stripped by Visual Studio generator?](https://discourse.cmake.org/t/compiler-option-stripped-by-visual-studio-generator/6476)

<div class="topic-metadata">

**Author:** [@bradlit](https://discourse.cmake.org/u/bradlit)\
**Replies:** 3\
**Last updated:** [September 15, 2022, 12:23pm UTC](https://discourse.cmake.org/t/compiler-option-stripped-by-visual-studio-generator/6476 "2022-09-15T12:23:06Z")

</div>

It seems the VS 16 code generator is stripping /Wall (all warnings), while the NMake and Ninja generators do not. Is this expected? cmake version 3.23.1 CMakeLists.txt: cmake\_minimum\_required(VERSION 3.16.3) project(…

---

## [How to solve Following "multiple uses of -o are not allowed" Error ??](https://discourse.cmake.org/t/how-to-solve-following-multiple-uses-of-o-are-not-allowed-error/6220)

<div class="topic-metadata">

**Author:** [@vasantharaj](https://discourse.cmake.org/u/vasantharaj)\
**Replies:** 2\
**Last updated:** [September 14, 2022, 10:53pm UTC](https://discourse.cmake.org/t/how-to-solve-following-multiple-uses-of-o-are-not-allowed-error/6220 "2022-09-14T22:53:24Z")

</div>

unable generate .elf file using command -output=${project name}.elf it showing below given Error. cctc E204: multiple uses of -o are not allowed Compiler: Tasking

---

## [Tasking compiler: Linking error - "cctc E205: don’t know what to do with @CMakeFiles\\sample.rsp"](https://discourse.cmake.org/t/tasking-compiler-linking-error-cctc-e205-don-t-know-what-to-do-with-cmakefiles-sample-rsp/5110)

<div class="topic-metadata">

**Author:** [@satheesh.jetti](https://discourse.cmake.org/u/satheesh.jetti)\
**Replies:** 11\
**Last updated:** [September 14, 2022, 8:59pm UTC](https://discourse.cmake.org/t/tasking-compiler-linking-error-cctc-e205-don-t-know-what-to-do-with-cmakefiles-sample-rsp/5110 "2022-09-14T20:59:45Z")

</div>

i have created cmake project , i included all the source files , i am able to generate object files but i got linking error. this is the error → “cctc E205: don’t know what to do with @CMakeFiles\\sample.rsp” . compiler…

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

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