# Code

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

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

**Page:** 39

---

## [Strange failure with ficticious Fortran module dependency](https://discourse.cmake.org/t/strange-failure-with-ficticious-fortran-module-dependency/7109)

<div class="topic-metadata">

**Author:** [@krefson](https://discourse.cmake.org/u/krefson)\
**Replies:** 5\
**Last updated:** [December 22, 2022, 3:09pm UTC](https://discourse.cmake.org/t/strange-failure-with-ficticious-fortran-module-dependency/7109 "2022-12-22T15:09:53Z")

</div>

I discovered an odd failure while attempting to port a large (mostly-)Fortran project to cmake+ninja under Msys2. The failure is clearly in the Fortran source code parser attempting to search for “module” statements, wh…

---

## [FindBLAS needs a try\_run to test link from Fortran](https://discourse.cmake.org/t/findblas-needs-a-try-run-to-test-link-from-fortran/7114)

<div class="topic-metadata">

**Author:** [@krefson](https://discourse.cmake.org/u/krefson)\
**Replies:** 0\
**Last updated:** [December 22, 2022, 11:49am UTC](https://discourse.cmake.org/t/findblas-needs-a-try-run-to-test-link-from-fortran/7114 "2022-12-22T11:49:01Z")

</div>

Having spent 30 minutes in puzzlement over a bad build with segfaulting executables, I would like to propose an enhancement of FindBLAS to check that the BLAS libraries found are ABI-compatible with the Fortran compiler …

---

## [Dependency Cycle with Qt6 / QML](https://discourse.cmake.org/t/dependency-cycle-with-qt6-qml/7099)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 9\
**Last updated:** [December 21, 2022, 1:26pm UTC](https://discourse.cmake.org/t/dependency-cycle-with-qt6-qml/7099 "2022-12-21T13:26:31Z")

</div>

Hi, I have some project, where I introduced some qml. The command is the following: qt\_add\_qml\_module(BeansClient URI Beans.Gui VERSION 1.0 QML\_FILES qml/Windows/Home/main.qml qml/Components…

---

## [Project wide compile options](https://discourse.cmake.org/t/project-wide-compile-options/7103)

<div class="topic-metadata">

**Author:** [@some\_name](https://discourse.cmake.org/u/some_name)\
**Replies:** 1\
**Last updated:** [December 21, 2022, 12:40pm UTC](https://discourse.cmake.org/t/project-wide-compile-options/7103 "2022-12-21T12:40:48Z")

</div>

I would like to set some options (such as /Wall) in the root of my project such that they apply to all code. I tried using add\_compile\_options but on Windows when I create a project using cmake -G “Visual Studio 17 2022”…

---

## [CMake code for building gzipped & ungzipped manuals](https://discourse.cmake.org/t/cmake-code-for-building-gzipped-ungzipped-manuals/7101)

<div class="topic-metadata">

**Author:** [@ogogon](https://discourse.cmake.org/u/ogogon)\
**Replies:** 1\
**Last updated:** [December 21, 2022, 2:15am UTC](https://discourse.cmake.org/t/cmake-code-for-building-gzipped-ungzipped-manuals/7101 "2022-12-21T02:15:04Z")

</div>

Colleagues, tell me, please, are there ready-made modules for building gzipped and non-gzipped manual pages from source codes? I have this situation - I write manual pages on markdown and compile them using the lowdown …

---

## [How to parse the values passed to findXXX.cmake file?](https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098)

<div class="topic-metadata">

**Author:** [@msilvestre](https://discourse.cmake.org/u/msilvestre)\
**Replies:** 2\
**Last updated:** [December 20, 2022, 3:09pm UTC](https://discourse.cmake.org/t/how-to-parse-the-values-passed-to-findxxx-cmake-file/7098 "2022-12-20T15:09:24Z")

</div>

Hi all, I need to parse the stuff passed to findXXX.cmake file. How can it be done? I’ve tried the cmake\_parse\_arguments but ARGV and ARGN are empty. Usage example: CMakeLists.txt file: find\_package(foo REQUIRED …

---

## [find\_package CONFIG - cross platform shared library location set/query ?](https://discourse.cmake.org/t/find-package-config-cross-platform-shared-library-location-set-query/7091)

<div class="topic-metadata">

**Author:** [@Nicholas\_Yue](https://discourse.cmake.org/u/Nicholas_Yue)\
**Replies:** 1\
**Last updated:** [December 19, 2022, 12:47pm UTC](https://discourse.cmake.org/t/find-package-config-cross-platform-shared-library-location-set-query/7091 "2022-12-19T12:47:21Z")

</div>

I am learning about creating and using CONFIG I am creating a simple SDK which has one shared library and one static library \[SSL - Simple Single Library\] User of the SDK can choose to link with either one via their n…

---

## [How do I change a cache variable which is used in my code](https://discourse.cmake.org/t/how-do-i-change-a-cache-variable-which-is-used-in-my-code/7094)

<div class="topic-metadata">

**Author:** [@abteikartei](https://discourse.cmake.org/u/abteikartei)\
**Replies:** 1\
**Last updated:** [December 18, 2022, 11:40am UTC](https://discourse.cmake.org/t/how-do-i-change-a-cache-variable-which-is-used-in-my-code/7094 "2022-12-18T11:40:51Z")

</div>

Hi! I have a boolean cache variable MY\_VARIABLE that is used via configure\_file and #ifdef to change what parts of my code are build. By default it is turned off. But if I change the variable with -DMY\_VARIABLE=ON durin…

---

## [Install "contaminated" headers directory](https://discourse.cmake.org/t/install-contaminated-headers-directory/7083)

<div class="topic-metadata">

**Author:** [@ruilvo](https://discourse.cmake.org/u/ruilvo)\
**Replies:** 4\
**Last updated:** [December 16, 2022, 2:32pm UTC](https://discourse.cmake.org/t/install-contaminated-headers-directory/7083 "2022-12-16T14:32:14Z")

</div>

Hello there, So here’s the deal. I’m managing this C(++ eventually)+CMake project. This is the repo: Problem is that the installation results in the following tree (here shown via cpack for simplicity): lk@lk-vm:~/D…

---

## [Changing XCode settings](https://discourse.cmake.org/t/changing-xcode-settings/7085)

<div class="topic-metadata">

**Author:** [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)\
**Replies:** 1\
**Last updated:** [December 16, 2022, 1:41pm UTC](https://discourse.cmake.org/t/changing-xcode-settings/7085 "2022-12-16T13:41:32Z")

</div>

Hello, I wanted to know if it was possible to change XCode parameters directly from CMake like for example the field WEAK REFERENCES IN MANUAL RETAIN RELEASE that we can see on the picture ? I discovered the notion of X…

---

## [Custom path at the end of RPATH](https://discourse.cmake.org/t/custom-path-at-the-end-of-rpath/7080)

<div class="topic-metadata">

**Author:** [@gzauhar](https://discourse.cmake.org/u/gzauhar)\
**Replies:** 1\
**Last updated:** [December 15, 2022, 2:26pm UTC](https://discourse.cmake.org/t/custom-path-at-the-end-of-rpath/7080 "2022-12-15T14:26:43Z")

</div>

Hi there! I kindly ask assistance with RPATH control in CMake. I would like to add custom path at the end of RPATH in every executable which gets produced (e.g. unittest executables) at build time (e.g. make and not ins…

---

## [not able to perform execute\_process()](https://discourse.cmake.org/t/not-able-to-perform-execute-process/7078)

<div class="topic-metadata">

**Author:** [@vryy](https://discourse.cmake.org/u/vryy)\
**Replies:** 1\
**Last updated:** [December 15, 2022, 1:07pm UTC](https://discourse.cmake.org/t/not-able-to-perform-execute-process/7078 "2022-12-15T13:07:01Z")

</div>

I invoked execute\_process as below execute\_process( COMMAND ${POST\_PROCESSOR} --filter=ensight --file=${PREFIX} WORKING\_DIRECTORY ${TEST\_DIR} COMMAND\_ECHO STDOUT OUTPUT\_VARIABLE log2 ERROR\_VARIABLE err2 RESUL…

---

## [CMake's equivalent of AC\_SEARCH\_LIBS (to find std::filesystem)?](https://discourse.cmake.org/t/cmakes-equivalent-of-ac-search-libs-to-find-std-filesystem/4818)

<div class="topic-metadata">

**Author:** [@mojca](https://discourse.cmake.org/u/mojca)\
**Replies:** 4\
**Last updated:** [December 15, 2022, 9:35am UTC](https://discourse.cmake.org/t/cmakes-equivalent-of-ac-search-libs-to-find-std-filesystem/4818 "2022-12-15T09:35:42Z")

</div>

In autotools one can do the following for example: AC\_SEARCH\_LIBS(clock\_gettime, rt) which will add the -lrt flag only when it’s available and needed. (I’m not claiming that my statement is 100% exact, but this one-lin…

---

## [CPack with externally created .app bundle (macOS)?](https://discourse.cmake.org/t/cpack-with-externally-created-app-bundle-macos/6152)

<div class="topic-metadata">

**Author:** [@SamuelMarks](https://discourse.cmake.org/u/SamuelMarks)\
**Replies:** 1\
**Last updated:** [December 14, 2022, 11:46am UTC](https://discourse.cmake.org/t/cpack-with-externally-created-app-bundle-macos/6152 "2022-12-14T11:46:40Z")

</div>

I’ve manually done lots that CMake+CPack are meant to do for me, here are the summary of my hacks, hidden behind an if(BUILD\_APPLE\_BUNDLE) option flag: set(CMAKE\_LIBRARY\_OUTPUT\_DIRECTORY "${CMAKE\_BINARY\_DIR}/${EXEC…

---

## [Subproject of a linked library is linked as GLOBAL when it should be LOCAL](https://discourse.cmake.org/t/subproject-of-a-linked-library-is-linked-as-global-when-it-should-be-local/7061)

<div class="topic-metadata">

**Author:** [@bugblatterbeast](https://discourse.cmake.org/u/bugblatterbeast)\
**Replies:** 3\
**Last updated:** [December 14, 2022, 9:58am UTC](https://discourse.cmake.org/t/subproject-of-a-linked-library-is-linked-as-global-when-it-should-be-local/7061 "2022-12-14T09:58:09Z")

</div>

Hi, I have a project containing a static library and a testing application. The static library has several sub projects. FetchContent\_Declare( subproject1 GIT\_REPOSITORY ... ) FetchContent\_MakeAvailable(subproj…

---

## [protobuf\_generate\_cpp not found](https://discourse.cmake.org/t/protobuf-generate-cpp-not-found/7053)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 1\
**Last updated:** [December 14, 2022, 4:13am UTC](https://discourse.cmake.org/t/protobuf-generate-cpp-not-found/7053 "2022-12-14T04:13:25Z")

</div>

I don’t see a whole lot in the docs about the preqequisites of the above function (?). Using it on 3.24.2 I have no problem but on some build agents I’m using which are on 3.16 it fails with Unknown CMake command "protob…

---

## [where is document for Rule Placeholder variables like \<SOURCE\>](https://discourse.cmake.org/t/where-is-document-for-rule-placeholder-variables-like-source/7059)

<div class="topic-metadata">

**Author:** [@FishAndBird](https://discourse.cmake.org/u/FishAndBird)\
**Replies:** 2\
**Last updated:** [December 14, 2022, 3:53am UTC](https://discourse.cmake.org/t/where-is-document-for-rule-placeholder-variables-like-source/7059 "2022-12-14T03:53:25Z")

</div>

I see there are rules with placeholder variables likes set(CMAKE\_C\_COMPILE\_OBJECT "\<CMAKE\_C\_COMPILER\> \<DEFINES\> \<INCLUDES\> \<FLAGS\> -o \<OBJECT\> -c \<SOURCE\>") Though i can find it in source Source/cmRulePlaceholderExpan…

---

## [How to set MSVC\_REDIST\_DIR?](https://discourse.cmake.org/t/how-to-set-msvc-redist-dir/7056)

<div class="topic-metadata">

**Author:** [@jpfeuffer](https://discourse.cmake.org/u/jpfeuffer)\
**Replies:** 2\
**Last updated:** [December 13, 2022, 11:04am UTC](https://discourse.cmake.org/t/how-to-set-msvc-redist-dir/7056 "2022-12-13T11:04:17Z")

</div>

Hi, I want to automatically copy dlls into my install folder with include(InstallRequiredSystemLibraries). However, with VS2019, toolset v142, I am getting: CMake Warning at C:/Program Files/CMake/share/cmake-3.25/Mod…

---

## [What's the best way to include headers from FetchContent deps?](https://discourse.cmake.org/t/whats-the-best-way-to-include-headers-from-fetchcontent-deps/7047)

<div class="topic-metadata">

**Author:** [@Chrinkus](https://discourse.cmake.org/u/Chrinkus)\
**Replies:** 5\
**Last updated:** [December 12, 2022, 5:26pm UTC](https://discourse.cmake.org/t/whats-the-best-way-to-include-headers-from-fetchcontent-deps/7047 "2022-12-12T17:26:01Z")

</div>

I’ve added the bare-bones FetchContent statements to my project that declare and make available some support libraries that I’ve also written. I’ve been successfully compiling and running from my source tree but didn’t r…

---

## [CMP0115 - diagnosing error message](https://discourse.cmake.org/t/cmp0115-diagnosing-error-message/7040)

<div class="topic-metadata">

**Author:** [@anon74639460](https://discourse.cmake.org/u/anon74639460)\
**Replies:** 2\
**Last updated:** [December 9, 2022, 1:50pm UTC](https://discourse.cmake.org/t/cmp0115-diagnosing-error-message/7040 "2022-12-09T13:50:53Z")

</div>

I have a few projects that used to build clean, now they get the infamous CMP0115 warning. I’m using the cmake files from one to start a new project and since this project is smaller, will use it. The file being flag…

---

## [Wrapper of target\_link\_libraries](https://discourse.cmake.org/t/wrapper-of-target-link-libraries/6956)

<div class="topic-metadata">

**Author:** [@NoName](https://discourse.cmake.org/u/NoName)\
**Replies:** 6\
**Last updated:** [December 8, 2022, 11:58am UTC](https://discourse.cmake.org/t/wrapper-of-target-link-libraries/6956 "2022-12-08T11:58:06Z")

</div>

Hi, I’m working on a large project that has managed its external library dependencies in a single “libraries.cmake” file so far. For each external dependency there is a find\_package call. Now I want to change it to a mo…

---

## [find\_package does not set the include path for my target](https://discourse.cmake.org/t/find-package-does-not-set-the-include-path-for-my-target/7032)

<div class="topic-metadata">

**Author:** [@K20shores](https://discourse.cmake.org/u/K20shores)\
**Replies:** 1\
**Last updated:** [December 7, 2022, 9:59pm UTC](https://discourse.cmake.org/t/find-package-does-not-set-the-include-path-for-my-target/7032 "2022-12-07T21:59:58Z")

</div>

I’ve been trying to include an install target in projects that I work on. In the most recent change, I’ve been trying to modify our project to install to common locations and install the config files that are needed to u…

---

## [How to check if a file was created by a test?](https://discourse.cmake.org/t/how-to-check-if-a-file-was-created-by-a-test/7017)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 2\
**Last updated:** [December 6, 2022, 5:59pm UTC](https://discourse.cmake.org/t/how-to-check-if-a-file-was-created-by-a-test/7017 "2022-12-06T17:59:08Z")

</div>

Say I have an executable that creates a file. What’s the best way to write a test to verify the existence of the file. # Assume the file is created in the same directory as the executable add\_test(NAME create\_json\_file …

---

## [set\_target\_properties doesn't work properly](https://discourse.cmake.org/t/set-target-properties-doesnt-work-properly/7016)

<div class="topic-metadata">

**Author:** [@shiltian](https://discourse.cmake.org/u/shiltian)\
**Replies:** 2\
**Last updated:** [December 6, 2022, 3:44am UTC](https://discourse.cmake.org/t/set-target-properties-doesnt-work-properly/7016 "2022-12-06T03:44:11Z")

</div>

Hi CMake community, I got a small piece of code where set\_target\_properties doesn’t work as expected. add\_compile\_definitions( TARGET\_NAME="PluginInterface" DEBUG\_PREFIX="PluginInterface" ) add\_llvm\_library(Plug…

---

## [Concurrent OpenSSL versions woes](https://discourse.cmake.org/t/concurrent-openssl-versions-woes/7012)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 2\
**Last updated:** [December 5, 2022, 9:56pm UTC](https://discourse.cmake.org/t/concurrent-openssl-versions-woes/7012 "2022-12-05T21:56:05Z")

</div>

My machine has OpenSSL 1.1.1f and 3.0.7 installed concurrently in rather different locations - however the .so files are all in the same dir but under distinct names. When I do find\_package(OpenSSL) and no hints it find…

---

## [How do I set define based on current build type?](https://discourse.cmake.org/t/how-do-i-set-define-based-on-current-build-type/6890)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.cmake.org/u/Jack)\
**Replies:** 11\
**Last updated:** [December 2, 2022, 1:13pm UTC](https://discourse.cmake.org/t/how-do-i-set-define-based-on-current-build-type/6890 "2022-12-02T13:13:01Z")

</div>

I want to ensure that a particular compiler definition is set/not set based on the build type. I thought that this would work but it’s not: if($ENV{CMAKE\_BUILD\_TYPE} MATCHES "\[Dd\]\[Ee\]\[Bb\]\[Uu\]\[Gg\]") # In case it w…

---

## [Is it exlicitly described in the doc that Modern CMake will only compile \`.cu\` files with \`nvcc\`?](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954)

<div class="topic-metadata">

**Author:** [@songyuc](https://discourse.cmake.org/u/songyuc)\
**Replies:** 3\
**Last updated:** [December 2, 2022, 12:21pm UTC](https://discourse.cmake.org/t/is-it-exlicitly-described-in-the-doc-that-modern-cmake-will-only-compile-cu-files-with-nvcc/6954 "2022-12-02T12:21:05Z")

</div>

Hi, guys, I am a learner of CMake, and I find that CMake would only compile .cu files with nvcc, except any files with the other extensions. Is this rule exlicitly described in the CMake documentation? Currently, I h…

---

## [generator expression, target\_compile\_features](https://discourse.cmake.org/t/generator-expression-target-compile-features/6980)

<div class="topic-metadata">

**Author:** [@maggu2810](https://discourse.cmake.org/u/maggu2810)\
**Replies:** 7\
**Last updated:** [December 1, 2022, 9:34pm UTC](https://discourse.cmake.org/t/generator-expression-target-compile-features/6980 "2022-12-01T21:34:11Z")

</div>

Hi, I am using an interface library with generator expressions to set specific options that can be consumed by several projects of mine. As far as I can judge it works as expected, for example: target\_link\_options(${t…

---

## [Detect presence of multi-config generators](https://discourse.cmake.org/t/detect-presence-of-multi-config-generators/6987)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 6\
**Last updated:** [November 30, 2022, 9:04pm UTC](https://discourse.cmake.org/t/detect-presence-of-multi-config-generators/6987 "2022-11-30T21:04:43Z")

</div>

If I have multi-config generators there are some configs I would like to remove for performance reasons I read about here, what’s the best way to do this? I.e. at what stage can I expect the GENERATOR\_IS\_MULTI\_CONFIG to…

---

## [How to use target\_compile\_definitions ?](https://discourse.cmake.org/t/how-to-use-target-compile-definitions/6982)

<div class="topic-metadata">

**Author:** [@malaterre](https://discourse.cmake.org/u/malaterre)\
**Replies:** 4\
**Last updated:** [November 29, 2022, 3:49pm UTC](https://discourse.cmake.org/t/how-to-use-target-compile-definitions/6982 "2022-11-29T15:49:30Z")

</div>

Here is my naive attempt at using target\_compile\_definitions: cmake\_minimum\_required(VERSION 3.12.1 FATAL\_ERROR) project(p) add\_library(foo foo.cpp) set(defs "-D\_GNU\_SOURCE -D\_LARGEFILE\_SOURCE -D\_FILE\_OFFSET\_BITS=64 -…

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

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