# Code

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

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

**Page:** 18

---

## [Incorrect module flag set in Intel Fortran compiler](https://discourse.cmake.org/t/incorrect-module-flag-set-in-intel-fortran-compiler/11707)

<div class="topic-metadata">

**Author:** [@artu72](https://discourse.cmake.org/u/artu72)\
**Replies:** 1\
**Last updated:** [September 17, 2024, 10:28am UTC](https://discourse.cmake.org/t/incorrect-module-flag-set-in-intel-fortran-compiler/11707 "2024-09-17T10:28:11Z")

</div>

Hi, in a Fortran project I need to place generated binary module files (.mod) in a given directory modules. I have used the command set(CMAKE\_Fortran\_MODULE\_DIRECTORY modules) This configuration works using the gnu com…

---

## [Visual Studio Multi-config solution](https://discourse.cmake.org/t/visual-studio-multi-config-solution/11633)

<div class="topic-metadata">

**Author:** [@Joerg](https://discourse.cmake.org/u/Joerg)\
**Replies:** 1\
**Last updated:** [September 17, 2024, 8:10am UTC](https://discourse.cmake.org/t/visual-studio-multi-config-solution/11633 "2024-09-17T08:10:29Z")

</div>

Hello, we are currently investigating switching from MPC (GitHub - DOCGroup/MPC: MPC (The Makefile, Project, and Workspace Creator)) to CMake. As a test, I am trying to convert a slightly larger C++ project to CMake. No…

---

## [Escaping for variable content in a add\_custom\_command](https://discourse.cmake.org/t/escaping-for-variable-content-in-a-add-custom-command/11700)

<div class="topic-metadata">

**Author:** [@pboettch](https://discourse.cmake.org/u/pboettch)\
**Replies:** 1\
**Last updated:** [September 17, 2024, 7:22am UTC](https://discourse.cmake.org/t/escaping-for-variable-content-in-a-add-custom-command/11700 "2024-09-17T07:22:31Z")

</div>

The following CMakeLists.txt: cmake\_minimum\_required(VERSION 3.30) project(ProjectName) set(F "Test with spaces and (parens)") add\_custom\_target(t ALL COMMAND doit ${F}) Generate the folloing command line: doit Test…

---

## [Adding quotes in a custom command](https://discourse.cmake.org/t/adding-quotes-in-a-custom-command/11662)

<div class="topic-metadata">

**Author:** [@artu72](https://discourse.cmake.org/u/artu72)\
**Replies:** 4\
**Last updated:** [September 16, 2024, 1:04pm UTC](https://discourse.cmake.org/t/adding-quotes-in-a-custom-command/11662 "2024-09-16T13:04:01Z")

</div>

Hi, in my project I need to read content from a file VERSION ( a simple string line without spaces or newlines ), adding quotes (") at begin and end of file, and write it in a new file VERSION\_Q. E.g, if VERSION is 3.0,…

---

## [installing a hpp file for reuse in a ubuntu laptop](https://discourse.cmake.org/t/installing-a-hpp-file-for-reuse-in-a-ubuntu-laptop/11666)

<div class="topic-metadata">

**Author:** [@Jonathan\_Dawsa](https://discourse.cmake.org/u/Jonathan_Dawsa)\
**Replies:** 4\
**Last updated:** [September 16, 2024, 11:30am UTC](https://discourse.cmake.org/t/installing-a-hpp-file-for-reuse-in-a-ubuntu-laptop/11666 "2024-09-16T11:30:11Z")

</div>

I wanna know how to install a header files on the computer the header file called ihead5.hpp is like this \`#include #include using namespace std; // void i5 (int a1,string s1) { /// a simple test fuction cout \<\< 20…

---

## [\--debug-find not showing paths searched for find\_library](https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687)

<div class="topic-metadata">

**Author:** [@jcm](https://discourse.cmake.org/u/jcm)\
**Replies:** 2\
**Last updated:** [September 15, 2024, 4:05pm UTC](https://discourse.cmake.org/t/debug-find-not-showing-paths-searched-for-find-library/11687 "2024-09-15T16:05:14Z")

</div>

(running CMake 3.30.2) I’m on macOS, and I have a call to find\_library that looks like so, inside a CMake find module FindMoltenVK.cmake: find\_library( MoltenVK\_LIBRARY NAMES MoltenVK HINTS ${PC\_MoltenVK\_LIBRARY\_…

---

## [In modern cmake, using many times include path for some function](https://discourse.cmake.org/t/in-modern-cmake-using-many-times-include-path-for-some-function/11688)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 0\
**Last updated:** [September 15, 2024, 8:58am UTC](https://discourse.cmake.org/t/in-modern-cmake-using-many-times-include-path-for-some-function/11688 "2024-09-15T08:58:54Z")

</div>

Using so many ${CMAKE\_CURRENT\_SOURCE\_DIR}/include in the code. Is it must be add the head file to these function? target\_sources target\_include\_directories set\_target\_properties

---

## [CMake does not seem to allow adding a project property sheet (Visual Studio) for each configuration (Debug and Release)](https://discourse.cmake.org/t/cmake-does-not-seem-to-allow-adding-a-project-property-sheet-visual-studio-for-each-configuration-debug-and-release/11684)

<div class="topic-metadata">

**Author:** [@dnguyen052924](https://discourse.cmake.org/u/dnguyen052924)\
**Replies:** 0\
**Last updated:** [September 14, 2024, 6:53pm UTC](https://discourse.cmake.org/t/cmake-does-not-seem-to-allow-adding-a-project-property-sheet-visual-studio-for-each-configuration-debug-and-release/11684 "2024-09-14T18:53:39Z")

</div>

I have 2 .props files, one is for Debug, and the other one is for Release. I’ve tried 2 ways below using generator expressions, but none of them works, no file is added/shown in the Property Manager window in Visual Stud…

---

## [Install DLL from imported package](https://discourse.cmake.org/t/install-dll-from-imported-package/11628)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 2\
**Last updated:** [September 14, 2024, 12:32pm UTC](https://discourse.cmake.org/t/install-dll-from-imported-package/11628 "2024-09-14T12:32:35Z")

</div>

Hello, In my project, I use thye package Xerces-C++. So I do : find\_package(XercesC 3.2.5 CONFIG REQUIRED) if(XercesC\_FOUND) message(STATUS "@@@@@@@@@@@@@@@@ Xerces found") message(STATUS "@@@@@@@@@@@@@@@@ Xer…

---

## [Creating a win32 window in VS '19 with cmake](https://discourse.cmake.org/t/creating-a-win32-window-in-vs-19-with-cmake/11552)

<div class="topic-metadata">

**Author:** [@catsonmars](https://discourse.cmake.org/u/catsonmars)\
**Replies:** 13\
**Last updated:** [September 13, 2024, 7:28pm UTC](https://discourse.cmake.org/t/creating-a-win32-window-in-vs-19-with-cmake/11552 "2024-09-13T19:28:39Z")

</div>

What I’ve tried. Just creating a win32 window in c++. Was pretty straightforward, the only configuring that needed to be done was project: properties → Linker -\>system → sub system → windows Now for the next step, integ…

---

## [CMAKE\_SHARED\_LIBRARY\_SUFFIX in script processing (-P) mode](https://discourse.cmake.org/t/cmake-shared-library-suffix-in-script-processing-p-mode/11646)

<div class="topic-metadata">

**Author:** [@starseeker](https://discourse.cmake.org/u/starseeker)\
**Replies:** 3\
**Last updated:** [September 12, 2024, 7:11pm UTC](https://discourse.cmake.org/t/cmake-shared-library-suffix-in-script-processing-p-mode/11646 "2024-09-12T19:11:46Z")

</div>

When I use cmake in -P mode (i.e. executing a script .cmake file) the standard CMake variable for shared library suffixes doesn’t seem to be defined: ~ $ more libsuffix.cmake message("CMAKE\_SHARED\_LIBRARY\_SUFFIX: ${CMA…

---

## [CMAKE\_INSTALL\_FULL\_LIBDIR can't change the absolute path by CMAKE\_INSTALL\_PREFIX](https://discourse.cmake.org/t/cmake-install-full-libdir-cant-change-the-absolute-path-by-cmake-install-prefix/11650)

<div class="topic-metadata">

**Author:** [@xwj1998](https://discourse.cmake.org/u/xwj1998)\
**Replies:** 1\
**Last updated:** [September 12, 2024, 7:45am UTC](https://discourse.cmake.org/t/cmake-install-full-libdir-cant-change-the-absolute-path-by-cmake-install-prefix/11650 "2024-09-12T07:45:38Z")

</div>

include(GNUInstallDirs) set\_property(CACHE CMAKE\_INSTALL\_PREFIX PREOPERTY VALUE "/usr/lib/x86\_64-linux-gnu") message(STATUS "-----------------${CMAKE\_INSTALL\_FULL\_LIBDIR}") the output is: -----------------/usr/local/l…

---

## [find\_package(BLAS) fails to find Arm performance libraries](https://discourse.cmake.org/t/find-package-blas-fails-to-find-arm-performance-libraries/11645)

<div class="topic-metadata">

**Author:** [@AlinPahontu](https://discourse.cmake.org/u/AlinPahontu)\
**Replies:** 0\
**Last updated:** [September 11, 2024, 1:12pm UTC](https://discourse.cmake.org/t/find-package-blas-fails-to-find-arm-performance-libraries/11645 "2024-09-11T13:12:18Z")

</div>

I have just downloaded and installed latest APL (24.04) on my windows on arm device. I am currently just making some small tests, but cmake fails to find apl. To reproduce, here is my CMakeLists file: cmake\_minimum\_req…

---

## [Policy CMP0111 is not set: An imported target missing its location property fails during generation. Run "cmake --help-policy CMP0111" for policy details](https://discourse.cmake.org/t/policy-cmp0111-is-not-set-an-imported-target-missing-its-location-property-fails-during-generation-run-cmake-help-policy-cmp0111-for-policy-details/11642)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 1\
**Last updated:** [September 11, 2024, 8:15am UTC](https://discourse.cmake.org/t/policy-cmp0111-is-not-set-an-imported-target-missing-its-location-property-fails-during-generation-run-cmake-help-policy-cmp0111-for-policy-details/11642 "2024-09-11T08:15:40Z")

</div>

https://docs.opencv.org/4.x/db/df5/tutorial\_linux\_gcc\_cmake.html I just install the opencv with debug and follow the toturial to run opencv. windows cmake -G “Visual Studio 17 2022” \` It show the error. If I build …

---

## [OpenCV\_DIR created and bin folder with all dlls added do PATH for Windows](https://discourse.cmake.org/t/opencv-dir-created-and-bin-folder-with-all-dlls-added-do-path-for-windows/11640)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 1\
**Last updated:** [September 11, 2024, 7:44am UTC](https://discourse.cmake.org/t/opencv-dir-created-and-bin-folder-with-all-dlls-added-do-path-for-windows/11640 "2024-09-11T07:44:52Z")

</div>

under Windows all environment variables must be set correctly (i.e. OpenCV\_DIR created and bin folder with all dlls added do PATH). https://docs.opencv.org/4.x/db/df5/tutorial\_linux\_gcc\_cmake.html I follow the step to…

---

## [${SPDLOG\_LIBRARIES} vs spdlog:spdlog](https://discourse.cmake.org/t/spdlog-libraries-vs-spdlog-spdlog/11632)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 3\
**Last updated:** [September 11, 2024, 6:53am UTC](https://discourse.cmake.org/t/spdlog-libraries-vs-spdlog-spdlog/11632 "2024-09-11T06:53:51Z")

</div>

find\_library(SPDLOG\_LIBRARIES NAMES spdlog spdlogd REQUIRED ) # SPDLOG\_LIBRARIES is C:\\spdlog\\lib\\spdlogd.lib # can work target\_link\_libraries(test\_example PRIVATE spdlog::spdlog) # can't wo…

---

## [ExternalProject\_Add is not downloading the git repository](https://discourse.cmake.org/t/externalproject-add-is-not-downloading-the-git-repository/11608)

<div class="topic-metadata">

**Author:** [@PanAMD](https://discourse.cmake.org/u/PanAMD)\
**Replies:** 2\
**Last updated:** [September 9, 2024, 11:09pm UTC](https://discourse.cmake.org/t/externalproject-add-is-not-downloading-the-git-repository/11608 "2024-09-09T23:09:59Z")

</div>

Hey everyone, I’ve been having some issues with my cmake script. Specifically with the ExternalProject\_Add function, it seems like it is not being executed or rather it is being executed but the problem is that it is not…

---

## [add\_test handles empty strings differently from before?](https://discourse.cmake.org/t/add-test-handles-empty-strings-differently-from-before/11588)

<div class="topic-metadata">

**Author:** [@kees-jan](https://discourse.cmake.org/u/kees-jan)\
**Replies:** 11\
**Last updated:** [September 9, 2024, 12:18pm UTC](https://discourse.cmake.org/t/add-test-handles-empty-strings-differently-from-before/11588 "2024-09-09T12:18:08Z")

</div>

Hi, Consider the following minimal example: CMAKE\_MINIMUM\_REQUIRED(VERSION 3.20 FATAL\_ERROR) PROJECT(tt) set(include\_dirs) set(include\_dir\_options "$\<$\<BOOL:${include\_dirs}\>:-I;$\<JOIN:${include\_dirs},;-I;\>\>") enable…

---

## [Handling of IMPORTED targets and MSVC\_RUNTIME\_LIBRARY](https://discourse.cmake.org/t/handling-of-imported-targets-and-msvc-runtime-library/11618)

<div class="topic-metadata">

**Author:** [@nappl](https://discourse.cmake.org/u/nappl)\
**Replies:** 0\
**Last updated:** [September 9, 2024, 4:54am UTC](https://discourse.cmake.org/t/handling-of-imported-targets-and-msvc-runtime-library/11618 "2024-09-09T04:54:03Z")

</div>

I have a set of header files for a static library along with multiple implementations for different operating systems and build configurations - these include the 4 MSVC runtime library configurations for Windows (md, md…

---

## [First CMakeLists.txt feedback please](https://discourse.cmake.org/t/first-cmakelists-txt-feedback-please/11606)

<div class="topic-metadata">

**Author:** [@RWobben](https://discourse.cmake.org/u/RWobben)\
**Replies:** 5\
**Last updated:** [September 8, 2024, 8:48am UTC](https://discourse.cmake.org/t/first-cmakelists-txt-feedback-please/11606 "2024-09-08T08:48:58Z")

</div>

Hello, I try to learn c++ by doing this course : https://www.learncpp.com/ Now I like to use CMake instead of doing all by myself. So I have a directory that contains : main.cpp io.cpp io.h Is this a good CMakeLis…

---

## [Avoid duplicate linking to avoid Xcode 15 warnings](https://discourse.cmake.org/t/avoid-duplicate-linking-to-avoid-xcode-15-warnings/9084)

<div class="topic-metadata">

**Author:** [@szhorvat](https://discourse.cmake.org/u/szhorvat)\
**Replies:** 11\
**Last updated:** [September 6, 2024, 5:04pm UTC](https://discourse.cmake.org/t/avoid-duplicate-linking-to-avoid-xcode-15-warnings/9084 "2024-09-06T17:04:47Z")

</div>

Xcode 15 includes a new linker which complains when passing a static library more than once to the linker. What do we need to pay attention to to prevent CMake from duplicating libraries? What is a convenient way to det…

---

## [No known features for CXX compiler "GNU" version 12.3.1 (arm-none-eabi)](https://discourse.cmake.org/t/no-known-features-for-cxx-compiler-gnu-version-12-3-1-arm-none-eabi/10797)

<div class="topic-metadata">

**Author:** [@Bjorn\_Johansson](https://discourse.cmake.org/u/Bjorn_Johansson)\
**Replies:** 7\
**Last updated:** [August 29, 2024, 8:50pm UTC](https://discourse.cmake.org/t/no-known-features-for-cxx-compiler-gnu-version-12-3-1-arm-none-eabi/10797 "2024-08-29T20:50:51Z")

</div>

Hi, We are cross-compiling C++20 for an ARM AArch32 bare-metal target (arm-none-eabi). This usually works fine. However, when we try to include the fmt library (GitHub - fmtlib/fmt: A modern formatting library version 1…

---

## [Need help to add unit test with googletest for a Cortex M0](https://discourse.cmake.org/t/need-help-to-add-unit-test-with-googletest-for-a-cortex-m0/11542)

<div class="topic-metadata">

**Author:** [@gibsonprs](https://discourse.cmake.org/u/gibsonprs)\
**Replies:** 0\
**Last updated:** [August 28, 2024, 6:13pm UTC](https://discourse.cmake.org/t/need-help-to-add-unit-test-with-googletest-for-a-cortex-m0/11542 "2024-08-28T18:13:07Z")

</div>

Good afternoon, I just discover googletest and i am a newbie on it. I have a project devlopped for cortexM0 . The build environment is linux through CMake… The project used a gcc -arm compiler. I am trying to add uni…

---

## [Custom language: Designing a thin wrapper for pre-compilers](https://discourse.cmake.org/t/custom-language-designing-a-thin-wrapper-for-pre-compilers/8456)

<div class="topic-metadata">

**Author:** [@Lecris](https://discourse.cmake.org/u/Lecris)\
**Replies:** 3\
**Last updated:** [August 26, 2024, 6:58am UTC](https://discourse.cmake.org/t/custom-language-designing-a-thin-wrapper-for-pre-compilers/8456 "2024-08-26T06:58:12Z")

</div>

This is related to fypp which has been brought up a few time around here. I’ve been reading about this implementation, and it got me thinking if it’s possible to design a simple language wrapper. I have been considering …

---

## [STATIC LIBARY - with an outside header file](https://discourse.cmake.org/t/static-libary-with-an-outside-header-file/11498)

<div class="topic-metadata">

**Author:** [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)\
**Replies:** 1\
**Last updated:** [August 22, 2024, 11:48am UTC](https://discourse.cmake.org/t/static-libary-with-an-outside-header-file/11498 "2024-08-22T11:48:22Z")

</div>

Generally - the idea as I understand is this: A static library should be very self contained. But in my case I can’t do that. Reason: In an embedded target, I need to highly taylor the static library for the end appli…

---

## [Build Directory as Surrogate for installation](https://discourse.cmake.org/t/build-directory-as-surrogate-for-installation/11497)

<div class="topic-metadata">

**Author:** [@Dylan\_Reedy](https://discourse.cmake.org/u/Dylan_Reedy)\
**Replies:** 4\
**Last updated:** [August 22, 2024, 6:53am UTC](https://discourse.cmake.org/t/build-directory-as-surrogate-for-installation/11497 "2024-08-22T06:53:20Z")

</div>

Hello, I work in a context where we occasionally deploy source code to “customers”. We also have several plugins that link against the main software package that are actively developed. In both cases, its desirable to u…

---

## [Assistance Needed for Creating a Shared Library with CMake](https://discourse.cmake.org/t/assistance-needed-for-creating-a-shared-library-with-cmake/11483)

<div class="topic-metadata">

**Author:** [@Umer](https://discourse.cmake.org/u/Umer)\
**Replies:** 12\
**Last updated:** [August 20, 2024, 9:53am UTC](https://discourse.cmake.org/t/assistance-needed-for-creating-a-shared-library-with-cmake/11483 "2024-08-20T09:53:17Z")

</div>

I need some guidance on creating a shared library using CMake. My C++ project is already configured in Visual Studio, with the target set to generate a DLL library. I now need to create a shared library using the same C+…

---

## [try\_compile generated temporary targets don't honor link\_libraries.](https://discourse.cmake.org/t/try-compile-generated-temporary-targets-dont-honor-link-libraries/4767)

<div class="topic-metadata">

**Author:** [@Amos\_Bird](https://discourse.cmake.org/u/Amos_Bird)\
**Replies:** 1\
**Last updated:** [August 20, 2024, 6:46am UTC](https://discourse.cmake.org/t/try-compile-generated-temporary-targets-dont-honor-link-libraries/4767 "2024-08-20T06:46:04Z")

</div>

Hello! My project has a global link\_libraries call which introduces a different libcxx headers and standard libs. It works fine for all my code and dependencies. However, things like CheckTypeSize and CheckFunctionExists…

---

## [install - wrong files, wrong location.](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481)

<div class="topic-metadata">

**Author:** [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)\
**Replies:** 5\
**Last updated:** [August 19, 2024, 9:10pm UTC](https://discourse.cmake.org/t/install-wrong-files-wrong-location/11481 "2024-08-19T21:10:11Z")

</div>

Is there a way to control the list of files installed? when “make install” occurs? A) I have an embedded target - so nothing really gets installed. Instead my CI/CD process says: put all important files in THIS directo…

---

## [find\_package(Python3) is not finding the correct python](https://discourse.cmake.org/t/find-package-python3-is-not-finding-the-correct-python/10563)

<div class="topic-metadata">

**Author:** [@mdorier](https://discourse.cmake.org/u/mdorier)\
**Replies:** 10\
**Last updated:** [August 19, 2024, 4:00pm UTC](https://discourse.cmake.org/t/find-package-python3-is-not-finding-the-correct-python/10563 "2024-08-19T16:00:56Z")

</div>

I have the following minimal CMakeLists.txt: cmake\_minimum\_required (VERSION 3.8) project (myproject C CXX) find\_package (Python3 COMPONENTS Interpreter Development REQUIRED) I use spack (https://spack.io/) to manage m…

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

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