# Code

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

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

**Page:** 44

---

## [PUBLIC\_HEADER target property ignored when building Mac OS Frameworks](https://discourse.cmake.org/t/public-header-target-property-ignored-when-building-mac-os-frameworks/6311)

<div class="topic-metadata">

**Author:** [@DwayneDuane](https://discourse.cmake.org/u/DwayneDuane)\
**Replies:** 1\
**Last updated:** [August 20, 2022, 4:14pm UTC](https://discourse.cmake.org/t/public-header-target-property-ignored-when-building-mac-os-frameworks/6311 "2022-08-20T16:14:23Z")

</div>

CMake version: 3.21.2 OS: macOS Monterey 12.4 I am trying to build a MacOS framework using CMake and would like to copy the lib’s public headers into a Headers subfolder inside the framework. According to CMake documen…

---

## [Is BUILD\_SHARED\_LIBS an implicit option without being declared as a project option?](https://discourse.cmake.org/t/is-build-shared-libs-an-implicit-option-without-being-declared-as-a-project-option/6308)

<div class="topic-metadata">

**Author:** [@specious](https://discourse.cmake.org/u/specious)\
**Replies:** 1\
**Last updated:** [August 19, 2022, 11:28pm UTC](https://discourse.cmake.org/t/is-build-shared-libs-an-implicit-option-without-being-declared-as-a-project-option/6308 "2022-08-19T23:28:11Z")

</div>

According to the docs and this tutorial, it appears that the recommendation is to declare BUILD\_SHARED\_LIBS as an option(). What precisely is the working status of this flag when it is not declared by the project? It se…

---

## [Locating a Problem while creating a Shared Library](https://discourse.cmake.org/t/locating-a-problem-while-creating-a-shared-library/3479)

<div class="topic-metadata">

**Author:** [@roottjk](https://discourse.cmake.org/u/roottjk)\
**Replies:** 2\
**Last updated:** [August 19, 2022, 10:18pm UTC](https://discourse.cmake.org/t/locating-a-problem-while-creating-a-shared-library/3479 "2022-08-19T22:18:15Z")

</div>

Hi guys, im pretty new to CMake and also to Android. Im supposed to port a c/c++ Program to Android. Its pretty complex and so is the CMakeLists.txt. I managed to successfully build an Android Version of the project run…

---

## [set MSVC "Output Files -\> Object File Name"](https://discourse.cmake.org/t/set-msvc-output-files-object-file-name/2220)

<div class="topic-metadata">

**Author:** [@ProTurm2](https://discourse.cmake.org/u/ProTurm2)\
**Replies:** 4\
**Last updated:** [August 19, 2022, 7:10pm UTC](https://discourse.cmake.org/t/set-msvc-output-files-object-file-name/2220 "2022-08-19T19:10:52Z")

</div>

What is the property name for setting MSVC Output Files -\> Object File Name ? I would like to handle the case where two files of different folders have the same file name. Does cmake offer something of this kind? Where …

---

## [Proper way for a package to propagate CMAKE\_MODULE\_PATH](https://discourse.cmake.org/t/proper-way-for-a-package-to-propagate-cmake-module-path/6301)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 2\
**Last updated:** [August 19, 2022, 4:21pm UTC](https://discourse.cmake.org/t/proper-way-for-a-package-to-propagate-cmake-module-path/6301 "2022-08-19T16:21:04Z")

</div>

Is there a proper way for a CMake package to propagate variables (in particular, CMAKE\_MODULE\_PATH) to any consuming projects? I’ve got a package that provides some find modules, and in its CMakeLists.txt, it adds the ap…

---

## [cmake barfing on i386 only?](https://discourse.cmake.org/t/cmake-barfing-on-i386-only/6294)

<div class="topic-metadata">

**Author:** [@FGasper](https://discourse.cmake.org/u/FGasper)\
**Replies:** 1\
**Last updated:** [August 18, 2022, 4:43pm UTC](https://discourse.cmake.org/t/cmake-barfing-on-i386-only/6294 "2022-08-18T16:43:45Z")

</div>

I’m trying to get libnfs to compile on i386, but it keeps failing with errors like this: CMake Error at lib/CMakeLists.txt:19 (target\_link\_libraries): Target "nfs\_rquota" of type OBJECT\_LIBRARY may not be linked into …

---

## [BUILD\_SHARED\_LIBS](https://discourse.cmake.org/t/build-shared-libs/4200)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 4\
**Last updated:** [August 17, 2022, 9:27am UTC](https://discourse.cmake.org/t/build-shared-libs/4200 "2022-08-17T09:27:19Z")

</div>

As far as I know it’s best practice to not specify SHARED or STATIC for a library, but rely on BUILD\_SHARED\_LIBS instead. I have to questions regarding this. Should one specify BUILD\_SHARED\_LIBS as an option? Up to k…

---

## [Can't find Java jar using find\_jar](https://discourse.cmake.org/t/cant-find-java-jar-using-find-jar/6285)

<div class="topic-metadata">

**Author:** [@mdorier](https://discourse.cmake.org/u/mdorier)\
**Replies:** 1\
**Last updated:** [August 16, 2022, 7:49pm UTC](https://discourse.cmake.org/t/cant-find-java-jar-using-find-jar/6285 "2022-08-16T19:49:01Z")

</div>

I’m using the FindJava and UseJava modules to build a Java binding for a C++ project. The Java binding requires to import external Java packages (namely, the YCSB “core” jar), which I have installed with spack. The foll…

---

## [How to let subdirectories decide what other subdirectories are added by parent](https://discourse.cmake.org/t/how-to-let-subdirectories-decide-what-other-subdirectories-are-added-by-parent/6274)

<div class="topic-metadata">

**Author:** [@deorder](https://discourse.cmake.org/u/deorder)\
**Replies:** 2\
**Last updated:** [August 16, 2022, 7:33pm UTC](https://discourse.cmake.org/t/how-to-let-subdirectories-decide-what-other-subdirectories-are-added-by-parent/6274 "2022-08-16T19:33:18Z")

</div>

How to let a subdirectory of the same project decide if the parent should add a subdirectory. Those subdirectories (x, y) are dependencies of one or more subdirectories (a, b), but not on the parent/root. Sometimes this …

---

## [The source directory does not appear to contain CMakeLists.txt. ???](https://discourse.cmake.org/t/the-source-directory-does-not-appear-to-contain-cmakelists-txt/6284)

<div class="topic-metadata">

**Author:** [@Asmae](https://discourse.cmake.org/u/Asmae)\
**Replies:** 3\
**Last updated:** [August 16, 2022, 5:20pm UTC](https://discourse.cmake.org/t/the-source-directory-does-not-appear-to-contain-cmakelists-txt/6284 "2022-08-16T17:20:14Z")

</div>

I do this command ccmake -DITK\_USE\_REVIEW=ON … and a CMAKE error appear: CMake Error: The source directory “/home/asma/gate” does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help butto…

---

## [Conditional linker flag](https://discourse.cmake.org/t/conditional-linker-flag/6277)

<div class="topic-metadata">

**Author:** [@Progman3K](https://discourse.cmake.org/u/Progman3K)\
**Replies:** 6\
**Last updated:** [August 16, 2022, 2:45am UTC](https://discourse.cmake.org/t/conditional-linker-flag/6277 "2022-08-16T02:45:13Z")

</div>

Hi, I’m a noob. I’m trying to pass a specific flag to the linker ONLY if the compiler is GCC 7 or below. Here is my project structure: ├── CMakeLists.txt └── src ├── CMakeLists.txt ├── main.cpp └── project.h The…

---

## [Can't find headers in framework when using Config](https://discourse.cmake.org/t/cant-find-headers-in-framework-when-using-config/4098)

<div class="topic-metadata">

**Author:** [@vdamewood](https://discourse.cmake.org/u/vdamewood)\
**Replies:** 2\
**Last updated:** [August 15, 2022, 9:25pm UTC](https://discourse.cmake.org/t/cant-find-headers-in-framework-when-using-config/4098 "2022-08-15T21:25:15Z")

</div>

On macOS, I get the following error when I try to build a project that uses find\_package to load MyLibConfig.cmake : /Users/vdamewood/tmp/projekto/MyConsumer/src/main.c:1:10: fatal error: 'MyLib/MyLib.h' file not found …

---

## [Generator expression with potentially empty list](https://discourse.cmake.org/t/generator-expression-with-potentially-empty-list/6254)

<div class="topic-metadata">

**Author:** [@jpfeuffer](https://discourse.cmake.org/u/jpfeuffer)\
**Replies:** 2\
**Last updated:** [August 15, 2022, 10:37am UTC](https://discourse.cmake.org/t/generator-expression-with-potentially-empty-list/6254 "2022-08-15T10:37:34Z")

</div>

Hi, I am trying to modify the example of https://cmake.org/cmake/help/git-stage/manual/cmake-generator-expressions.7.html#genex:TARGET\_RUNTIME\_DLLS to work with potentially empty lists in a macro but I just cannot get …

---

## [OUTPUT\_VARIABLE of execute\_process isn't initialized in install(CODE)](https://discourse.cmake.org/t/output-variable-of-execute-process-isnt-initialized-in-install-code/6263)

<div class="topic-metadata">

**Author:** [@Anton-V-K](https://discourse.cmake.org/u/Anton-V-K)\
**Replies:** 2\
**Last updated:** [August 14, 2022, 9:21am UTC](https://discourse.cmake.org/t/output-variable-of-execute-process-isnt-initialized-in-install-code/6263 "2022-08-14T09:21:03Z")

</div>

I’m experimenting with dynamic install scripts and encountered that OUTPUT\_VARIABLE isn’t initialized after process finishes (this happens for built-in commands like cat, echo and probably others). Here is the minimal C…

---

## [Proper way to set a CACHE variable](https://discourse.cmake.org/t/proper-way-to-set-a-cache-variable/6222)

<div class="topic-metadata">

**Author:** [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Replies:** 3\
**Last updated:** [August 12, 2022, 11:31pm UTC](https://discourse.cmake.org/t/proper-way-to-set-a-cache-variable/6222 "2022-08-12T23:31:55Z")

</div>

I have shared library that I use where in its cmake files, sets a number of CACHE variables the cmake file does something like SET( VAR OFF CACHE BOOL “Some boolean variable” ) MESSAGE( STATUS "VAR=${VAR} ) in the p…

---

## [How include \*.winmd file in VS project with cmake?](https://discourse.cmake.org/t/how-include-winmd-file-in-vs-project-with-cmake/6242)

<div class="topic-metadata">

**Author:** [@Konstantin\_Bartashev](https://discourse.cmake.org/u/Konstantin_Bartashev)\
**Replies:** 0\
**Last updated:** [August 11, 2022, 11:41am UTC](https://discourse.cmake.org/t/how-include-winmd-file-in-vs-project-with-cmake/6242 "2022-08-11T11:41:55Z")

</div>

I have already try: set(CMAKE\_CXX\_FLAGS "${CMAKE\_CXX\_FLAGS} -AI\\"C:/Path/to/winmd/file.winmd\\"") and try target\_link\_libraries: target\_link\_libraries(${APP\_TARGET\_NAME} C:/Path/to/winmd/file.winmd didn’t works. In V…

---

## [Bug in \`if(\<varname\> STREQUAL \<string\>)\`](https://discourse.cmake.org/t/bug-in-if-varname-strequal-string/6084)

<div class="topic-metadata">

**Author:** [@gabyx](https://discourse.cmake.org/u/gabyx)\
**Replies:** 12\
**Last updated:** [August 9, 2022, 4:29pm UTC](https://discourse.cmake.org/t/bug-in-if-varname-strequal-string/6084 "2022-08-09T16:29:16Z")

</div>

Why is in this code the fatal error not triggered. This is clearly a bug? function(overwrite\_if\_empty varName byString) if("${${varName}}" STREQUAL "") message("SET") set(${varName} ${byString} PARENT\_SCOPE) …

---

## [CMAKE\_INSTALL\_RPATH\_USE\_LINK\_PATH has not effect with link directories outside /usr?](https://discourse.cmake.org/t/cmake-install-rpath-use-link-path-has-not-effect-with-link-directories-outside-usr/6158)

<div class="topic-metadata">

**Author:** [@zeroxia](https://discourse.cmake.org/u/zeroxia)\
**Replies:** 2\
**Last updated:** [August 2, 2022, 12:33pm UTC](https://discourse.cmake.org/t/cmake-install-rpath-use-link-path-has-not-effect-with-link-directories-outside-usr/6158 "2022-08-02T12:33:02Z")

</div>

Hi, System: Ubuntu 18.04, x86\_64 CMake version: 3.16.0 Compiler: GCC 7.5 I have the following interface target definition: set(APP\_CYBERRT\_PREFIX "/usr/local/cyberRT") if(EXISTS "${MY\_ROOT}/install/cyberRT/bin/mainb…

---

## [RPATH handling in the wiki -- bug?](https://discourse.cmake.org/t/rpath-handling-in-the-wiki-bug/6155)

<div class="topic-metadata">

**Author:** [@jirislaby](https://discourse.cmake.org/u/jirislaby)\
**Replies:** 1\
**Last updated:** [August 2, 2022, 11:16am UTC](https://discourse.cmake.org/t/rpath-handling-in-the-wiki-bug/6155 "2022-08-02T11:16:49Z")

</div>

During debugging of this issue in stp’s cmake: We’ve come back to: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath I don’t understand this part there: set(CMAKE\_INSTALL\_…

---

## [Hide unrelated presets](https://discourse.cmake.org/t/hide-unrelated-presets/6137)

<div class="topic-metadata">

**Author:** [@Braden](https://discourse.cmake.org/u/Braden)\
**Replies:** 3\
**Last updated:** [July 28, 2022, 2:17am UTC](https://discourse.cmake.org/t/hide-unrelated-presets/6137 "2022-07-28T02:17:21Z")

</div>

I know how to use a condition to restrict a preset to a particular platform; but I think I’m looking for something finer-grained than that. Consider: I’d like to provide a preset to generate Visual Studio 2015 project fi…

---

## [string(TIMESTAMP out\_var %s) timezone issue in Docker environment](https://discourse.cmake.org/t/string-timestamp-out-var-s-timezone-issue-in-docker-environment/5901)

<div class="topic-metadata">

**Author:** [@zeroxia](https://discourse.cmake.org/u/zeroxia)\
**Replies:** 3\
**Last updated:** [July 27, 2022, 4:28pm UTC](https://discourse.cmake.org/t/string-timestamp-out-var-s-timezone-issue-in-docker-environment/5901 "2022-07-27T16:28:26Z")

</div>

System: Ubuntu 18.04 x86\_64 I’ve prepared this t.cmake example script: string(TIMESTAMP t) string(TIMESTAMP t2 UTC) string(TIMESTAMP tt %s UTC) string(TIMESTAMP ttt %s) message(STATUS "t is ${t}") message(STATUS "t2 is…

---

## [How to make a property transitive?](https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128)

<div class="topic-metadata">

**Author:** [@wwj](https://discourse.cmake.org/u/wwj)\
**Replies:** 2\
**Last updated:** [July 25, 2022, 6:29am UTC](https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128 "2022-07-25T06:29:54Z")

</div>

I would like to make the INTERPROCEDURAL\_OPTIMIZATION property transitive, like: add\_library(A ...) # The property that should propagate to all targets that link (directly or indirectly) to A set\_property(TARGET A PROP…

---

## [CMake installation of a software package that only provides headers and pre compiled libraries](https://discourse.cmake.org/t/cmake-installation-of-a-software-package-that-only-provides-headers-and-pre-compiled-libraries/6119)

<div class="topic-metadata">

**Author:** [@wolfman21](https://discourse.cmake.org/u/wolfman21)\
**Replies:** 2\
**Last updated:** [July 21, 2022, 5:33pm UTC](https://discourse.cmake.org/t/cmake-installation-of-a-software-package-that-only-provides-headers-and-pre-compiled-libraries/6119 "2022-07-21T17:33:29Z")

</div>

Hello, We routinely work with a closed source software package, call it Foo, that is distributed as a set of C++ headers and libraries. The install process entails extracting the tarballs containing headers and libs an…

---

## [How do I configure a library so that the projects which depend upon it do not need to know about the projects upon which it depends?](https://discourse.cmake.org/t/how-do-i-configure-a-library-so-that-the-projects-which-depend-upon-it-do-not-need-to-know-about-the-projects-upon-which-it-depends/6107)

<div class="topic-metadata">

**Author:** [@Ixitxachitl](https://discourse.cmake.org/u/Ixitxachitl)\
**Replies:** 11\
**Last updated:** [July 21, 2022, 4:35pm UTC](https://discourse.cmake.org/t/how-do-i-configure-a-library-so-that-the-projects-which-depend-upon-it-do-not-need-to-know-about-the-projects-upon-which-it-depends/6107 "2022-07-21T16:35:56Z")

</div>

I have Project A, a library, and Project B, an executable which depends on A. A and B are completely separate with regard to directory structure, build systems, etc. A depends on a third party library, X. As it happen…

---

## [Making Generated Header Files Available to Other Targets in the Same Base Project](https://discourse.cmake.org/t/making-generated-header-files-available-to-other-targets-in-the-same-base-project/6097)

<div class="topic-metadata">

**Author:** [@phread](https://discourse.cmake.org/u/phread)\
**Replies:** 1\
**Last updated:** [July 21, 2022, 2:02pm UTC](https://discourse.cmake.org/t/making-generated-header-files-available-to-other-targets-in-the-same-base-project/6097 "2022-07-21T14:02:39Z")

</div>

Given some package which generates code including header files (typically associated with a library). Is there a recommended way of making generated headers available to other targets? I have an approach which works bu…

---

## [What is the recommended/correct value of \`IMPORTED\_LOCATION\` for IMPORTED library targets?](https://discourse.cmake.org/t/what-is-the-recommended-correct-value-of-imported-location-for-imported-library-targets/6081)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 4\
**Last updated:** [July 21, 2022, 4:57am UTC](https://discourse.cmake.org/t/what-is-the-recommended-correct-value-of-imported-location-for-imported-library-targets/6081 "2022-07-21T04:57:40Z")

</div>

This topic is related to this issue: https://gitlab.kitware.com/cmake/cmake/-/issues/23696 Description I want to verify what is the recommended/correct value of IMPORETED\_LOCATION when there exist MULTIPLE configuration…

---

## [Generating a Visual Studio project including external MS projects](https://discourse.cmake.org/t/generating-a-visual-studio-project-including-external-ms-projects/977)

<div class="topic-metadata">

**Author:** [@Capps\_Arlie](https://discourse.cmake.org/u/Capps_Arlie)\
**Replies:** 6\
**Last updated:** [July 20, 2022, 1:57pm UTC](https://discourse.cmake.org/t/generating-a-visual-studio-project-including-external-ms-projects/977 "2022-07-20T13:57:33Z")

</div>

I have a large program, configured with CMake, that links against several (tens of) libraries. The libraries are built with MS Visual Studio 2017 (using Intel C++ and Fortran compilers): they have handwritten project.vc…

---

## [Build \`ExternalProject\_Add\` always in \`Release\` mode](https://discourse.cmake.org/t/build-externalproject-add-always-in-release-mode/6088)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.cmake.org/u/kerim)\
**Replies:** 1\
**Last updated:** [July 17, 2022, 11:00am UTC](https://discourse.cmake.org/t/build-externalproject-add-always-in-release-mode/6088 "2022-07-17T11:00:29Z")

</div>

Hi, I use superbuild to build my app. One of superbuild dependencies is GDAL. I wan’t it to be build always Release no matter what configuration my app is built (because it seems that GDAL doesn’t generates python bind…

---

## [CMake swift internal libraries usage](https://discourse.cmake.org/t/cmake-swift-internal-libraries-usage/6080)

<div class="topic-metadata">

**Author:** [@InfRandomness](https://discourse.cmake.org/u/InfRandomness)\
**Replies:** 0\
**Last updated:** [July 14, 2022, 8:23am UTC](https://discourse.cmake.org/t/cmake-swift-internal-libraries-usage/6080 "2022-07-14T08:23:21Z")

</div>

Hey all, I was wondering if there was a way for me to use the swift compiler libraries (Swift.org - Swift Compiler) into my C++ project, I tried adding the swift repository into my project and including some of their mo…

---

## [C# SDK Style Projects - Missing Cmakelists.txt](https://discourse.cmake.org/t/c-sdk-style-projects-missing-cmakelists-txt/6036)

<div class="topic-metadata">

**Author:** [@mattsnowboard](https://discourse.cmake.org/u/mattsnowboard)\
**Replies:** 2\
**Last updated:** [July 12, 2022, 8:36pm UTC](https://discourse.cmake.org/t/c-sdk-style-projects-missing-cmakelists-txt/6036 "2022-07-12T20:36:21Z")

</div>

Is there a reason that setting DOTNET\_SDK "Microsoft.NET.Sdk" causes the CMakeLists.txt file to not show up in the generate project? It is convenient simply for quickly navigating to the file and for it to get picked up …

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

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