# Usage

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

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

**Page:** 47

---

## [Correct import/export of symbols from library](https://discourse.cmake.org/t/correct-import-export-of-symbols-from-library/7858)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [April 10, 2023, 1:10pm UTC](https://discourse.cmake.org/t/correct-import-export-of-symbols-from-library/7858 "2023-04-10T13:10:54Z")

</div>

Hi, This question is related to building a shared library NMAKE : fatal error U1077 I think. In order to properly declare my libraries symbol, I’m currently obliged to do something like that: #ifdef UNIQUELIBRARYIDENT…

---

## [Execute custom code (sed) when RPM SPEC is generated](https://discourse.cmake.org/t/execute-custom-code-sed-when-rpm-spec-is-generated/7823)

<div class="topic-metadata">

**Author:** [@wdezell](https://discourse.cmake.org/u/wdezell)\
**Replies:** 4\
**Last updated:** [April 7, 2023, 4:01pm UTC](https://discourse.cmake.org/t/execute-custom-code-sed-when-rpm-spec-is-generated/7823 "2023-04-07T16:01:15Z")

</div>

I have a need to modify the auto-generated SPEC file prior to the invocation of rpmbuild but install(CODE…) in the main CMakeLists.txt doesn’t trigger at the right time (the dynamic nature of our CI build doesn’t lend it…

---

## [Could NOT find Python3 (missing: Python3\_LIBRARIES Development Development.Embed) (found suitable version "3.11.2", minimum required is "3.5")](https://discourse.cmake.org/t/could-not-find-python3-missing-python3-libraries-development-development-embed-found-suitable-version-3-11-2-minimum-required-is-3-5/7837)

<div class="topic-metadata">

**Author:** [@trayres](https://discourse.cmake.org/u/trayres)\
**Replies:** 3\
**Last updated:** [April 6, 2023, 5:21pm UTC](https://discourse.cmake.org/t/could-not-find-python3-missing-python3-libraries-development-development-embed-found-suitable-version-3-11-2-minimum-required-is-3-5/7837 "2023-04-06T17:21:25Z")

</div>

Hello everyone! I cannot get CMake to find my Python libraries; I’m getting this error. I’m on MSYS2 on Windows 10 (which I think might be part of the problem).

---

## [make gives an error: first defined here](https://discourse.cmake.org/t/make-gives-an-error-first-defined-here/5267)

<div class="topic-metadata">

**Author:** [@cgx66xf](https://discourse.cmake.org/u/cgx66xf)\
**Replies:** 5\
**Last updated:** [April 4, 2023, 8:38pm UTC](https://discourse.cmake.org/t/make-gives-an-error-first-defined-here/5267 "2023-04-04T20:38:58Z")

</div>

The error \[ 33%\] Building CXX object CMakeFiles/socket.dir/server.cpp.o \[ 66%\] Building CXX object CMakeFiles/socket.dir/client.cpp.o \[100%\] Linking CXX executable socket /usr/bin/ld: CMakeFiles/socket.dir/client.cpp.o:…

---

## [How do I replace the compiler options for one target?](https://discourse.cmake.org/t/how-do-i-replace-the-compiler-options-for-one-target/7815)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 4\
**Last updated:** [April 4, 2023, 9:46am UTC](https://discourse.cmake.org/t/how-do-i-replace-the-compiler-options-for-one-target/7815 "2023-04-04T09:46:20Z")

</div>

I have a multi-directory project with a lot of CMakeLists.txt files. At the root file I have this: set(CMAKE\_CXX\_FLAGS "-Wall -Wimplicit-fallthrough -Werror=return-type") I’d like to completely replace that in a subdir…

---

## [qt\_add\_resources error](https://discourse.cmake.org/t/qt-add-resources-error/7782)

<div class="topic-metadata">

**Author:** [@abdelmaged](https://discourse.cmake.org/u/abdelmaged)\
**Replies:** 2\
**Last updated:** [April 3, 2023, 11:58pm UTC](https://discourse.cmake.org/t/qt-add-resources-error/7782 "2023-04-03T23:58:28Z")

</div>

I’m trying to use CMake macro qt\_add\_resources, and add qrc file that has comments, and it seems this generates rules including the comments as dependencies. Example: resources.qrc \<!-- WARNING WARNING WARNING WARNING…

---

## [missing vulkan even though i have vulkan and set the vulkan\_sdk env var to the proper directory](https://discourse.cmake.org/t/missing-vulkan-even-though-i-have-vulkan-and-set-the-vulkan-sdk-env-var-to-the-proper-directory/7803)

<div class="topic-metadata">

**Author:** [@samuelcarr](https://discourse.cmake.org/u/samuelcarr)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 11:41am UTC](https://discourse.cmake.org/t/missing-vulkan-even-though-i-have-vulkan-and-set-the-vulkan-sdk-env-var-to-the-proper-directory/7803 "2023-04-03T11:41:42Z")

</div>

CMake Error at E:/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find Vulkan (missing: Vulkan\_LIBRARY Vulkan\_INCLUDE\_DIR) (found version "") Call Stack (most recent call f…

---

## [cmake error at cmake file](https://discourse.cmake.org/t/cmake-error-at-cmake-file/7790)

<div class="topic-metadata">

**Author:** [@samuelcarr](https://discourse.cmake.org/u/samuelcarr)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 11:37am UTC](https://discourse.cmake.org/t/cmake-error-at-cmake-file/7790 "2023-04-03T11:37:26Z")

</div>

error is Could not find url for MSVC version = 1934 and Python version = 3.6. this is the code in question https://pastebin.com/wHzpjtGE

---

## [Several questions regarding environment variables (PATH) and Windows/MSVC](https://discourse.cmake.org/t/several-questions-regarding-environment-variables-path-and-windows-msvc/7780)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 11:28am UTC](https://discourse.cmake.org/t/several-questions-regarding-environment-variables-path-and-windows-msvc/7780 "2023-04-03T11:28:38Z")

</div>

Hi, since Windows doesn’t have RPATH, I’m having a bit of trouble getting PATH set up properly in a Visual Studio build. I managed to set up the PATH properly in the VS\_DEBUGGER\_ENVIRONMENT target property. First ques…

---

## [Building for macOS-arm64 but attempting to link with file built for macOS-x86\_64](https://discourse.cmake.org/t/building-for-macos-arm64-but-attempting-to-link-with-file-built-for-macos-x86-64/7779)

<div class="topic-metadata">

**Author:** [@Keon6](https://discourse.cmake.org/u/Keon6)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 11:26am UTC](https://discourse.cmake.org/t/building-for-macos-arm64-but-attempting-to-link-with-file-built-for-macos-x86-64/7779 "2023-04-03T11:26:03Z")

</div>

Trying to build the following but I keep running into issues (maxe/QuickStart.adoc at master · maxe-team/maxe · GitHub). Basically, the code was written before M1 chips came out and I’m not sure what the optimal way to…

---

## [CLion error vs. building in terminal - intel MKL library](https://discourse.cmake.org/t/clion-error-vs-building-in-terminal-intel-mkl-library/7775)

<div class="topic-metadata">

**Author:** [@jlenz](https://discourse.cmake.org/u/jlenz)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 11:24am UTC](https://discourse.cmake.org/t/clion-error-vs-building-in-terminal-intel-mkl-library/7775 "2023-04-03T11:24:47Z")

</div>

Hello, I am working on an audio application dynamically links to subdirectory with libtorch dlls. I use the following commands to build on terminal: cmake .. -DCMAKE\_BUILD\_TYPE=Debug cmake --build . --config Debug Whe…

---

## [COMMAND\_ERROR\_IS\_FATAL output isn't particularly helpful](https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 2\
**Last updated:** [April 3, 2023, 11:22am UTC](https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751 "2023-04-03T11:22:07Z")

</div>

Consider this script: execute\_process( COMMAND bash -c "exit 127" COMMAND\_ERROR\_IS\_FATAL ANY ) message(STATUS "Got here") This fails with: $ cmake -P err.cmake CMake Error at err.cmake:1 (execute\_process):…

---

## [Which env was changed with cmake --config command](https://discourse.cmake.org/t/which-env-was-changed-with-cmake-config-command/7689)

<div class="topic-metadata">

**Author:** [@alfred-yu](https://discourse.cmake.org/u/alfred-yu)\
**Replies:** 1\
**Last updated:** [April 3, 2023, 11:12am UTC](https://discourse.cmake.org/t/which-env-was-changed-with-cmake-config-command/7689 "2023-04-03T11:12:44Z")

</div>

I used some opensource libraries in my own project with cmake, the build type is release by default with cmake --build . command, but the build type of opensource libraries becomes debug, it will be ok if I use cmake --b…

---

## [separate\_arguments not works](https://discourse.cmake.org/t/separate-arguments-not-works/7808)

<div class="topic-metadata">

**Author:** [@AndrzejB](https://discourse.cmake.org/u/AndrzejB)\
**Replies:** 1\
**Last updated:** [April 1, 2023, 10:26pm UTC](https://discourse.cmake.org/t/separate-arguments-not-works/7808 "2023-04-01T22:26:54Z")

</div>

separate\_arguments would be the only one hack to get list as result of function instead get only string This minimal CMakeLists.txt cmake\_minimum\_required(VERSION 3.24) project(zgloszenie\_cmake) set(CMAKE\_CXX\_STANDARD …

---

## [Unknown CMake command "python3\_add\_library".](https://discourse.cmake.org/t/unknown-cmake-command-python3-add-library/7799)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 1\
**Last updated:** [March 30, 2023, 5:09pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-python3-add-library/7799 "2023-03-30T17:09:52Z")

</div>

Hi, In my CMakeLists for a Python wrapper, I’ve got: find\_package(Python3 REQUIRED) add\_subdirectory(\<path to pybind 11 CMakeLists\>) When calling cmake I’ve got (on CMake 3.19+, same behaviour on Linux or windows) CM…

---

## [Unable to change 'Source Code Directory' for wxWidgets-3.1.15 installation](https://discourse.cmake.org/t/unable-to-change-source-code-directory-for-wxwidgets-3-1-15-installation/3791)

<div class="topic-metadata">

**Author:** [@Jim\_Kucera](https://discourse.cmake.org/u/Jim_Kucera)\
**Replies:** 3\
**Last updated:** [March 30, 2023, 9:57am UTC](https://discourse.cmake.org/t/unable-to-change-source-code-directory-for-wxwidgets-3-1-15-installation/3791 "2023-03-30T09:57:22Z")

</div>

Hello, My 1st attempt at a wxWidgets-3.1.15 installation failed using source directory ‘demo’. On 2nd attempt I extracted wxWidget-3.1.5 to directory ‘wxWidgets-3.1.15’. When I reran CMake, it thinks the source is loca…

---

## [cmake error cmakelists.txt:18 (project)](https://discourse.cmake.org/t/cmake-error-cmakelists-txt-18-project/7789)

<div class="topic-metadata">

**Author:** [@samuelcarr](https://discourse.cmake.org/u/samuelcarr)\
**Replies:** 0\
**Last updated:** [March 29, 2023, 2:17am UTC](https://discourse.cmake.org/t/cmake-error-cmakelists-txt-18-project/7789 "2023-03-29T02:17:44Z")

</div>

CMake Error at CMakeLists.txt:18 (project): Generator Visual Studio 17 2022 could not find any instance of Visual Studio. I already tried the fix for the could not find any instance of visual studio error and it did …

---

## [Write multiline text to file with path given by generator expression](https://discourse.cmake.org/t/write-multiline-text-to-file-with-path-given-by-generator-expression/7781)

<div class="topic-metadata">

**Author:** [@jnc](https://discourse.cmake.org/u/jnc)\
**Replies:** 1\
**Last updated:** [March 28, 2023, 9:22pm UTC](https://discourse.cmake.org/t/write-multiline-text-to-file-with-path-given-by-generator-expression/7781 "2023-03-28T21:22:11Z")

</div>

Hi, I have a project that requires creating a text file in the same folder as the output binary. The location of the binary can be obtained using a generator expression, which is not available when using file(WRITE). Ho…

---

## [How to set CMAKE\_OSX\_DEPLOYMENT\_TARGET, conditionally?](https://discourse.cmake.org/t/how-to-set-cmake-osx-deployment-target-conditionally/7772)

<div class="topic-metadata">

**Author:** [@bavulapati](https://discourse.cmake.org/u/bavulapati)\
**Replies:** 2\
**Last updated:** [March 27, 2023, 8:24am UTC](https://discourse.cmake.org/t/how-to-set-cmake-osx-deployment-target-conditionally/7772 "2023-03-27T08:24:45Z")

</div>

Our project uses a single CMakeLists.txt file for both iOS and MacOS apps. We would like to set CMAKE\_OSX\_DEPLOYMENT\_TARGET from the CMakeLists.txt file depending on the target OS(iOS, MacOS). CMAKE\_OSX\_DEPLOYMENT\_TARGE…

---

## [Could NOT find Python: unsuitable version](https://discourse.cmake.org/t/could-not-find-python-unsuitable-version/7759)

<div class="topic-metadata">

**Author:** [@Teancum\_Quist](https://discourse.cmake.org/u/Teancum_Quist)\
**Replies:** 1\
**Last updated:** [March 24, 2023, 8:01am UTC](https://discourse.cmake.org/t/could-not-find-python-unsuitable-version/7759 "2023-03-24T08:01:34Z")

</div>

I’m trying to build this piece of code using cmake, but I keep getting an error that it can’t find python, or I have the wrong version. I only have one python distribution. 3.10, it is in my path. I highlighted below whe…

---

## [string(JSON ... GET ...) slow](https://discourse.cmake.org/t/string-json-get-slow/7740)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 5\
**Last updated:** [March 23, 2023, 9:28pm UTC](https://discourse.cmake.org/t/string-json-get-slow/7740 "2023-03-23T21:28:23Z")

</div>

Hi, I’ve got a 3 MB JSON file consisting of a list of a few thousand items. I need to parse them one by one and get the “name” member from each item. So I’m doing foreach(idx RANGE ${length}) string(JSON name GET “…

---

## [environment variable from preset during build](https://discourse.cmake.org/t/environment-variable-from-preset-during-build/7755)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 3\
**Last updated:** [March 23, 2023, 2:09pm UTC](https://discourse.cmake.org/t/environment-variable-from-preset-during-build/7755 "2023-03-23T14:09:19Z")

</div>

I have an issue where the environment setting in a config preset is not used when running ninja. $ cmake --preset default && touch CMakeLists.txt && (cd build/default; ninja) Preset environment variables: MY\_ENVIRONM…

---

## [Problem with too long dependency file path (.d)](https://discourse.cmake.org/t/problem-with-too-long-dependency-file-path-d/7744)

<div class="topic-metadata">

**Author:** [@Pahlden](https://discourse.cmake.org/u/Pahlden)\
**Replies:** 2\
**Last updated:** [March 22, 2023, 12:27pm UTC](https://discourse.cmake.org/t/problem-with-too-long-dependency-file-path-d/7744 "2023-03-22T12:27:06Z")

</div>

I’m running in a problem with dependency file path which seem to be too long for CMAKE: example: \[4/1995\] Building CXX object x\_service\_server\_ServiceRplOnline…neChangeReq\_eGetActivePouTypeChangeListReq\_SkelDesFac\_.cpp.…

---

## [find\_library does not find stdc++fs](https://discourse.cmake.org/t/find-library-does-not-find-stdc-fs/4764)

<div class="topic-metadata">

**Author:** [@jcelerier](https://discourse.cmake.org/u/jcelerier)\
**Replies:** 14\
**Last updated:** [March 22, 2023, 12:22pm UTC](https://discourse.cmake.org/t/find-library-does-not-find-stdc-fs/4764 "2023-03-22T12:22:21Z")

</div>

I have the following: $ find /usr -name '\*stdc\*' /usr/lib/gcc/x86\_64-redhat-linux/10/32/libstdc++.a /usr/lib/gcc/x86\_64-redhat-linux/10/32/libstdc++.so /usr/lib/gcc/x86\_64-redhat-linux/10/32/libstdc++fs.a /usr/lib/gcc/x…

---

## [CMAKE\_OBJECT\_PATH\_MAX does it also apply to dependency files ('.d') ?](https://discourse.cmake.org/t/cmake-object-path-max-does-it-also-apply-to-dependency-files-d/5319)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 2\
**Last updated:** [March 22, 2023, 6:35am UTC](https://discourse.cmake.org/t/cmake-object-path-max-does-it-also-apply-to-dependency-files-d/5319 "2023-03-22T06:35:31Z")

</div>

I’m getting an error that I believe is due to a very long pathname: \[1711/2435 12.4/sec\] Building CXX object eSW/Qt/AEPPApps/ManufacturingCalibration/CMakeFiles/ManufacturingCalibration.dir/..\_..\_..\_..\_..\_build-AEPP-Qt5…

---

## [CMake Error In Linux: target "FILE\_SET" does not exist](https://discourse.cmake.org/t/cmake-error-in-linux-target-file-set-does-not-exist/7726)

<div class="topic-metadata">

**Author:** [@Neoptolemus](https://discourse.cmake.org/u/Neoptolemus)\
**Replies:** 2\
**Last updated:** [March 20, 2023, 10:32pm UTC](https://discourse.cmake.org/t/cmake-error-in-linux-target-file-set-does-not-exist/7726 "2023-03-20T22:32:56Z")

</div>

Hi everyone, I’m a beginner to CMake, using 3.22.1, and attempting to build a project targeting both Windows and Linux (x86). I am using an example CMake project to learn how to make this work, specifically this shared …

---

## [Using resharper cli tools with cmake under Linux ?](https://discourse.cmake.org/t/using-resharper-cli-tools-with-cmake-under-linux/7651)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 3\
**Last updated:** [March 20, 2023, 9:31pm UTC](https://discourse.cmake.org/t/using-resharper-cli-tools-with-cmake-under-linux/7651 "2023-03-20T21:31:47Z")

</div>

Hi, I tried to run JetBrain’s ReSharper command line tool InspectCode InspectCode Command-Line Tool | ReSharper Documentation today on Linux, which they say is supported: System Requirements - dotUltimate | ReSharper I…

---

## [Workflow for iOS devices (pushing to device, debugging)](https://discourse.cmake.org/t/workflow-for-ios-devices-pushing-to-device-debugging/7716)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 3\
**Last updated:** [March 20, 2023, 6:59pm UTC](https://discourse.cmake.org/t/workflow-for-ios-devices-pushing-to-device-debugging/7716 "2023-03-20T18:59:29Z")

</div>

Does anyone use CMake to build and run an iOS app, without working (much) in Xcode? I’ve been using CMake + Emacs a lot lately, to build executables for desktop or command line. I’d like to start doing the same for iOS a…

---

## [Keep CPack INSTALL() from generating excess %config directives in RPM Spec file](https://discourse.cmake.org/t/keep-cpack-install-from-generating-excess-config-directives-in-rpm-spec-file/7723)

<div class="topic-metadata">

**Author:** [@wdezell](https://discourse.cmake.org/u/wdezell)\
**Replies:** 0\
**Last updated:** [March 20, 2023, 3:53pm UTC](https://discourse.cmake.org/t/keep-cpack-install-from-generating-excess-config-directives-in-rpm-spec-file/7723 "2023-03-20T15:53:27Z")

</div>

I’ve got a CPack scenario where a combination of INSTALL(DIRECTORY ), INSTALL(PROGRAMS ), and INSTALL(FILES ) are being used to set up creation of a binary RPM. At one point set(CPACK\_RPM\_USER\_FILELIST …) is used to expl…

---

## [FetchContent or ExternalProject or other choices for non-CMake libraries](https://discourse.cmake.org/t/fetchcontent-or-externalproject-or-other-choices-for-non-cmake-libraries/7687)

<div class="topic-metadata">

**Author:** [@magisu](https://discourse.cmake.org/u/magisu)\
**Replies:** 7\
**Last updated:** [March 17, 2023, 11:24pm UTC](https://discourse.cmake.org/t/fetchcontent-or-externalproject-or-other-choices-for-non-cmake-libraries/7687 "2023-03-17T23:24:05Z")

</div>

Since CMake 3.24 it seems possible to implement the following feature within the CMake framework: First, look for a local pre-compiled library in the system or a specific position using CMake find\_package tool. If it i…

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

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