# Code

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

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

**Page:** 49

---

## [MacOS: CMake unable to link C++ library with ObjC++ library](https://discourse.cmake.org/t/macos-cmake-unable-to-link-c-library-with-objc-library/5361)

<div class="topic-metadata">

**Author:** [@devojoyti](https://discourse.cmake.org/u/devojoyti)\
**Replies:** 0\
**Last updated:** [April 3, 2022, 4:12pm UTC](https://discourse.cmake.org/t/macos-cmake-unable-to-link-c-library-with-objc-library/5361 "2022-04-03T16:12:22Z")

</div>

Basically this question here - objective c - MacOS: CMake unable to link C++ library with ObjC++ library - Stack Overflow I have created a minimalistic C++ library that I want to use in my Xcode project. It has this dir…

---

## [Opinions on include directories](https://discourse.cmake.org/t/opinions-on-include-directories/5342)

<div class="topic-metadata">

**Author:** [@NeoCortex97](https://discourse.cmake.org/u/NeoCortex97)\
**Replies:** 2\
**Last updated:** [April 1, 2022, 11:37am UTC](https://discourse.cmake.org/t/opinions-on-include-directories/5342 "2022-04-01T11:37:00Z")

</div>

Hi, The annoying noob is back and is asking stupid questions again :sweat\_smile: I am currently spending some time to figure out a useful directory structure for my use of headers… I still would like the everything to…

---

## [Unable to use absolute file paths in qrc file?](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 5\
**Last updated:** [April 1, 2022, 3:49am UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321 "2022-04-01T03:49:42Z")

</div>

This comment applies to Qt5.6.3. It appears that the quick compiler doesn’t generate proper namespaces when using full paths in a qrc file. I was attempting this because I need to autogenerate a qrc file in the binary …

---

## [cmake + mingw32: invalid option '-?'](https://discourse.cmake.org/t/cmake-mingw32-invalid-option/5344)

<div class="topic-metadata">

**Author:** [@hydroconstructor](https://discourse.cmake.org/u/hydroconstructor)\
**Replies:** 8\
**Last updated:** [March 31, 2022, 2:39pm UTC](https://discourse.cmake.org/t/cmake-mingw32-invalid-option/5344 "2022-03-31T14:39:41Z")

</div>

Can’t compile anything by cmake, including Step 1 tutorial example. There is my CMakeLists.txt: cmake\_minimum\_required(VERSION 3.10) set( CMAKE\_CXX\_COMPILER "c:/Program Files/mingw-w64/x86\_64-8.1.0-win32-seh-rt\_v6-rev0…

---

## [What are imported and alias executables good for](https://discourse.cmake.org/t/what-are-imported-and-alias-executables-good-for/5315)

<div class="topic-metadata">

**Author:** [@NeoCortex97](https://discourse.cmake.org/u/NeoCortex97)\
**Replies:** 3\
**Last updated:** [March 31, 2022, 12:13pm UTC](https://discourse.cmake.org/t/what-are-imported-and-alias-executables-good-for/5315 "2022-03-31T12:13:47Z")

</div>

I have read the docs for executables, but I do not really understand when I should use imported executables or aliases. https://cmake.org/cmake/help/latest/command/add\_executable.html This is the link that I was readin…

---

## [cmake cannot find freetype library](https://discourse.cmake.org/t/cmake-cannot-find-freetype-library/5310)

<div class="topic-metadata">

**Author:** [@agcdam](https://discourse.cmake.org/u/agcdam)\
**Replies:** 2\
**Last updated:** [March 31, 2022, 8:34am UTC](https://discourse.cmake.org/t/cmake-cannot-find-freetype-library/5310 "2022-03-31T08:34:18Z")

</div>

When I try to build the library i get this error. Could NOT find Freetype (missing: FREETYPE\_LIBRARY) (Required is at least version “2.8”)

---

## [Install findPackage script](https://discourse.cmake.org/t/install-findpackage-script/5307)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 2\
**Last updated:** [March 30, 2022, 7:56pm UTC](https://discourse.cmake.org/t/install-findpackage-script/5307 "2022-03-30T19:56:28Z")

</div>

Hi, for a project I have some deependencies like MySQL. I therefore also have a FindMySQL.cmake script. In my Config script, when my project is installed, I have find\_dependency(MySQL), because well mysql is a dependenc…

---

## [What make command is used for try\_compile?](https://discourse.cmake.org/t/what-make-command-is-used-for-try-compile/5331)

<div class="topic-metadata">

**Author:** [@Detlef\_Vollmann](https://discourse.cmake.org/u/Detlef_Vollmann)\
**Replies:** 0\
**Last updated:** [March 30, 2022, 12:51pm UTC](https://discourse.cmake.org/t/what-make-command-is-used-for-try-compile/5331 "2022-03-30T12:51:23Z")

</div>

Hello, I’m trying to create my own toolchain file, but I’m getting a strange error message: “\[…\] Run Build Command(s): -f Makefile cmTC\_7ea91/fast \[…\]” Obviously before “-f” the make command is missing. This only ha…

---

## [How to prevent CMake from creating a symlink for shared libraries ?](https://discourse.cmake.org/t/how-to-prevent-cmake-from-creating-a-symlink-for-shared-libraries/5316)

<div class="topic-metadata">

**Author:** [@pol2095](https://discourse.cmake.org/u/pol2095)\
**Replies:** 4\
**Last updated:** [March 29, 2022, 7:47pm UTC](https://discourse.cmake.org/t/how-to-prevent-cmake-from-creating-a-symlink-for-shared-libraries/5316 "2022-03-29T19:47:13Z")

</div>

Hello, I make Tesseract-ocr, I obtain on Ubuntu a simlink libtesseract.so and a file libtesseract.so.5.1.0, is-it possible to prevent versioning and obtain only a file libtesseract.so ? I tried to add in “CMakeLists.tx…

---

## [Does cmake file name or content support Chinese characters](https://discourse.cmake.org/t/does-cmake-file-name-or-content-support-chinese-characters/5122)

<div class="topic-metadata">

**Author:** [@Xuexq](https://discourse.cmake.org/u/Xuexq)\
**Replies:** 5\
**Last updated:** [March 29, 2022, 3:28pm UTC](https://discourse.cmake.org/t/does-cmake-file-name-or-content-support-chinese-characters/5122 "2022-03-29T15:28:20Z")

</div>

CMake 3.22.0 1.If cmake file name contains Chinese characters, such as “中文工程\_files.cmake”, there is error Error information: CMake Error at cmake/FileUtil.cmake:26 (include): include could not find requested file: ?…

---

## [FeatureSummary module: how to get all dependency libraries of a Target and their versions?](https://discourse.cmake.org/t/featuresummary-module-how-to-get-all-dependency-libraries-of-a-target-and-their-versions/5308)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 3\
**Last updated:** [March 29, 2022, 3:27pm UTC](https://discourse.cmake.org/t/featuresummary-module-how-to-get-all-dependency-libraries-of-a-target-and-their-versions/5308 "2022-03-29T15:27:33Z")

</div>

I want to get the list of all dependency libraries and their versions of a target. This should be possible for imported targets and for build targets. For imported targets ist works, but I am wondering that the version…

---

## [Using an external .dyld with incorrect install\_name](https://discourse.cmake.org/t/using-an-external-dyld-with-incorrect-install-name/5314)

<div class="topic-metadata">

**Author:** [@ndevenish](https://discourse.cmake.org/u/ndevenish)\
**Replies:** 1\
**Last updated:** [March 29, 2022, 1:37pm UTC](https://discourse.cmake.org/t/using-an-external-dyld-with-incorrect-install-name/5314 "2022-03-29T13:37:48Z")

</div>

I’m linking to an external library /abs/path/lib/libexternal.dylib. The dylib has it’s -install\_name/Library ID set to the relative path "lib/libexternal.dylib". When I link to this from my downstream application, it fa…

---

## [Combining multiple static libraries onto one. How to retrieve list of static libraries from target?](https://discourse.cmake.org/t/combining-multiple-static-libraries-onto-one-how-to-retrieve-list-of-static-libraries-from-target/5302)

<div class="topic-metadata">

**Author:** [@hgkjshegfskef](https://discourse.cmake.org/u/hgkjshegfskef)\
**Replies:** 1\
**Last updated:** [March 29, 2022, 1:24pm UTC](https://discourse.cmake.org/t/combining-multiple-static-libraries-onto-one-how-to-retrieve-list-of-static-libraries-from-target/5302 "2022-03-29T13:24:39Z")

</div>

Platform: Linux, Ninja. Goal: combine many static libraries into one static library, i.e. run something like ar rcs hugelib.a lib1.a lib2.a \[...\]. Why? For the user to use C/C++ source files in script mode, and so that …

---

## [Escaping strings for output to JSON file](https://discourse.cmake.org/t/escaping-strings-for-output-to-json-file/5297)

<div class="topic-metadata">

**Author:** [@dwarwick](https://discourse.cmake.org/u/dwarwick)\
**Replies:** 3\
**Last updated:** [March 29, 2022, 1:22pm UTC](https://discourse.cmake.org/t/escaping-strings-for-output-to-json-file/5297 "2022-03-29T13:22:44Z")

</div>

I have an existing string in CMake – compile flags passed to the target – that have quotes in them. If I want to write these to a JSON file, I need to escape the quotes in them. Since these are not defined manually by me…

---

## [How do I install a library as a find-able package?](https://discourse.cmake.org/t/how-do-i-install-a-library-as-a-find-able-package/5150)

<div class="topic-metadata">

**Author:** [@Chrinkus](https://discourse.cmake.org/u/Chrinkus)\
**Replies:** 3\
**Last updated:** [March 29, 2022, 6:59am UTC](https://discourse.cmake.org/t/how-do-i-install-a-library-as-a-find-able-package/5150 "2022-03-29T06:59:11Z")

</div>

I have a C utility library that I’ve been using CMake to build and install. Now I want to access my library in a GTK project I’m doing that is (sorry) using Meson to build. When I list my library as a dependency Meson is…

---

## [How to install export target with INSTALL\_INTERFACE](https://discourse.cmake.org/t/how-to-install-export-target-with-install-interface/5293)

<div class="topic-metadata">

**Author:** [@tooEarlyForThis](https://discourse.cmake.org/u/tooEarlyForThis)\
**Replies:** 2\
**Last updated:** [March 28, 2022, 7:14am UTC](https://discourse.cmake.org/t/how-to-install-export-target-with-install-interface/5293 "2022-03-28T07:14:01Z")

</div>

Having worked with CMake for some time, it is now time to create my first exported library. I followed the guides in the documentation (https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html and others)…

---

## [Problems with PkgConfig and static builds](https://discourse.cmake.org/t/problems-with-pkgconfig-and-static-builds/5284)

<div class="topic-metadata">

**Author:** [@bjpalmer](https://discourse.cmake.org/u/bjpalmer)\
**Replies:** 0\
**Last updated:** [March 24, 2022, 3:02pm UTC](https://discourse.cmake.org/t/problems-with-pkgconfig-and-static-builds/5284 "2022-03-24T15:02:46Z")

</div>

Hi, We are trying to use the PkgConfig module with our GridPACK project to link with builds of the PETSc library. This works fine for builds using shared libraries, but fails completely for static builds. We need to get…

---

## [ExternalProject\_Add does not respect USES\_TERMINAL\_\* flags.](https://discourse.cmake.org/t/externalproject-add-does-not-respect-uses-terminal-flags/5254)

<div class="topic-metadata">

**Author:** [@rbprogrammer](https://discourse.cmake.org/u/rbprogrammer)\
**Replies:** 2\
**Last updated:** [March 21, 2022, 11:43am UTC](https://discourse.cmake.org/t/externalproject-add-does-not-respect-uses-terminal-flags/5254 "2022-03-21T11:43:06Z")

</div>

The latest CMake docs for ExternalProject\_Add() describe how to use the directive to download external dependencies through version control systems like Git, Subversion, and others. The docs also mention a section calle…

---

## [Debugging an errant -isystem](https://discourse.cmake.org/t/debugging-an-errant-isystem/5250)

<div class="topic-metadata">

**Author:** [@dcblack](https://discourse.cmake.org/u/dcblack)\
**Replies:** 2\
**Last updated:** [March 21, 2022, 11:07am UTC](https://discourse.cmake.org/t/debugging-an-errant-isystem/5250 "2022-03-21T11:07:30Z")

</div>

I have a project that keeps insisting on putting in a -isystem DIRECTORY, where the directory is completely inappropriate (it points to a directory is not relevant that is from another project elsewhere on my machine) an…

---

## [Target visibility for external project](https://discourse.cmake.org/t/target-visibility-for-external-project/5242)

<div class="topic-metadata">

**Author:** [@NeoCortex97](https://discourse.cmake.org/u/NeoCortex97)\
**Replies:** 4\
**Last updated:** [March 20, 2022, 12:50am UTC](https://discourse.cmake.org/t/target-visibility-for-external-project/5242 "2022-03-20T00:50:12Z")

</div>

As you might have read in my Topic about using the superbuild pattern as a workspace, I want to emulate some of the functionality that catkin offered for ROS projects. I would like to structure my projects and my worksp…

---

## [CPack a Windows Service](https://discourse.cmake.org/t/cpack-a-windows-service/5251)

<div class="topic-metadata">

**Author:** [@jshanab](https://discourse.cmake.org/u/jshanab)\
**Replies:** 0\
**Last updated:** [March 19, 2022, 5:53pm UTC](https://discourse.cmake.org/t/cpack-a-windows-service/5251 "2022-03-19T17:53:41Z")

</div>

I have been trying to figure out if there is an easy and proper way to install a Windows Service In NSIS this would be a hidden (-{sectionname}) part that calls the service manager to stop and unregister(if necessary)-\>…

---

## [cmake "include()" statement does not (always) error out when the target file does not exist?](https://discourse.cmake.org/t/cmake-include-statement-does-not-always-error-out-when-the-target-file-does-not-exist/5237)

<div class="topic-metadata">

**Author:** [@emmenlau](https://discourse.cmake.org/u/emmenlau)\
**Replies:** 1\
**Last updated:** [March 19, 2022, 4:44am UTC](https://discourse.cmake.org/t/cmake-include-statement-does-not-always-error-out-when-the-target-file-does-not-exist/5237 "2022-03-19T04:44:52Z")

</div>

I just spent two hours of debugging until I found an interesting problem. In my package-configuration, I write include("${CMAKE\_CURRENT\_LIST\_DIR}/@MY\_PROJECT\_NAME@Targets.cmake") Through a copy-paste-error, the variabl…

---

## [How do I get a workspace of independent subprojects](https://discourse.cmake.org/t/how-do-i-get-a-workspace-of-independent-subprojects/5154)

<div class="topic-metadata">

**Author:** [@NeoCortex97](https://discourse.cmake.org/u/NeoCortex97)\
**Replies:** 12\
**Last updated:** [March 18, 2022, 8:52am UTC](https://discourse.cmake.org/t/how-do-i-get-a-workspace-of-independent-subprojects/5154 "2022-03-18T08:52:19Z")

</div>

I would like to create a workspace like pattern. So that I have a directory which contains a CMakeLists.txt and a number of direcotries with other cmake projects an would like to be able to build all of them by configur…

---

## [installing a pre-built module and its various dependencies](https://discourse.cmake.org/t/installing-a-pre-built-module-and-its-various-dependencies/5227)

<div class="topic-metadata">

**Author:** [@wuziq](https://discourse.cmake.org/u/wuziq)\
**Replies:** 1\
**Last updated:** [March 17, 2022, 5:47am UTC](https://discourse.cmake.org/t/installing-a-pre-built-module-and-its-various-dependencies/5227 "2022-03-17T05:47:08Z")

</div>

Apologies in advance if this approach is completely wrong-headed. I could be missing obvious things but am just too tunnel-visioned to realize it. Anyway… We have a pre-built .dll, called Foo.dll, that we load with Lo…

---

## [Using of .dld files in cmake](https://discourse.cmake.org/t/using-of-dld-files-in-cmake/5219)

<div class="topic-metadata">

**Author:** [@satheesh.jetti](https://discourse.cmake.org/u/satheesh.jetti)\
**Replies:** 0\
**Last updated:** [March 15, 2022, 11:36am UTC](https://discourse.cmake.org/t/using-of-dld-files-in-cmake/5219 "2022-03-15T11:36:06Z")

</div>

I have linker configuration file(.dld) which will call all the linker scripts(.lsl). I want to use .dld file in cmake. Is it possible ? If yes ,Please give me the commands for it. thanks in advance

---

## [Write CMake file for project that using GTKMM and An include library](https://discourse.cmake.org/t/write-cmake-file-for-project-that-using-gtkmm-and-an-include-library/5216)

<div class="topic-metadata">

**Author:** [@Mamograg17](https://discourse.cmake.org/u/Mamograg17)\
**Replies:** 0\
**Last updated:** [March 14, 2022, 1:05pm UTC](https://discourse.cmake.org/t/write-cmake-file-for-project-that-using-gtkmm-and-an-include-library/5216 "2022-03-14T13:05:30Z")

</div>

Hello, I am trying to write a CMake file for my project, this is the project tree : Project I CMakeLists.txt I\_\_\_src I-----I\_\_main.cpp I-----I\_\_window.cpp I-----I\_\_windows.hpp I-----I\_\_operations.cpp I-----I\_\_CM…

---

## [rerunning configure\_file when the input file changes.](https://discourse.cmake.org/t/rerunning-configure-file-when-the-input-file-changes/5191)

<div class="topic-metadata">

**Author:** [@ARSanderson](https://discourse.cmake.org/u/ARSanderson)\
**Replies:** 3\
**Last updated:** [March 10, 2022, 12:16pm UTC](https://discourse.cmake.org/t/rerunning-configure-file-when-the-input-file-changes/5191 "2022-03-10T12:16:26Z")

</div>

When cmake runs the first time I am able to generate a file using the following: configure\_file(foo.cpp.in foo.cpp) That works great. But if foo.cpp.in changes I would like foo.cpp to be regenerated. If I touch foo.c…

---

## [System include path](https://discourse.cmake.org/t/system-include-path/1457)

<div class="topic-metadata">

**Author:** [@Cedric\_Schmeits](https://discourse.cmake.org/u/Cedric_Schmeits)\
**Replies:** 4\
**Last updated:** [March 7, 2022, 9:13pm UTC](https://discourse.cmake.org/t/system-include-path/1457 "2022-03-07T21:13:47Z")

</div>

I’m currently in the process of using pclint in checking the c and c++ source files for errors. So when I have a target I want to lint the files that are the sources of that target to be processed using the pclint applic…

---

## [Own CMAKE library](https://discourse.cmake.org/t/own-cmake-library/5179)

<div class="topic-metadata">

**Author:** [@Spyrex](https://discourse.cmake.org/u/Spyrex)\
**Replies:** 1\
**Last updated:** [March 7, 2022, 8:14pm UTC](https://discourse.cmake.org/t/own-cmake-library/5179 "2022-03-07T20:14:41Z")

</div>

Hey, I am relatively new to cpp. I programmed some classes I want to be able to build to a separate library I can use from another cpp project. This my directory structure: Root - Game/ - CMakeLists.txt - main.c…

---

## [Clean way to detect if compiler supports enum deprecation](https://discourse.cmake.org/t/clean-way-to-detect-if-compiler-supports-enum-deprecation/5169)

<div class="topic-metadata">

**Author:** [@szhorvat](https://discourse.cmake.org/u/szhorvat)\
**Replies:** 1\
**Last updated:** [March 4, 2022, 11:01pm UTC](https://discourse.cmake.org/t/clean-way-to-detect-if-compiler-supports-enum-deprecation/5169 "2022-03-04T23:01:32Z")

</div>

GCC versions 6 and later, as well as all most Clang versions, support deprecating enum values in C like this: enum Foo { A = 1, B \_\_attribute\_\_ ((deprecated)) = A /\* B is deprecated in favour of A \*/ }; Howeve…

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

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