# Code

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

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

**Page:** 73

---

## [library RPATH resolution](https://discourse.cmake.org/t/library-rpath-resolution/887)

<div class="topic-metadata">

**Author:** [@OlegWorld](https://discourse.cmake.org/u/OlegWorld)\
**Replies:** 6\
**Last updated:** [March 31, 2020, 12:27pm UTC](https://discourse.cmake.org/t/library-rpath-resolution/887 "2020-03-31T12:27:41Z")

</div>

Let’s say we have a library A, which depends on library B. Library A is built using cmake and library B is linked to it publicly using target\_link\_libraries(…) Now i want to build an executable target, which depends on …

---

## [Custom location for not found library libmpfr.so.4](https://discourse.cmake.org/t/custom-location-for-not-found-library-libmpfr-so-4/877)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 0\
**Last updated:** [March 27, 2020, 10:01pm UTC](https://discourse.cmake.org/t/custom-location-for-not-found-library-libmpfr-so-4/877 "2020-03-27T22:01:35Z")

</div>

I’m trying to solve the “classic” issue of compiling with gnu 4.4 on Bionic, which means that libmpfr.so.4 is not found and the build fails immediately on the compiler check. However libmpfr is available in a custom loca…

---

## [Can't find fltk library with cmake (ERROR)](https://discourse.cmake.org/t/cant-find-fltk-library-with-cmake-error/867)

<div class="topic-metadata">

**Author:** [@Mrityunjay\_Jha](https://discourse.cmake.org/u/Mrityunjay_Jha)\
**Replies:** 2\
**Last updated:** [March 27, 2020, 11:49am UTC](https://discourse.cmake.org/t/cant-find-fltk-library-with-cmake-error/867 "2020-03-27T11:49:46Z")

</div>

I am not able to link fltk library using cmake script.Here is my CMakeLists.txt file: cmake\_minimum\_required(VERSION 3.16.5) SET(CMake\_C\_Compiler\_Works 1) SET(CMake\_CXX\_Compiler\_Works 1) project(Windows) find\_package( …

---

## [Dynamically generating add\_custom\_command dependencies during build time](https://discourse.cmake.org/t/dynamically-generating-add-custom-command-dependencies-during-build-time/865)

<div class="topic-metadata">

**Author:** [@davis291](https://discourse.cmake.org/u/davis291)\
**Replies:** 2\
**Last updated:** [March 27, 2020, 10:59am UTC](https://discourse.cmake.org/t/dynamically-generating-add-custom-command-dependencies-during-build-time/865 "2020-03-27T10:59:26Z")

</div>

We have a code base that we are trying to convert from autotools to cmake. This project builds both c++ libraries and a python interface. The python interface/module is generated by python scripts during the build using …

---

## [RPATH not set, but necessary](https://discourse.cmake.org/t/rpath-not-set-but-necessary/861)

<div class="topic-metadata">

**Author:** [@CodingNickNick](https://discourse.cmake.org/u/CodingNickNick)\
**Replies:** 8\
**Last updated:** [March 26, 2020, 2:44pm UTC](https://discourse.cmake.org/t/rpath-not-set-but-necessary/861 "2020-03-26T14:44:53Z")

</div>

I am linking an imported target against an executable, but the RPATH of the resulting executable is not set up correctly: when I run it, I get the ‘image not found’ error for this library. When I manually set the BUILD\_R…

---

## [CMake cannot find MPI in standard installation path](https://discourse.cmake.org/t/cmake-cannot-find-mpi-in-standard-installation-path/850)

<div class="topic-metadata">

**Author:** [@Crownk](https://discourse.cmake.org/u/Crownk)\
**Replies:** 6\
**Last updated:** [March 25, 2020, 1:07pm UTC](https://discourse.cmake.org/t/cmake-cannot-find-mpi-in-standard-installation-path/850 "2020-03-25T13:07:55Z")

</div>

The following is my CMakeLists.txt file and actually it works well on my server4. However, I tried to configure it on my server3 and then it could not find the MPI package. project(CUDA\_MPI LANGUAGES CXX CUDA) set(CMAK…

---

## [FindBoost difference between Boost\_INCLUDE\_DIR and Boost\_INCLUDE\_DIRS](https://discourse.cmake.org/t/findboost-difference-between-boost-include-dir-and-boost-include-dirs/855)

<div class="topic-metadata">

**Author:** [@MonkeyBreaker](https://discourse.cmake.org/u/MonkeyBreaker)\
**Replies:** 3\
**Last updated:** [March 25, 2020, 12:56pm UTC](https://discourse.cmake.org/t/findboost-difference-between-boost-include-dir-and-boost-include-dirs/855 "2020-03-25T12:56:00Z")

</div>

Hi everyone, Question is about the difference of using Boost\_INCLUDE\_DIR and Boost\_INCLUDE\_DIRS to indicate where boost header files are in the system. As I understood so far from the documentation and from different p…

---

## [How to create reliable command-line configured argument dependencies for custom commands?](https://discourse.cmake.org/t/how-to-create-reliable-command-line-configured-argument-dependencies-for-custom-commands/842)

<div class="topic-metadata">

**Author:** [@airwin](https://discourse.cmake.org/u/airwin)\
**Replies:** 3\
**Last updated:** [March 25, 2020, 11:49am UTC](https://discourse.cmake.org/t/how-to-create-reliable-command-line-configured-argument-dependencies-for-custom-commands/842 "2020-03-25T11:49:24Z")

</div>

I have a build system use case (building the 5 papers that currently describe FreeEOS) where the custom commands that are run to generate plots for the papers have a configurable argument (the name of the PLplot devic…

---

## [Installing CMake package config files for MacOS frameworks](https://discourse.cmake.org/t/installing-cmake-package-config-files-for-macos-frameworks/849)

<div class="topic-metadata">

**Author:** [@vre](https://discourse.cmake.org/u/vre)\
**Replies:** 5\
**Last updated:** [March 24, 2020, 10:26pm UTC](https://discourse.cmake.org/t/installing-cmake-package-config-files-for-macos-frameworks/849 "2020-03-24T22:26:56Z")

</div>

I created a versioned MacOS framework with CMake and stumbled over the question where to install the package config files sample-config.cmake, sample-config-version.cmake, sample-exports.cmake, sample-exports-release.cma…

---

## [How to limit C\_FLAGS to certain libraries](https://discourse.cmake.org/t/how-to-limit-c-flags-to-certain-libraries/853)

<div class="topic-metadata">

**Author:** [@Allen](https://discourse.cmake.org/u/Allen)\
**Replies:** 1\
**Last updated:** [March 24, 2020, 3:27pm UTC](https://discourse.cmake.org/t/how-to-limit-c-flags-to-certain-libraries/853 "2020-03-24T15:27:14Z")

</div>

We are trying to reduce warnings in our code base by promoting some warnings to errors. We build the list of warnings during configure time and add them to CMAKE\_C\_FLAGS. This was fine until we started implementing the…

---

## [ARM64 doesn't work with ExternalProject\_Add command](https://discourse.cmake.org/t/arm64-doesnt-work-with-externalproject-add-command/846)

<div class="topic-metadata">

**Author:** [@ugurkanates](https://discourse.cmake.org/u/ugurkanates)\
**Replies:** 1\
**Last updated:** [March 23, 2020, 12:23pm UTC](https://discourse.cmake.org/t/arm64-doesnt-work-with-externalproject-add-command/846 "2020-03-23T12:23:53Z")

</div>

cmake\_minimum\_required(VERSION 3.0) project(TestMe) set(CMAKE\_CXX\_STANDARD 11) find\_package(Boost REQUIRED COMPONENTS system thread filesystem) set(EXTERNAL\_INSTALL\_LOCATION ${CMAKE\_BINARY\_DIR}/external) include(Externa…

---

## [Why toplevel Cmake can't clean custom project add by ExternProject\_add](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824)

<div class="topic-metadata">

**Author:** [@lijianzhong](https://discourse.cmake.org/u/lijianzhong)\
**Replies:** 3\
**Last updated:** [March 23, 2020, 11:31am UTC](https://discourse.cmake.org/t/why-toplevel-cmake-cant-clean-custom-project-add-by-externproject-add/824 "2020-03-23T11:31:23Z")

</div>

\[Cmake 3.16.4\] I use ExternalProject\_Add command to add a custom project. The generate make file can build and link correctly. But when I use make clean to clean the project , the custom project cant not be cleaned. The…

---

## [NSIS PATH too long, how to use EnVar plugin?](https://discourse.cmake.org/t/nsis-path-too-long-how-to-use-envar-plugin/839)

<div class="topic-metadata">

**Author:** [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)\
**Replies:** 5\
**Last updated:** [March 22, 2020, 3:40pm UTC](https://discourse.cmake.org/t/nsis-path-too-long-how-to-use-envar-plugin/839 "2020-03-22T15:40:44Z")

</div>

I’ve built a Windows installer using NSIS, cross compiling from Linux using MinGW and the Linux nsis package (Ubuntu 19.10). This works great, but if the user’s PATH exceeds 1024 characters the application cannot be add…

---

## [how to write '@' in configure\_file( "" @ONLY )](https://discourse.cmake.org/t/how-to-write-in-configure-file-only/829)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [March 20, 2020, 3:20pm UTC](https://discourse.cmake.org/t/how-to-write-in-configure-file-only/829 "2020-03-20T15:20:48Z")

</div>

how to write ‘@’ in configure\_file( "@" @ONLY ) ? input\_file has the following content: @ I tried configure\_file( "input\_file" @ONLY ) but am receiving \\@.

---

## [When does CMAKE\_CURRENT\_BINARY\_DIR resolve symlinks?](https://discourse.cmake.org/t/when-does-cmake-current-binary-dir-resolve-symlinks/809)

<div class="topic-metadata">

**Author:** [@sdettmer](https://discourse.cmake.org/u/sdettmer)\
**Replies:** 2\
**Last updated:** [March 17, 2020, 5:52pm UTC](https://discourse.cmake.org/t/when-does-cmake-current-binary-dir-resolve-symlinks/809 "2020-03-17T17:52:27Z")

</div>

Hi, I have a project in a directory where two directory components are symbolic links (to directories). Normally I’m use to see CMAKE\_\* paths to be “logical” (i.e. what “pwd -L” shows). However, under circumstances some…

---

## [ExternalProject, superbuilds and Visual Studio](https://discourse.cmake.org/t/externalproject-superbuilds-and-visual-studio/794)

<div class="topic-metadata">

**Author:** [@Zomgrolf](https://discourse.cmake.org/u/Zomgrolf)\
**Replies:** 3\
**Last updated:** [March 16, 2020, 6:33pm UTC](https://discourse.cmake.org/t/externalproject-superbuilds-and-visual-studio/794 "2020-03-16T18:33:54Z")

</div>

I could use some help with properly setting up my project in CMake. The main platform is Visual Studio on Windows (but it would be nice to have something portable that works on other systems, esp. Linux + Ninja + gcc). W…

---

## [unable to get target location](https://discourse.cmake.org/t/unable-to-get-target-location/797)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 5\
**Last updated:** [March 13, 2020, 12:51pm UTC](https://discourse.cmake.org/t/unable-to-get-target-location/797 "2020-03-13T12:51:51Z")

</div>

I am getting a location not found for my custom target. Here is the code snippet: cmake\_minimum\_required( VERSION 3.17 ) project(Debug) add\_custom\_target(tgt ALL) get\_target\_property( TGT\_LOCATION tgt LOCATION ) mess…

---

## [Does the target\_include\_directories() command strip out duplicate paths added?](https://discourse.cmake.org/t/does-the-target-include-directories-command-strip-out-duplicate-paths-added/769)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 11\
**Last updated:** [March 9, 2020, 5:28pm UTC](https://discourse.cmake.org/t/does-the-target-include-directories-command-strip-out-duplicate-paths-added/769 "2020-03-09T17:28:32Z")

</div>

Yes, it does (BUT as good it can); see the following exemple project: cmake\_minimum\_required(VERSION 3.8 FATAL\_ERROR) project(test C) file(WRITE ${CMAKE\_BINARY\_DIR}/main.c "int main(void){return 0;}\\n") add\_executable(…

---

## [How to create file-dependency for all sources of target?](https://discourse.cmake.org/t/how-to-create-file-dependency-for-all-sources-of-target/706)

<div class="topic-metadata">

**Author:** [@pboettch](https://discourse.cmake.org/u/pboettch)\
**Replies:** 5\
**Last updated:** [March 5, 2020, 3:59pm UTC](https://discourse.cmake.org/t/how-to-create-file-dependency-for-all-sources-of-target/706 "2020-03-05T15:59:15Z")

</div>

I have different use-cases where I would like to declare a file-dependency at target-level, be it generated or in the sources, which influences the compile-process for all sources of this target. Imagine a configuration…

---

## [Scoped enable\_language](https://discourse.cmake.org/t/scoped-enable-language/766)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 2\
**Last updated:** [March 5, 2020, 8:05am UTC](https://discourse.cmake.org/t/scoped-enable-language/766 "2020-03-05T08:05:42Z")

</div>

I have a project in language A with most toolchain files also in A. If built with unittests then there is one or two subdirectories in language B included. One single toolchain is also in language B. Depending on an o…

---

## [iOS resource management](https://discourse.cmake.org/t/ios-resource-management/758)

<div class="topic-metadata">

**Author:** [@cycollins](https://discourse.cmake.org/u/cycollins)\
**Replies:** 6\
**Last updated:** [March 4, 2020, 11:35pm UTC](https://discourse.cmake.org/t/ios-resource-management/758 "2020-03-04T23:35:14Z")

</div>

There are facilities in Cmake for hinting source code to be treated as resources for an iOS App, and that works modestly well. When you generate an Xcode project, the code behavior is close to being right. You get a proj…

---

## [Issue with the install phase of package](https://discourse.cmake.org/t/issue-with-the-install-phase-of-package/721)

<div class="topic-metadata">

**Author:** [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Replies:** 12\
**Last updated:** [March 3, 2020, 6:34pm UTC](https://discourse.cmake.org/t/issue-with-the-install-phase-of-package/721 "2020-03-03T18:34:24Z")

</div>

Currently, for windows, I use a local installation area. Between Qt, and other 3rd party shared libraries, its difficult to have a user create installation otherwise. To do so, I have used for sometime, and it works gr…

---

## [How to avoid parallel-build race conditions?](https://discourse.cmake.org/t/how-to-avoid-parallel-build-race-conditions/727)

<div class="topic-metadata">

**Author:** [@airwin](https://discourse.cmake.org/u/airwin)\
**Replies:** 12\
**Last updated:** [March 2, 2020, 8:10pm UTC](https://discourse.cmake.org/t/how-to-avoid-parallel-build-race-conditions/727 "2020-03-02T20:10:20Z")

</div>

The documentation of add\_custom\_command states (in part) the following: “Do not list the output in more than one independent target that may build in parallel or the two instances of the rule may conflict (instead use…

---

## [How to use CMakePackageConfigHelpers right?](https://discourse.cmake.org/t/how-to-use-cmakepackageconfighelpers-right/660)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 8\
**Last updated:** [February 29, 2020, 9:36am UTC](https://discourse.cmake.org/t/how-to-use-cmakepackageconfighelpers-right/660 "2020-02-29T09:36:41Z")

</div>

When I try to use it like here https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#example-generating-package-files I run into problems. Using cmake version 3.16.3 on OSX and debian, same result. …

---

## [Testing targets with shared libraries on Windows](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707)

<div class="topic-metadata">

**Author:** [@alex](https://discourse.cmake.org/u/alex)\
**Replies:** 3\
**Last updated:** [February 28, 2020, 8:43pm UTC](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707 "2020-02-28T20:43:54Z")

</div>

I have a working build and test set up on Linux (yay!) but Windows continues to pose challenges. Everything builds fine, but all tests fail with “MyProj.dll” not found! I suppose this is because they are in different di…

---

## [Pull a custom target to earlier in the parallel build](https://discourse.cmake.org/t/pull-a-custom-target-to-earlier-in-the-parallel-build/703)

<div class="topic-metadata">

**Author:** [@Lance\_E\_T\_Compte](https://discourse.cmake.org/u/Lance_E_T_Compte)\
**Replies:** 3\
**Last updated:** [February 28, 2020, 8:31pm UTC](https://discourse.cmake.org/t/pull-a-custom-target-to-earlier-in-the-parallel-build/703 "2020-02-28T20:31:02Z")

</div>

I’ve a project with about 3500 targets, building with ninja in parallel on machines with between 4 and 8 cores. One of these targets takes quite a long time, and that slows the entire build, since, for whatever reason, …

---

## [warnings in the configure process](https://discourse.cmake.org/t/warnings-in-the-configure-process/705)

<div class="topic-metadata">

**Author:** [@ORI\_HECHT](https://discourse.cmake.org/u/ORI_HECHT)\
**Replies:** 1\
**Last updated:** [February 28, 2020, 8:18pm UTC](https://discourse.cmake.org/t/warnings-in-the-configure-process/705 "2020-02-28T20:18:42Z")

</div>

I am getting the following warning when configuring a project that compiles C++ files from different directories - source directory … has no common path with … What importance is there in this warning? How can I su…

---

## [\`install()\`-ing a static library also requires installing an internal object library?](https://discourse.cmake.org/t/install-ing-a-static-library-also-requires-installing-an-internal-object-library/683)

<div class="topic-metadata">

**Author:** [@alex](https://discourse.cmake.org/u/alex)\
**Replies:** 5\
**Last updated:** [February 28, 2020, 8:17pm UTC](https://discourse.cmake.org/t/install-ing-a-static-library-also-requires-installing-an-internal-object-library/683 "2020-02-28T20:17:58Z")

</div>

I have two directories, src and src/runtime, which each contain their own CMakeLists.txt. src contains my main target. runtime contains a large number of files which are (in a series of steps) transformed into .cpp files…

---

## [Question about internal headers and idiomatic CMake use](https://discourse.cmake.org/t/question-about-internal-headers-and-idiomatic-cmake-use/668)

<div class="topic-metadata">

**Author:** [@Michael\_K](https://discourse.cmake.org/u/Michael_K)\
**Replies:** 1\
**Last updated:** [February 28, 2020, 7:44pm UTC](https://discourse.cmake.org/t/question-about-internal-headers-and-idiomatic-cmake-use/668 "2020-02-28T19:44:44Z")

</div>

Hey, I’m quite new to CMake and try make a project with CMake. I need some hints / suggestions on how to make this as easy and as idiomatic as possible (so not to burden possible future users with bad CMake code). My pr…

---

## [CMAKE\_CONFIGURE\_DEPENDS with newly created file](https://discourse.cmake.org/t/cmake-configure-depends-with-newly-created-file/663)

<div class="topic-metadata">

**Author:** [@Leherenn](https://discourse.cmake.org/u/Leherenn)\
**Replies:** 1\
**Last updated:** [February 28, 2020, 7:40pm UTC](https://discourse.cmake.org/t/cmake-configure-depends-with-newly-created-file/663 "2020-02-28T19:40:51Z")

</div>

I have some code that is auto generated externally using another script. Let’s say this generated in resources. In there, there is a “README.TXT” file with the generation timestamp, so the file changes every time the ge…

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

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