# Usage

**URL:** https://discourse.cmake.org/c/usage/12.md?page=15

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

**Page:** 16

---

## [CMake \>= 3.24 linking changes: Fortran main with C++ library](https://discourse.cmake.org/t/cmake-3-24-linking-changes-fortran-main-with-c-library/13487)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 1\
**Last updated:** [January 27, 2025, 6:12pm UTC](https://discourse.cmake.org/t/cmake-3-24-linking-changes-fortran-main-with-c-library/13487 "2025-01-27T18:12:05Z")

</div>

Since CMake 3.24.0, the linker overhaul (or other release changes) have had the effect of omitting “-lc++” when AppleClang is used with GNU Fortran to make a Fortran main executable with C++ library. I have a MWE at CMa…

---

## [Building a library as BOTH as a shared library and as and archive?](https://discourse.cmake.org/t/building-a-library-as-both-as-a-shared-library-and-as-and-archive/13485)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 10:17pm UTC](https://discourse.cmake.org/t/building-a-library-as-both-as-a-shared-library-and-as-and-archive/13485 "2025-01-25T22:17:56Z")

</div>

I can force a library to be built as an archive by specifying: -DBUILD\_SHARED\_LIBS=OFF but how can I force it to be built as a both a static library and a dynamic library? Thanks David

---

## [cmake-gui linker errors](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470)

<div class="topic-metadata">

**Author:** [@ralian](https://discourse.cmake.org/u/ralian)\
**Replies:** 3\
**Last updated:** [January 24, 2025, 10:28pm UTC](https://discourse.cmake.org/t/cmake-gui-linker-errors/13470 "2025-01-24T22:28:09Z")

</div>

Hello, I am trying to build the Qt-based cmake-gui as I want to get started developing for it. I am working on Windows with Visual Studio 17 2022 as my generator and compiler, and I am able to build the base CMake execut…

---

## [CMake Error: The source directory "C:/aseprite" does not appear to contain CMakeLists.txt.](https://discourse.cmake.org/t/cmake-error-the-source-directory-c-aseprite-does-not-appear-to-contain-cmakelists-txt/12840)

<div class="topic-metadata">

**Author:** [@Jaiden\_Egan](https://discourse.cmake.org/u/Jaiden_Egan)\
**Replies:** 1\
**Last updated:** [January 24, 2025, 4:48pm UTC](https://discourse.cmake.org/t/cmake-error-the-source-directory-c-aseprite-does-not-appear-to-contain-cmakelists-txt/12840 "2025-01-24T16:48:04Z")

</div>

I was following a tutorial but when I typed: C:\\aseprite\\build\>cmake -DCMAKE\_BUILD\_TYPE=RelWithDebInfo -DLAF\_BACKEND=skia -DSKIA\_DIR=C:\\deps\\skia -DSKIA\_LIBRARY\_DIR=C:\\deps\\skia\\out\\Release-x64 -DSKIA\_LIBRARY=C:\\deps\\sk…

---

## [Issue with dependencies propagation when different versions are present](https://discourse.cmake.org/t/issue-with-dependencies-propagation-when-different-versions-are-present/10429)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [January 23, 2025, 5:16pm UTC](https://discourse.cmake.org/t/issue-with-dependencies-propagation-when-different-versions-are-present/10429 "2025-01-23T17:16:44Z")

</div>

This question is a consequence of this other one I’m writing a static library MyLib which I properly package to be found with find\_package. This lib is privately linking another one ThirdPartyLib which is also detected…

---

## [CMake Error: Unknown argument --install](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445)

<div class="topic-metadata">

**Author:** [@vfdff](https://discourse.cmake.org/u/vfdff)\
**Replies:** 7\
**Last updated:** [January 23, 2025, 10:22am UTC](https://discourse.cmake.org/t/cmake-error-unknown-argument-install/13445 "2025-01-23T10:22:53Z")

</div>

I download cmake-3.31.4.tar.gz and try to build it local, so I use the following comands: mkdir build install cd build cmake …/ --build . --install …/intall it reports a strange error as I can see the option –insta…

---

## [install FILES given no DESTINATION](https://discourse.cmake.org/t/install-files-given-no-destination/13446)

<div class="topic-metadata">

**Author:** [@vfdff](https://discourse.cmake.org/u/vfdff)\
**Replies:** 4\
**Last updated:** [January 23, 2025, 9:28am UTC](https://discourse.cmake.org/t/install-files-given-no-destination/13446 "2025-01-23T09:28:33Z")

</div>

We already specify the DESTINATION for FILES, but it reports install FILES given no DESTINATION 1 get\_filename\_component(BASE\_DIR "${CMAKE\_CURRENT\_LIST\_DIR}" ABSOLUTE) 2 3 set(AOE\_CONFIG ${CMAKE\_CURRENT\_SOURCE\_D…

---

## [Tutorial step1 Error with project()](https://discourse.cmake.org/t/tutorial-step1-error-with-project/11520)

<div class="topic-metadata">

**Author:** [@vichebar](https://discourse.cmake.org/u/vichebar)\
**Replies:** 4\
**Last updated:** [January 22, 2025, 8:29pm UTC](https://discourse.cmake.org/t/tutorial-step1-error-with-project/11520 "2025-01-22T20:29:58Z")

</div>

I was following the tutorial and in the first step Exercise 1 - Building a Basic Project the instructions ask to run in the console cmake ../Step1 And as the output I got CMake Error at CMakeLists.txt:5 (project):…

---

## [How can I use CMake with GreenHills compiler](https://discourse.cmake.org/t/how-can-i-use-cmake-with-greenhills-compiler/4388)

<div class="topic-metadata">

**Author:** [@AbdAllah.ElTamaly](https://discourse.cmake.org/u/AbdAllah.ElTamaly)\
**Replies:** 17\
**Last updated:** [January 22, 2025, 6:51am UTC](https://discourse.cmake.org/t/how-can-i-use-cmake-with-greenhills-compiler/4388 "2025-01-22T06:51:19Z")

</div>

Hello, I have been trying to use CMake to generate Makefiles for a C project compiling using GreenHills compiler. But I am getting these errors: – The C compiler identification is GHS – The CXX compiler identification…

---

## [Recommended approach for having multiple "products/exports/libraries/executables"](https://discourse.cmake.org/t/recommended-approach-for-having-multiple-products-exports-libraries-executables/13442)

<div class="topic-metadata">

**Author:** [@SamCoutteauHybrid](https://discourse.cmake.org/u/SamCoutteauHybrid)\
**Replies:** 0\
**Last updated:** [January 21, 2025, 1:44pm UTC](https://discourse.cmake.org/t/recommended-approach-for-having-multiple-products-exports-libraries-executables/13442 "2025-01-21T13:44:48Z")

</div>

after reading a lot of documentation I think I understand how to Configure, Build, Export, Install, … a project with one main “product/…”, such as a library or exe, using modern cmake pratices. However I’m still unsure o…

---

## [Specifying linker by path is broken!](https://discourse.cmake.org/t/specifying-linker-by-path-is-broken/13441)

<div class="topic-metadata">

**Author:** [@Time0o](https://discourse.cmake.org/u/Time0o)\
**Replies:** 4\
**Last updated:** [January 21, 2025, 12:53pm UTC](https://discourse.cmake.org/t/specifying-linker-by-path-is-broken/13441 "2025-01-21T12:53:36Z")

</div>

According to the documentation the following should be possible: cmake -B build \\ -DCMAKE\_C\_COMPILER=/llvm-project/llvm/build/projects/bin/clang \\ -DCMAKE\_CXX\_COMPILER=/llvm-project/llvm/build/projects/b…

---

## [Static library dependency problem](https://discourse.cmake.org/t/static-library-dependency-problem/13438)

<div class="topic-metadata">

**Author:** [@Mario\_Rossi](https://discourse.cmake.org/u/Mario_Rossi)\
**Replies:** 4\
**Last updated:** [January 20, 2025, 10:04pm UTC](https://discourse.cmake.org/t/static-library-dependency-problem/13438 "2025-01-20T22:04:14Z")

</div>

I have a project where there is 1 static library (A) and 1 executable (E) Linux, Ubuntu 24.04, cmake 3.28.3 The static library (A) itself links some system provided static libraries like this target\_link\_libraries(A P…

---

## [check\_ipo\_supported returns false with clang msys2 version on windows.](https://discourse.cmake.org/t/check-ipo-supported-returns-false-with-clang-msys2-version-on-windows/13436)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 0\
**Last updated:** [January 20, 2025, 3:48pm UTC](https://discourse.cmake.org/t/check-ipo-supported-returns-false-with-clang-msys2-version-on-windows/13436 "2025-01-20T15:48:36Z")

</div>

Everything in the object :slight\_smile: check\_ipo\_supported(RESULT IPO\_SUPPORTED) returns IPO\_SUPPORTED as true for msvc and msys2/gcc but false for msys2/clang. According to clang --help flto options are available. I…

---

## [How to add comand line arguments for running executables in VS 2022 ?](https://discourse.cmake.org/t/how-to-add-comand-line-arguments-for-running-executables-in-vs-2022/13423)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 6\
**Last updated:** [January 19, 2025, 10:01pm UTC](https://discourse.cmake.org/t/how-to-add-comand-line-arguments-for-running-executables-in-vs-2022/13423 "2025-01-19T22:01:31Z")

</div>

When using the cmake support in VS2022, as far as I know launch.vs.json is the place where I can add command line options for the executable I want to run. Now, since it needs several dlls from different locations, in m…

---

## [Manage shared library dependencies on multiple targets](https://discourse.cmake.org/t/manage-shared-library-dependencies-on-multiple-targets/13429)

<div class="topic-metadata">

**Author:** [@mix359](https://discourse.cmake.org/u/mix359)\
**Replies:** 0\
**Last updated:** [January 18, 2025, 6:54pm UTC](https://discourse.cmake.org/t/manage-shared-library-dependencies-on-multiple-targets/13429 "2025-01-18T18:54:56Z")

</div>

Hi to All, I’m new to cmake and I’m struggling a bit creating a configuration for my case: I’m working on a desktop application in c++ that depend on various external libraries. In that project I have 3 cmake targets: o…

---

## [How to merge libraries into single shared library](https://discourse.cmake.org/t/how-to-merge-libraries-into-single-shared-library/13421)

<div class="topic-metadata">

**Author:** [@Nicholaswogan](https://discourse.cmake.org/u/Nicholaswogan)\
**Replies:** 3\
**Last updated:** [January 18, 2025, 12:33am UTC](https://discourse.cmake.org/t/how-to-merge-libraries-into-single-shared-library/13421 "2025-01-18T00:33:25Z")

</div>

Consider the following simple example below. Suppose I have library a and library b, where b is linked to a. I want to create a shared library b\_merged that contains all the compiled code necessary to use library b. I wa…

---

## [If you'd like to have RPATH under Windows...](https://discourse.cmake.org/t/if-youd-like-to-have-rpath-under-windows/13422)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 0\
**Last updated:** [January 17, 2025, 10:23pm UTC](https://discourse.cmake.org/t/if-youd-like-to-have-rpath-under-windows/13422 "2025-01-17T22:23:47Z")

</div>

If you’d like to have RPATH under Windows, so that running dlls from the build directory becomes easier, consider voting this item up: Developer Community I guess the chances are small, but maybe it helps.

---

## [purpose of @PACKAGE\_INIT@](https://discourse.cmake.org/t/purpose-of-package-init/13319)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 1\
**Last updated:** [January 17, 2025, 7:04pm UTC](https://discourse.cmake.org/t/purpose-of-package-init/13319 "2025-01-17T19:04:20Z")

</div>

I never used it in my configuration files and never encountered any issues. What I read about this placeholder did not help me to understand it’s actual purpose (and why I survived so far without it). Can someone provid…

---

## [error while loading shared libraries: libwhisper.so.1: cannot open shared object file: No such file or directory](https://discourse.cmake.org/t/error-while-loading-shared-libraries-libwhisper-so-1-cannot-open-shared-object-file-no-such-file-or-directory/13409)

<div class="topic-metadata">

**Author:** [@Raphy](https://discourse.cmake.org/u/Raphy)\
**Replies:** 0\
**Last updated:** [January 16, 2025, 3:01pm UTC](https://discourse.cmake.org/t/error-while-loading-shared-libraries-libwhisper-so-1-cannot-open-shared-object-file-no-such-file-or-directory/13409 "2025-01-16T15:01:01Z")

</div>

I installed whisper in MyPrj : ~/Downloads/whisper.cpp$ cmake --install builddir/ --prefix=/home/me/MyPrj/src/whisperLib -- Install configuration: "Release" -- Installing: /home/me/MyPrj/src/whisperLib/lib/libwhisper.so…

---

## [How do I get generated files to be built first?](https://discourse.cmake.org/t/how-do-i-get-generated-files-to-be-built-first/13370)

<div class="topic-metadata">

**Author:** [@rsalz](https://discourse.cmake.org/u/rsalz)\
**Replies:** 10\
**Last updated:** [January 16, 2025, 2:07pm UTC](https://discourse.cmake.org/t/how-do-i-get-generated-files-to-be-built-first/13370 "2025-01-16T14:07:25Z")

</div>

I have a series of files include/openssl/foo.gen that have a custom command to build {build-dir}include/openssl/foo.h. And foo.h is include’d in various source files. How do I ensure that the step runs before compiling b…

---

## [Gromacs compilation: Could NOT find CUDA](https://discourse.cmake.org/t/gromacs-compilation-could-not-find-cuda/13405)

<div class="topic-metadata">

**Author:** [@Natalia\_Chesnokova](https://discourse.cmake.org/u/Natalia_Chesnokova)\
**Replies:** 0\
**Last updated:** [January 15, 2025, 2:45pm UTC](https://discourse.cmake.org/t/gromacs-compilation-could-not-find-cuda/13405 "2025-01-15T14:45:14Z")

</div>

Hi everyone! When I compile Gromacs with GPU acceleration from source code, I get a message “Could NOT find CUDA (missing: CUDA\_NVCC\_EXECUTABLE CUDA\_INCLUDE\_DIRS CUDA\_CUDART\_LIBRARY)” when running the Cmake command. M…

---

## [Cannot set toolset when configuring with the Visual Studio 2022 generator.](https://discourse.cmake.org/t/cannot-set-toolset-when-configuring-with-the-visual-studio-2022-generator/10160)

<div class="topic-metadata">

**Author:** [@teo-tsirpanis](https://discourse.cmake.org/u/teo-tsirpanis)\
**Replies:** 15\
**Last updated:** [January 15, 2025, 1:45pm UTC](https://discourse.cmake.org/t/cannot-set-toolset-when-configuring-with-the-visual-studio-2022-generator/10160 "2025-01-15T13:45:52Z")

</div>

I have installed on my machine Visual Studio 2022 17.9 with the MSVC toolsets 14.36, 14.38 and 14.39. I created with Visual Studio a new “CMake project” and after configuring it with cmake -S . -B build -G "Visual Studio…

---

## [Preventing installing \`FILE\_SET\` headers from a dependent static library target](https://discourse.cmake.org/t/preventing-installing-file-set-headers-from-a-dependent-static-library-target/13400)

<div class="topic-metadata">

**Author:** [@tonh](https://discourse.cmake.org/u/tonh)\
**Replies:** 1\
**Last updated:** [January 15, 2025, 11:01am UTC](https://discourse.cmake.org/t/preventing-installing-file-set-headers-from-a-dependent-static-library-target/13400 "2025-01-15T11:01:51Z")

</div>

I have some top-level static library foo which in turn depends on another static library foo-dep which is included in the build using FetchContent. foo-dep needs to be installed as part of the installation of foo, excep…

---

## [Any way to choose path of CMakePresets.json?](https://discourse.cmake.org/t/any-way-to-choose-path-of-cmakepresets-json/9579)

<div class="topic-metadata">

**Author:** [@hehaoqian1](https://discourse.cmake.org/u/hehaoqian1)\
**Replies:** 3\
**Last updated:** [January 15, 2025, 10:01am UTC](https://discourse.cmake.org/t/any-way-to-choose-path-of-cmakepresets-json/9579 "2025-01-15T10:01:16Z")

</div>

New to cmake preset according to cmake doc –preset \<preset\>, --preset=\<preset\> Reads a preset from \<path-to-source\>/CMakePresets.json and \<path-to-source\>/CMakeUserPresets.json. The preset may specify the generator …

---

## [unexpected "REQUIRED" argument forwarded by \`find\_dependency\`](https://discourse.cmake.org/t/unexpected-required-argument-forwarded-by-find-dependency/13395)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [January 14, 2025, 1:59pm UTC](https://discourse.cmake.org/t/unexpected-required-argument-forwarded-by-find-dependency/13395 "2025-01-14T13:59:34Z")

</div>

This question is related to this one. I decided to track what happened exactly when resolving a dependency chain. I set 3 projects A, B and C. B depends privately on C and does find\_package(C \<REQUIRED\>). A depends p…

---

## [CMake doesn't register new files when I add new files](https://discourse.cmake.org/t/cmake-doesnt-register-new-files-when-i-add-new-files/13390)

<div class="topic-metadata">

**Author:** [@Aseed](https://discourse.cmake.org/u/Aseed)\
**Replies:** 4\
**Last updated:** [January 14, 2025, 9:39am UTC](https://discourse.cmake.org/t/cmake-doesnt-register-new-files-when-i-add-new-files/13390 "2025-01-14T09:39:43Z")

</div>

Hello! I’m using CMake with C++, whenever I add a new file into the project, CMake doesn’t update , and there’s errors in the other files, saying that the stuff I declared/defined in the new file doesn’t exist, and I hav…

---

## [Can Ninja replace Unix makefiles ?](https://discourse.cmake.org/t/can-ninja-replace-unix-makefiles/13388)

<div class="topic-metadata">

**Author:** [@Laur59](https://discourse.cmake.org/u/Laur59)\
**Replies:** 10\
**Last updated:** [January 14, 2025, 3:44am UTC](https://discourse.cmake.org/t/can-ninja-replace-unix-makefiles/13388 "2025-01-14T03:44:04Z")

</div>

Hello I use so far Unix makefiles as generator in projects. The typical building process is to go project directory and rm -r build cmake -S . -B build cmake --build build I wished to experiment with ninja thus I trie…

---

## [Why are thirdparty c++ header files being installed with my executable](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354)

<div class="topic-metadata">

**Author:** [@usermarqueemark](https://discourse.cmake.org/u/usermarqueemark)\
**Replies:** 4\
**Last updated:** [January 13, 2025, 9:25pm UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354 "2025-01-13T21:25:02Z")

</div>

I am using CMake FetchContent\_MakeAvailable to build a number of thirdparty depenencies from github, e.g. in the file PDFHummus.cmake if(NOT PDFHummus\_POPULATED) Include(FetchContent) FetchContent\_Declare( P…

---

## [\[Solved\] cmake-3.31/Modules/CMakeDetermineCompilerId.cmake:1104 (file): file failed to open for reading (Permission denied)](https://discourse.cmake.org/t/solved-cmake-3-31-modules-cmakedeterminecompilerid-cmake-1104-file-file-failed-to-open-for-reading-permission-denied/13377)

<div class="topic-metadata">

**Author:** [@8Observer8](https://discourse.cmake.org/u/8Observer8)\
**Replies:** 1\
**Last updated:** [January 13, 2025, 12:53am UTC](https://discourse.cmake.org/t/solved-cmake-3-31-modules-cmakedeterminecompilerid-cmake-1104-file-file-failed-to-open-for-reading-permission-denied/13377 "2025-01-13T00:53:40Z")

</div>

I have download cmake-3.31.4-windows-x86\_64 here: Release v3.31.4 · Kitware/CMake · GitHub I unzipped it and I added the bin path to the PATH: E:\\Program Files\\cmake-3.31.4-windows-x86\_64\\bin I try to config my project …

---

## [How to prevent CMake from adding host system flags (-arch arm64) when cross-compiling with ExternalProject\_Add?](https://discourse.cmake.org/t/how-to-prevent-cmake-from-adding-host-system-flags-arch-arm64-when-cross-compiling-with-externalproject-add/13374)

<div class="topic-metadata">

**Author:** [@diegoll](https://discourse.cmake.org/u/diegoll)\
**Replies:** 1\
**Last updated:** [January 12, 2025, 10:55pm UTC](https://discourse.cmake.org/t/how-to-prevent-cmake-from-adding-host-system-flags-arch-arm64-when-cross-compiling-with-externalproject-add/13374 "2025-01-12T22:55:34Z")

</div>

I’m working on cross-compiling a library for RISC-V using CMake’s ExternalProject\_Add. When CMake tries to test the compiler, it’s adding macOS-specific flags (-arch arm64 -isysroot) even though I’m using a RISC-V toolch…

[Previous page](https://discourse.cmake.org/c/usage/12.md?page=14)

[Next page](https://discourse.cmake.org/c/usage/12.md?page=16)
