# Usage

**URL:** https://discourse.cmake.org/c/usage/12.md?page=89

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

**Page:** 90

---

## [add dependinfo to custom target](https://discourse.cmake.org/t/add-dependinfo-to-custom-target/1276)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [November 9, 2020, 9:39pm UTC](https://discourse.cmake.org/t/add-dependinfo-to-custom-target/1276 "2020-11-09T21:39:29Z")

</div>

When I set an executable: enable\_language(CXX) add\_executable( MyProj\_MyExe2 main.cc ) CMake populates CMAKE\_DEPENDS\_LANGUAGES in DependInfo.cmake: # The set of languages for which implicit dependencies are needed: se…

---

## [Fail cmake if there are unused variables defined](https://discourse.cmake.org/t/fail-cmake-if-there-are-unused-variables-defined/840)

<div class="topic-metadata">

**Author:** [@shukron](https://discourse.cmake.org/u/shukron)\
**Replies:** 2\
**Last updated:** [November 9, 2020, 8:32pm UTC](https://discourse.cmake.org/t/fail-cmake-if-there-are-unused-variables-defined/840 "2020-11-09T20:32:43Z")

</div>

Hi all! I want make cmake fail if there are some unused variables defined. Currently I do get a warning, but I couldn’t find a way to cause cmake exit with non-zero return value. For example, I want the following invo…

---

## [Automatically detecting generated dependencies](https://discourse.cmake.org/t/automatically-detecting-generated-dependencies/1183)

<div class="topic-metadata">

**Author:** [@chris.olton](https://discourse.cmake.org/u/chris.olton)\
**Replies:** 7\
**Last updated:** [November 9, 2020, 8:25pm UTC](https://discourse.cmake.org/t/automatically-detecting-generated-dependencies/1183 "2020-11-09T20:25:45Z")

</div>

Our project has multiple source files and multiple generated header files (in addition to non-generated header files if that matters). These source files variously depend on these generated header files. How can I get cm…

---

## [Wildcards in PATHS or HINTS in find\_file, file\_path, etc.](https://discourse.cmake.org/t/wildcards-in-paths-or-hints-in-find-file-file-path-etc/975)

<div class="topic-metadata">

**Author:** [@e\_ensafi](https://discourse.cmake.org/u/e_ensafi)\
**Replies:** 5\
**Last updated:** [November 9, 2020, 8:07pm UTC](https://discourse.cmake.org/t/wildcards-in-paths-or-hints-in-find-file-file-path-etc/975 "2020-11-09T20:07:44Z")

</div>

Hi, The following seems to work, but as far as I can see, the documentation does not indicate that wildcards are legal: # I have a file called /Path/To/Stuff/Under/Other/Stuff/MyFile.txt SET(MY\_ROOT\_DIR /Path/To/Stuff)…

---

## [CTest library path](https://discourse.cmake.org/t/ctest-library-path/1236)

<div class="topic-metadata">

**Author:** [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)\
**Replies:** 1\
**Last updated:** [November 9, 2020, 7:48pm UTC](https://discourse.cmake.org/t/ctest-library-path/1236 "2020-11-09T19:48:18Z")

</div>

Hi all, I have a working build, in which I have several tests as well. On a specific environment I use a build in which several of the linked libraries are in atypical directories. Using the CMAKE\_FIND\_ROOT\_PATH this is…

---

## [Short target names and exports](https://discourse.cmake.org/t/short-target-names-and-exports/2107)

<div class="topic-metadata">

**Author:** [@eiband](https://discourse.cmake.org/u/eiband)\
**Replies:** 2\
**Last updated:** [November 2, 2020, 7:45pm UTC](https://discourse.cmake.org/t/short-target-names-and-exports/2107 "2020-11-02T19:45:11Z")

</div>

Is it okay to use short target names such as “base” in libraries as long as they are unique to the library? The imported targets are made unique with a namespace prefix, e.g. Prefix::base. Background: Target names could…

---

## [How to set target's compiler preprocessor flags?](https://discourse.cmake.org/t/how-to-set-targets-compiler-preprocessor-flags/2094)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 3\
**Last updated:** [October 30, 2020, 11:47pm UTC](https://discourse.cmake.org/t/how-to-set-targets-compiler-preprocessor-flags/2094 "2020-10-30T23:47:49Z")

</div>

I want to compile ‘C’ source file, defining HAVE\_CONFIG\_H to the C preprocessor. E.g. if gcc is the compiler, I want to pass -DHAVE\_CONFIG\_H to the compiler. What is the correct portable way to do this, using target\_comp…

---

## [target\_link\_libraries() requires full path for some but not all project libraries?](https://discourse.cmake.org/t/target-link-libraries-requires-full-path-for-some-but-not-all-project-libraries/2097)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 3\
**Last updated:** [October 30, 2020, 11:47pm UTC](https://discourse.cmake.org/t/target-link-libraries-requires-full-path-for-some-but-not-all-project-libraries/2097 "2020-10-30T23:47:15Z")

</div>

My project builds several libraries, then links them to generate an executable. When calling target\_link\_libraries() for the executable, some - but not all - of the project libraries must be specified with full path ${CM…

---

## [Skipping CMake compiler checks](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079)

<div class="topic-metadata">

**Author:** [@mensinda](https://discourse.cmake.org/u/mensinda)\
**Replies:** 10\
**Last updated:** [October 29, 2020, 6:01pm UTC](https://discourse.cmake.org/t/skipping-cmake-compiler-checks/2079 "2020-10-29T18:01:26Z")

</div>

The use case I am interested in is improving the CMake dependency lookup mechanism in meson (not CMake subprojects but the CMake dependency / find\_package() backend). What we are currently doing for using the \*-config.cm…

---

## [Using cmake/ninja to batch cl invocations](https://discourse.cmake.org/t/using-cmake-ninja-to-batch-cl-invocations/1853)

<div class="topic-metadata">

**Author:** [@shuffle2](https://discourse.cmake.org/u/shuffle2)\
**Replies:** 8\
**Last updated:** [October 28, 2020, 7:21pm UTC](https://discourse.cmake.org/t/using-cmake-ninja-to-batch-cl-invocations/1853 "2020-10-28T19:21:26Z")

</div>

I’m trying to port a msbuild based project to cmake/ninja, and it seems like the ability to invoke the compiler with multiple source files is missing(?) Is there a way to have cmake generate ninja build files which will…

---

## [NOT TARGET meaning?](https://discourse.cmake.org/t/not-target-meaning/2085)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 1\
**Last updated:** [October 28, 2020, 6:01pm UTC](https://discourse.cmake.org/t/not-target-meaning/2085 "2020-10-28T18:01:38Z")

</div>

I see expressions like this in cmake files: if(NOT TARGET JSONUtils::JSONUtils) include("${JSONUtils\_CMAKE\_DIR}/JSONUtilsTargets.cmake") endif() What exactly does this mean? By itself I think “NOT TARGET” means var…

---

## [Initialize empty list](https://discourse.cmake.org/t/initialize-empty-list/2068)

<div class="topic-metadata">

**Author:** [@johan556](https://discourse.cmake.org/u/johan556)\
**Replies:** 2\
**Last updated:** [October 25, 2020, 9:38pm UTC](https://discourse.cmake.org/t/initialize-empty-list/2068 "2020-10-25T21:38:14Z")

</div>

What is the most idiomatic way to initialize an empty list? I have earlier used set(mylist) This works, when I later starts to append items to the list. But I recently understood that this actually “unset” the variable…

---

## [GENERATE\_NATIVE\_HEADERS target is not recognized as INTERFACE type](https://discourse.cmake.org/t/generate-native-headers-target-is-not-recognized-as-interface-type/2048)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 7\
**Last updated:** [October 23, 2020, 10:22pm UTC](https://discourse.cmake.org/t/generate-native-headers-target-is-not-recognized-as-interface-type/2048 "2020-10-23T22:22:10Z")

</div>

target\_include\_directories failed when target (myprojJNI below) is a target that was created by add\_jar GENERATE\_NATIVE\_HEADERS option. ERROR: CMake Error at …CMakeLists.txt:… (target\_include\_directories): target\_inc…

---

## [Continuing wisdom of disabling individual cmake generators on a platform-by-platform basis?](https://discourse.cmake.org/t/continuing-wisdom-of-disabling-individual-cmake-generators-on-a-platform-by-platform-basis/2044)

<div class="topic-metadata">

**Author:** [@stephene](https://discourse.cmake.org/u/stephene)\
**Replies:** 4\
**Last updated:** [October 22, 2020, 3:24pm UTC](https://discourse.cmake.org/t/continuing-wisdom-of-disabling-individual-cmake-generators-on-a-platform-by-platform-basis/2044 "2020-10-22T15:24:41Z")

</div>

Hi everyone, I would just like to raise awareness of a technical issue I have being having recently and start a discussion about this. I have the standard Windows GUI build of cmake 3.19 installed on my PC here and it s…

---

## [CMake not recognizing compiler on MacOS with Xcode Generator](https://discourse.cmake.org/t/cmake-not-recognizing-compiler-on-macos-with-xcode-generator/1169)

<div class="topic-metadata">

**Author:** [@Manav\_Bhatia](https://discourse.cmake.org/u/Manav_Bhatia)\
**Replies:** 3\
**Last updated:** [October 22, 2020, 12:27pm UTC](https://discourse.cmake.org/t/cmake-not-recognizing-compiler-on-macos-with-xcode-generator/1169 "2020-10-22T12:27:56Z")

</div>

Hi, I have installed CMake 3.17.1, gcc 9.3.0, openmpi 3.1.5 and other tools on my Mac (10.15.4) using spack. I am able to configure and build my code with the following options cmake ../ \\ -DMPI\_C\_COMPILER=mpicc -DMPI…

---

## [How do I specify different binaries to link against for Visual Studio debug and release, but be able to select either](https://discourse.cmake.org/t/how-do-i-specify-different-binaries-to-link-against-for-visual-studio-debug-and-release-but-be-able-to-select-either/2026)

<div class="topic-metadata">

**Author:** [@imlost](https://discourse.cmake.org/u/imlost)\
**Replies:** 7\
**Last updated:** [October 21, 2020, 4:22pm UTC](https://discourse.cmake.org/t/how-do-i-specify-different-binaries-to-link-against-for-visual-studio-debug-and-release-but-be-able-to-select-either/2026 "2020-10-21T16:22:25Z")

</div>

How do I specify in CMAKE that binary file A is for debug and B is for release when linking, but in such a way I can still toggle between the two in VS and not have to do cmake … each time I need to switch between the tw…

---

## [cmake/ctest generate Test.xml (without rebuilding?) / could not load cache](https://discourse.cmake.org/t/cmake-ctest-generate-test-xml-without-rebuilding-could-not-load-cache/2025)

<div class="topic-metadata">

**Author:** [@KantarBruceAdams](https://discourse.cmake.org/u/KantarBruceAdams)\
**Replies:** 0\
**Last updated:** [October 19, 2020, 2:58pm UTC](https://discourse.cmake.org/t/cmake-ctest-generate-test-xml-without-rebuilding-could-not-load-cache/2025 "2020-10-19T14:58:49Z")

</div>

I have a cmake based (C++) project which includes tests created via add\_test(). The build process is basically: cmake make all testsuite make test This has worked well for some time. I am now trying to get my build …

---

## [Building Alembic on Ubuntu : Could NOT find Boost](https://discourse.cmake.org/t/building-alembic-on-ubuntu-could-not-find-boost/1986)

<div class="topic-metadata">

**Author:** [@johhnry](https://discourse.cmake.org/u/johhnry)\
**Replies:** 2\
**Last updated:** [October 11, 2020, 9:56pm UTC](https://discourse.cmake.org/t/building-alembic-on-ubuntu-could-not-find-boost/1986 "2020-10-11T21:56:47Z")

</div>

Hi, I am trying to build the Alembic project which uses the FindBoost module to check if boost python is installed. The code responsible for doing that is in the alembic/cmake/AlembicBoost.cmake file which does the fol…

---

## [Help with Visual Studio Generator](https://discourse.cmake.org/t/help-with-visual-studio-generator/1957)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 5\
**Last updated:** [October 9, 2020, 8:59am UTC](https://discourse.cmake.org/t/help-with-visual-studio-generator/1957 "2020-10-09T08:59:50Z")

</div>

I have a CMake project that works fine on Linux and which I am now porting to Windows, where I want to build from the command line using the Visual Studio C++ tools. I initially used the Ninja generator on Windows but g…

---

## [$\<0\> genex doesn't evaluate argument, $\<IF\> evaluates both. Is that intentional?](https://discourse.cmake.org/t/0-genex-doesnt-evaluate-argument-if-evaluates-both-is-that-intentional/1960)

<div class="topic-metadata">

**Author:** [@Angew](https://discourse.cmake.org/u/Angew)\
**Replies:** 2\
**Last updated:** [October 2, 2020, 3:08pm UTC](https://discourse.cmake.org/t/0-genex-doesnt-evaluate-argument-if-evaluates-both-is-that-intentional/1960 "2020-10-02T15:08:09Z")

</div>

I’ve been hit by a difference between $\<0:x\> and $\<IF:c,x,y\> which I considered unexpected, and wanted to ask whether it’s intentional. In these example, assume target foo does not exist. Tested with CMake 3.18.3. The …

---

## [ATTACHED\_FILES](https://discourse.cmake.org/t/attached-files/1641)

<div class="topic-metadata">

**Author:** [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)\
**Replies:** 5\
**Last updated:** [October 1, 2020, 4:55pm UTC](https://discourse.cmake.org/t/attached-files/1641 "2020-10-01T16:55:09Z")

</div>

All, I am attaching some \*.svg files to a test for upload which appears to work except that when clicking on the attachment link in the dashboard I see an empty page… Are there limitations to what can be attached? Thou…

---

## [FindBLAS with Fujitsu libraries](https://discourse.cmake.org/t/findblas-with-fujitsu-libraries/1953)

<div class="topic-metadata">

**Author:** [@Sreepathi\_Sarat](https://discourse.cmake.org/u/Sreepathi_Sarat)\
**Replies:** 1\
**Last updated:** [October 1, 2020, 8:07am UTC](https://discourse.cmake.org/t/findblas-with-fujitsu-libraries/1953 "2020-10-01T08:07:11Z")

</div>

Hello: I’m trying to build a scientific application that uses cmake on Fugaku, the Japanese supercomputer which has A64FX Arm processors. This machine has Fujitsu compilers and scientific libraries that provide BLAS an…

---

## [Cmake configuration build fails on test big endian](https://discourse.cmake.org/t/cmake-configuration-build-fails-on-test-big-endian/1903)

<div class="topic-metadata">

**Author:** [@Oleg\_Karpenko](https://discourse.cmake.org/u/Oleg_Karpenko)\
**Replies:** 11\
**Last updated:** [September 28, 2020, 9:27pm UTC](https://discourse.cmake.org/t/cmake-configuration-build-fails-on-test-big-endian/1903 "2020-09-28T21:27:34Z")

</div>

Hello, Cmake fails in the configuration stage with the following messages when I tried to compile with the iOS toolchain and Xcode generator. Check size of unsigned long - failed CMake Error at /Applications/CMake.app…

---

## [How to Explicitly specify cmake to process a different .txt file](https://discourse.cmake.org/t/how-to-explicitly-specify-cmake-to-process-a-different-txt-file/938)

<div class="topic-metadata">

**Author:** [@rmadhuraj](https://discourse.cmake.org/u/rmadhuraj)\
**Replies:** 5\
**Last updated:** [September 27, 2020, 8:56pm UTC](https://discourse.cmake.org/t/how-to-explicitly-specify-cmake-to-process-a-different-txt-file/938 "2020-09-27T20:56:07Z")

</div>

Hi, Is it possible to have two List.txt files , i,e, CMakeLists1.txt and CMakeLists2.txt in a single directory and while compiling is it possible to inform cmake to consider CMakeLists2.txt for further process ? If yes …

---

## [pow with variable throws error](https://discourse.cmake.org/t/pow-with-variable-throws-error/1893)

<div class="topic-metadata">

**Author:** [@grenmel](https://discourse.cmake.org/u/grenmel)\
**Replies:** 1\
**Last updated:** [September 27, 2020, 7:47pm UTC](https://discourse.cmake.org/t/pow-with-variable-throws-error/1893 "2020-09-27T19:47:04Z")

</div>

Hi, I’m new to C. When I try variable in pow function (for example pow(hightSq,2)) it returns "undefined reference to ‘pow’ ". I’ve read that it has to do something with UNIX compatibility and that you have to add argume…

---

## [Can you exclude certain source files from different build configurations?](https://discourse.cmake.org/t/can-you-exclude-certain-source-files-from-different-build-configurations/1897)

<div class="topic-metadata">

**Author:** [@Dave\_R](https://discourse.cmake.org/u/Dave_R)\
**Replies:** 3\
**Last updated:** [September 23, 2020, 7:29pm UTC](https://discourse.cmake.org/t/can-you-exclude-certain-source-files-from-different-build-configurations/1897 "2020-09-23T19:29:00Z")

</div>

I’m working on a project that runs on an embedded board with an ARM9 processor. The board was originally running Linux with a 2.6.0 kernel and we recently upgraded to use a 5.1.0 kernel and I’m now trying to sort out the…

---

## [Cross Compiling toolchain not taken into account](https://discourse.cmake.org/t/cross-compiling-toolchain-not-taken-into-account/1901)

<div class="topic-metadata">

**Author:** [@SadE](https://discourse.cmake.org/u/SadE)\
**Replies:** 3\
**Last updated:** [September 23, 2020, 3:18pm UTC](https://discourse.cmake.org/t/cross-compiling-toolchain-not-taken-into-account/1901 "2020-09-23T15:18:28Z")

</div>

Hi, I’m new to CMAke and trying to set up a cross compile project for ARM using the Armcc tools (from Keil) . I saw the toolchain files are part of the Cmake distribution , so I’m trying to use it … without any success.…

---

## [Getting undefined reference error despite of having the library specified in CMake](https://discourse.cmake.org/t/getting-undefined-reference-error-despite-of-having-the-library-specified-in-cmake/1888)

<div class="topic-metadata">

**Author:** [@Coderx7](https://discourse.cmake.org/u/Coderx7)\
**Replies:** 1\
**Last updated:** [September 23, 2020, 2:50am UTC](https://discourse.cmake.org/t/getting-undefined-reference-error-despite-of-having-the-library-specified-in-cmake/1888 "2020-09-23T02:50:25Z")

</div>

Hello everyone, hope you are having a great time. I’m trying to create a test executable out of a library I made. Lets name them lib1 and lib2. lib1 gets built along with its test just fine. the lib2 is also built wit…

---

## [abuse / misuse of find\_package?](https://discourse.cmake.org/t/abuse-misuse-of-find-package/1887)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 2\
**Last updated:** [September 22, 2020, 4:19pm UTC](https://discourse.cmake.org/t/abuse-misuse-of-find-package/1887 "2020-09-22T16:19:42Z")

</div>

I am reviewing at my work some code that a developer submitted and a big red flag went up for me. I wanted to make sure I’m not the one misunderstanding find\_package before I really dig in with my objections to some cha…

---

## [How to replicating a mingw32 build with CMake?](https://discourse.cmake.org/t/how-to-replicating-a-mingw32-build-with-cmake/1883)

<div class="topic-metadata">

**Author:** [@mbilyanov](https://discourse.cmake.org/u/mbilyanov)\
**Replies:** 0\
**Last updated:** [September 22, 2020, 9:31am UTC](https://discourse.cmake.org/t/how-to-replicating-a-mingw32-build-with-cmake/1883 "2020-09-22T09:31:58Z")

</div>

I have the following mingw32 build directive and it works. The command successfully builds a Windows DLL on a Linux machine. /usr/bin/x86\_64-w64-mingw32-g++ -march=x86-64 -mtune=x86-64 -O2 -shared -static -static-libgcc…

[Previous page](https://discourse.cmake.org/c/usage/12.md?page=88)

[Next page](https://discourse.cmake.org/c/usage/12.md?page=90)
