# Usage

**URL:** https://discourse.cmake.org/c/usage/12.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

---

## [Help bundling external dependencies into the final executable](https://discourse.cmake.org/t/help-bundling-external-dependencies-into-the-final-executable/5899)

<div class="topic-metadata">

**Author:** [@TennisBowling](https://discourse.cmake.org/u/TennisBowling)\
**Replies:** 3\
**Last updated:** [June 20, 2022, 6:09pm UTC](https://discourse.cmake.org/t/help-bundling-external-dependencies-into-the-final-executable/5899 "2022-06-20T18:09:28Z")

</div>

I’m currently trying to bundle all external dependencies with my final executable, that way I can move it around without needing to move .so's or .dll's around too. my CMakeListst.txt is: cmake\_minimum\_required(VERSION…

---

## [Testing abnormal exit of programs](https://discourse.cmake.org/t/testing-abnormal-exit-of-programs/5903)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 1\
**Last updated:** [June 20, 2022, 6:08pm UTC](https://discourse.cmake.org/t/testing-abnormal-exit-of-programs/5903 "2022-06-20T18:08:37Z")

</div>

I want to test with ctest, that an executable fails (e.g. with abort()). How can i specify this in ctest? How can I set ctestto exlicitly exprect an abort (or SEGV or …)? :~/cmake\_test/Build$ ninja && ctest \[4/4\] Link…

---

## [Building all the tests](https://discourse.cmake.org/t/building-all-the-tests/5889)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 3\
**Last updated:** [June 20, 2022, 11:11am UTC](https://discourse.cmake.org/t/building-all-the-tests/5889 "2022-06-20T11:11:37Z")

</div>

In CMake, for some reason, the test rule only runs the tests, it does not build them. If I want to actually compile the tests first, my options seem to be: Do make all && make test all the time (which requires building…

---

## [How to set project root when "No project() command is present"?](https://discourse.cmake.org/t/how-to-set-project-root-when-no-project-command-is-present/5895)

<div class="topic-metadata">

**Author:** [@abitrolly](https://discourse.cmake.org/u/abitrolly)\
**Replies:** 7\
**Last updated:** [June 19, 2022, 9:58pm UTC](https://discourse.cmake.org/t/how-to-set-project-root-when-no-project-command-is-present/5895 "2022-06-19T21:58:06Z")

</div>

I am a just few days into CMake, and I need to understand if it is possible to reference project root from CMakeLists.txt in subdirectories to get project variables right? This is a typical C project with Python binding…

---

## [install CODE Parse error](https://discourse.cmake.org/t/install-code-parse-error/5875)

<div class="topic-metadata">

**Author:** [@mumin16](https://discourse.cmake.org/u/mumin16)\
**Replies:** 1\
**Last updated:** [June 16, 2022, 5:17am UTC](https://discourse.cmake.org/t/install-code-parse-error/5875 "2022-06-16T05:17:15Z")

</div>

install(CODE install\_name\_tool -change “./libMylib.dylib” “@executable\_path/libMylib.dylib” ./Myapp) i have parse error: Parse error. Expected “(”, got newline with text " ".

---

## [DragNDrop do damage executable in myapp.app](https://discourse.cmake.org/t/dragndrop-do-damage-executable-in-myapp-app/5872)

<div class="topic-metadata">

**Author:** [@mumin16](https://discourse.cmake.org/u/mumin16)\
**Replies:** 1\
**Last updated:** [June 15, 2022, 4:11pm UTC](https://discourse.cmake.org/t/dragndrop-do-damage-executable-in-myapp-app/5872 "2022-06-15T16:11:53Z")

</div>

for multiplatform setup creator, i have the following CMakeLists.txt in subdirectory. it ok for windows and linux but DragNDrop do damage executable in myapp.app. and Myapp not run. #cmake . -GNinja #cmake --build . --…

---

## [How do I build cmake from source as universal(arm64 and x86\_64) binary on Mac?](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862)

<div class="topic-metadata">

**Author:** [@Diuming](https://discourse.cmake.org/u/Diuming)\
**Replies:** 6\
**Last updated:** [June 15, 2022, 3:41pm UTC](https://discourse.cmake.org/t/how-do-i-build-cmake-from-source-as-universal-arm64-and-x86-64-binary-on-mac/5862 "2022-06-15T15:41:26Z")

</div>

as title: I try with CFLAGS and CXXFLAGS, but not successful. ./configure CFLAGS="-mmacosx-version-min=11.0 -arch x86\_64 -arch arm64" CXXFLAGS="-mmacosx-version-min=11.0 -arch x86\_64 -arch arm64" --prefix=/some/place/…

---

## [How to force trigger postbuild event](https://discourse.cmake.org/t/how-to-force-trigger-postbuild-event/5851)

<div class="topic-metadata">

**Author:** [@oscarh2](https://discourse.cmake.org/u/oscarh2)\
**Replies:** 1\
**Last updated:** [June 13, 2022, 4:57pm UTC](https://discourse.cmake.org/t/how-to-force-trigger-postbuild-event/5851 "2022-06-13T16:57:27Z")

</div>

I have a postbuild type add\_custom\_command for copying some files on every successful build. Sometimes, only the files to be copied are updated, so the target won’t be rebuilt, thus the postbuild event won’t happen. So t…

---

## [ExternalProject\_Add install permission denied](https://discourse.cmake.org/t/externalproject-add-install-permission-denied/5846)

<div class="topic-metadata">

**Author:** [@StefanSchmelz](https://discourse.cmake.org/u/StefanSchmelz)\
**Replies:** 5\
**Last updated:** [June 13, 2022, 2:15am UTC](https://discourse.cmake.org/t/externalproject-add-install-permission-denied/5846 "2022-06-13T02:15:51Z")

</div>

Hi, I wanted to use a library that does not have a system Package, or a package from any package manager like conan or vcpkg. I tried using ExternalProjecct\_Add and when I managed not not misstype half the parameters it …

---

## [How to transfer existing cmdline params to ExternalProject\_Add?](https://discourse.cmake.org/t/how-to-transfer-existing-cmdline-params-to-externalproject-add/5811)

<div class="topic-metadata">

**Author:** [@klirichek](https://discourse.cmake.org/u/klirichek)\
**Replies:** 4\
**Last updated:** [June 12, 2022, 5:36am UTC](https://discourse.cmake.org/t/how-to-transfer-existing-cmdline-params-to-externalproject-add/5811 "2022-06-12T05:36:30Z")

</div>

We using some 3-rd party components in the project, which are built from sources and then cached in order to avoid unnecessary rebuilding. That is done by simple logic, as find\_package (foo QUIET) if (NOT foo\_FOUND) ..…

---

## [CMakePresets and relative path in add\_subdirectory](https://discourse.cmake.org/t/cmakepresets-and-relative-path-in-add-subdirectory/5839)

<div class="topic-metadata">

**Author:** [@jaquilio](https://discourse.cmake.org/u/jaquilio)\
**Replies:** 7\
**Last updated:** [June 10, 2022, 6:03pm UTC](https://discourse.cmake.org/t/cmakepresets-and-relative-path-in-add-subdirectory/5839 "2022-06-10T18:03:57Z")

</div>

Our CMakeLists.txt needs to add a subdirectory using relative path such as: add\_subdirectory(${CMAKE\_SOURCE\_DIR}/../../Foundation/BlahLib ...) CMake requires that the binary directory be specified as the second argume…

---

## [Advice for maintaining module-mode FindPackage.cmake files](https://discourse.cmake.org/t/advice-for-maintaining-module-mode-findpackage-cmake-files/5818)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 5\
**Last updated:** [June 10, 2022, 11:14am UTC](https://discourse.cmake.org/t/advice-for-maintaining-module-mode-findpackage-cmake-files/5818 "2022-06-10T11:14:22Z")

</div>

CMake Gurus, I have a question about maintaining module-mode FindPackage.cmake files. To wit, the documentation for find\_package says: The Find\<PackageName\>.cmake file is not typically provided by the package itself. …

---

## [Yet another command line 'spaces in arguments' problem...is this really 2022?](https://discourse.cmake.org/t/yet-another-command-line-spaces-in-arguments-problem-is-this-really-2022/5829)

<div class="topic-metadata">

**Author:** [@marksibly](https://discourse.cmake.org/u/marksibly)\
**Replies:** 5\
**Last updated:** [June 10, 2022, 1:07am UTC](https://discourse.cmake.org/t/yet-another-command-line-spaces-in-arguments-problem-is-this-really-2022/5829 "2022-06-10T01:07:41Z")

</div>

Hi, This has been driving me nuts all morning! Why does this work OK? export CHECKOUT\_DIR=openxr-checkout export BUILD\_DIR=openxr-build cmake -S "$CHECKOUT\_DIR" -B "$BUILD\_DIR" -DDYNAMIC\_LOADER=OFF -G "Visual Studio 1…

---

## [AdditionalIncludeDirectories are missed in vcxproj](https://discourse.cmake.org/t/additionalincludedirectories-are-missed-in-vcxproj/5826)

<div class="topic-metadata">

**Author:** [@matwey](https://discourse.cmake.org/u/matwey)\
**Replies:** 5\
**Last updated:** [June 9, 2022, 7:15pm UTC](https://discourse.cmake.org/t/additionalincludedirectories-are-missed-in-vcxproj/5826 "2022-06-09T19:15:12Z")

</div>

Hello, I am using GitHub Actions for my open-source project: GitHub - matwey/libopenvizsla at github-actions While trying to fix the build for Windows, I’ve faced an issue which I could not reproduce in my environment. …

---

## [Error in generated cmake\_install.cmake?](https://discourse.cmake.org/t/error-in-generated-cmake-install-cmake/5827)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 11\
**Last updated:** [June 9, 2022, 1:07pm UTC](https://discourse.cmake.org/t/error-in-generated-cmake-install-cmake/5827 "2022-06-09T13:07:31Z")

</div>

using cmake version 3.23.2 on OSX I get the following error when I try to install boost from source: bash-3.2$ ninja install \[0/2\] Re-checking globbed directories... \[0/1\] Install the project... -- Install configuration…

---

## [Cross compilation with linaro toolchain on windows](https://discourse.cmake.org/t/cross-compilation-with-linaro-toolchain-on-windows/5813)

<div class="topic-metadata">

**Author:** [@mickae1](https://discourse.cmake.org/u/mickae1)\
**Replies:** 3\
**Last updated:** [June 8, 2022, 3:01pm UTC](https://discourse.cmake.org/t/cross-compilation-with-linaro-toolchain-on-windows/5813 "2022-06-08T15:01:29Z")

</div>

Hi, I’m trying to cross compile a project on windows using visual studio: cmake -G “Visual Studio 17 2022” -A ARM -DCMAKE\_TOOLCHAIN\_FILE=C:/CMAKE\_sample/toolchain/toolchain\_windows.cmake … this is my toolchain file: I…

---

## [How to use find\_package(X CONFIG) results?](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 3\
**Last updated:** [June 8, 2022, 1:52pm UTC](https://discourse.cmake.org/t/how-to-use-find-package-x-config-results/5819 "2022-06-08T13:52:11Z")

</div>

How to know how a particular package X responds to find\_package(X CONFIG)? If the package is found then I assume variable X\_FOUND is always set. But there doesn’t seem be a “standard” way of setting other result variabl…

---

## [CMake command mode help (cmake -E env) (Edit: fixed error on concatenation)](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798)

<div class="topic-metadata">

**Author:** [@lucas-inacio](https://discourse.cmake.org/u/lucas-inacio)\
**Replies:** 3\
**Last updated:** [June 8, 2022, 1:24am UTC](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798 "2022-06-08T01:24:04Z")

</div>

Hello, everyone! I’m trying to set up an external project. In the CONFIGURE\_COMMAND phase I’m trying to use a modified environment as folows: find\_program(nasm NAMES nasm REQUIRED) find\_program(perl NAMES perl REQUIRED…

---

## [Could NOT find PythonInterp (missing: PYTHON\_EXECUTABLE)](https://discourse.cmake.org/t/could-not-find-pythoninterp-missing-python-executable/5791)

<div class="topic-metadata">

**Author:** [@Zameen](https://discourse.cmake.org/u/Zameen)\
**Replies:** 3\
**Last updated:** [June 7, 2022, 11:25am UTC](https://discourse.cmake.org/t/could-not-find-pythoninterp-missing-python-executable/5791 "2022-06-07T11:25:58Z")

</div>

I am trying this project in CMake (v3.23.2) Git Project On Configuring following Error display CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could …

---

## [RFE: does cmake have a "simulate" option? ...](https://discourse.cmake.org/t/rfe-does-cmake-have-a-simulate-option/5796)

<div class="topic-metadata">

**Author:** [@lbrtchx](https://discourse.cmake.org/u/lbrtchx)\
**Replies:** 15\
**Last updated:** [June 7, 2022, 11:24am UTC](https://discourse.cmake.org/t/rfe-does-cmake-have-a-simulate-option/5796 "2022-06-07T11:24:28Z")

</div>

would it even make sense for it to have one? I am working on compiling webkit2gtk’s source using cmake. I have constantly run into dependency problems with the libraries it uses. It would save people a grate deal of tim…

---

## [CMake and WSL not playing well together? source directory "/" does not appear to contain CMakeLists.txt ...](https://discourse.cmake.org/t/cmake-and-wsl-not-playing-well-together-source-directory-does-not-appear-to-contain-cmakelists-txt/5788)

<div class="topic-metadata">

**Author:** [@lbrtchx](https://discourse.cmake.org/u/lbrtchx)\
**Replies:** 3\
**Last updated:** [June 6, 2022, 1:54pm UTC](https://discourse.cmake.org/t/cmake-and-wsl-not-playing-well-together-source-directory-does-not-appear-to-contain-cmakelists-txt/5788 "2022-06-06T13:54:39Z")

</div>

based on the similarity with my subject string five other posts were suggested to me, which I read but only one of them was relevant to my case. Basically, I am trying to compile WebKit2 on WSL. I was expecting to run i…

---

## [Cmake hung at pkg-config in SLES12](https://discourse.cmake.org/t/cmake-hung-at-pkg-config-in-sles12/5729)

<div class="topic-metadata">

**Author:** [@SudeshnaMoulik](https://discourse.cmake.org/u/SudeshnaMoulik)\
**Replies:** 9\
**Last updated:** [June 6, 2022, 1:51pm UTC](https://discourse.cmake.org/t/cmake-hung-at-pkg-config-in-sles12/5729 "2022-06-06T13:51:02Z")

</div>

Hi Team, Cmake is hung while finding any package that depends on pkg-config package: cmake version: cmake version 3.15.7 in CMakeLists.txt: find\_package(EXPAT REQUIRED) find\_package(X11 REQUIRED) logs: pbi-32-s12:…

---

## [How do I crosscompile on an M1 Mac for 64 bit Raspberry Pis?](https://discourse.cmake.org/t/how-do-i-crosscompile-on-an-m1-mac-for-64-bit-raspberry-pis/5800)

<div class="topic-metadata">

**Author:** [@ro-kue](https://discourse.cmake.org/u/ro-kue)\
**Replies:** 1\
**Last updated:** [June 5, 2022, 11:56pm UTC](https://discourse.cmake.org/t/how-do-i-crosscompile-on-an-m1-mac-for-64-bit-raspberry-pis/5800 "2022-06-05T23:56:43Z")

</div>

Hi! GCC (and I assume Clang) on macOS have the -arch option as opposed to the -march option. The difference is that on macOS you might want to compile a universal binary and -arch takes more than one architecture so you…

---

## [Extra Fortran\_FLAGS in \`flags.make\` with arm64: Should I have them?](https://discourse.cmake.org/t/extra-fortran-flags-in-flags-make-with-arm64-should-i-have-them/5772)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 2\
**Last updated:** [June 1, 2022, 10:17pm UTC](https://discourse.cmake.org/t/extra-fortran-flags-in-flags-make-with-arm64-should-i-have-them/5772 "2022-06-01T22:17:01Z")

</div>

I’ve recently been experimenting with getting a climate model I work on working on M1 Mac. Thanks to the GCC folks, I got it to run! However, one thing I noticed as I was experimenting is that when I build on my M1 Mac, …

---

## [Why is my library consumer getting a PRIVATE library dependency](https://discourse.cmake.org/t/why-is-my-library-consumer-getting-a-private-library-dependency/5776)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 2\
**Last updated:** [June 1, 2022, 7:54pm UTC](https://discourse.cmake.org/t/why-is-my-library-consumer-getting-a-private-library-dependency/5776 "2022-06-01T19:54:33Z")

</div>

I have three build elements: bar (library) provides bar() foo (library) provides foo() and uses bar() main (exec) uses foo() I purposely have bar as a PRIVATE library of foo, and expect for main to fail because it doe…

---

## [Does the IMPORTED\_LOCATION property support generator expressions?](https://discourse.cmake.org/t/does-the-imported-location-property-support-generator-expressions/5730)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 3\
**Last updated:** [June 1, 2022, 6:59pm UTC](https://discourse.cmake.org/t/does-the-imported-location-property-support-generator-expressions/5730 "2022-06-01T18:59:48Z")

</div>

Does the IMPORTED\_LOCATION target property support generator expressions? I tried this with and it appears to work on Windows but not on Linux. I don’t see an explicit “this supports generator expressions” notice, but I…

---

## [TI\_Arm\_Clang\_Compiler\_1.3.0 not passing initial compiler test](https://discourse.cmake.org/t/ti-arm-clang-compiler-1-3-0-not-passing-initial-compiler-test/5759)

<div class="topic-metadata">

**Author:** [@Raisha](https://discourse.cmake.org/u/Raisha)\
**Replies:** 5\
**Last updated:** [June 1, 2022, 1:02pm UTC](https://discourse.cmake.org/t/ti-arm-clang-compiler-1-3-0-not-passing-initial-compiler-test/5759 "2022-06-01T13:02:56Z")

</div>

Hello, I am trying to build using TI\_Arm\_Clang\_Compiler\_1.3.0 using cmake. The compiler test is failing at linking and the compiler is identified as Clang instead of TI. – The C compiler identification is Clang 12.0.1 …

---

## [CMAKE\_\<LANG\>\_COMPILER\_EXTERNAL\_TOOLCHAIN adds -gcc-toolchain not ---gcc-toolchain](https://discourse.cmake.org/t/cmake-lang-compiler-external-toolchain-adds-gcc-toolchain-not-gcc-toolchain/5748)

<div class="topic-metadata">

**Author:** [@samolisov](https://discourse.cmake.org/u/samolisov)\
**Replies:** 4\
**Last updated:** [June 1, 2022, 10:01am UTC](https://discourse.cmake.org/t/cmake-lang-compiler-external-toolchain-adds-gcc-toolchain-not-gcc-toolchain/5748 "2022-06-01T10:01:10Z")

</div>

Hello, I’m trying to cross-compile a project using clang as a compiler and pass the --gcc-toolchain command line argument to the compiler. As I get, the preferable way for this is to use the CMAKE\_\<LANG\>\_COMPILER\_EXTERN…

---

## [Is it possible to retrieve the full path of the cpack package (including the file extension)?](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-full-path-of-the-cpack-package-including-the-file-extension/5765)

<div class="topic-metadata">

**Author:** [@raygerlabs](https://discourse.cmake.org/u/raygerlabs)\
**Replies:** 0\
**Last updated:** [May 31, 2022, 2:05pm UTC](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-full-path-of-the-cpack-package-including-the-file-extension/5765 "2022-05-31T14:05:52Z")

</div>

Here is an example code. The package\_info.txt file will contain the package name but without the extension and path. # Set packaging path if (NOT CPACK\_OUTPUT\_FILE\_PREFIX) set(CPACK\_OUTPUT\_FILE\_PREFIX "${PROJECT\_BINAR…

---

## [Is it possible to retrieve the list of public headers when using target\_sources(... FILE\_SET HEADERS ...)?](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757)

<div class="topic-metadata">

**Author:** [@raygerlabs](https://discourse.cmake.org/u/raygerlabs)\
**Replies:** 2\
**Last updated:** [May 31, 2022, 11:45am UTC](https://discourse.cmake.org/t/is-it-possible-to-retrieve-the-list-of-public-headers-when-using-target-sources-file-set-headers/5757 "2022-05-31T11:45:32Z")

</div>

Dear all, I find the new features in Cmake 3.23 very handy and useful so far! I have just one minor issue right now. If I specify my source and header files with target\_sources(…) I can retrieve the .cpp files simply by…

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

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