# Code

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

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

**Page:** 68

---

## [What cmake method is used to configure the Randomized Base Address option in Linker for VS2015 Project ?](https://discourse.cmake.org/t/what-cmake-method-is-used-to-configure-the-randomized-base-address-option-in-linker-for-vs2015-project/2016)

<div class="topic-metadata">

**Author:** [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Replies:** 1\
**Last updated:** [October 18, 2020, 3:07am UTC](https://discourse.cmake.org/t/what-cmake-method-is-used-to-configure-the-randomized-base-address-option-in-linker-for-vs2015-project/2016 "2020-10-18T03:07:45Z")

</div>

---

## [trouble with find\_package(iconv) and include(FindIconv) on AIX](https://discourse.cmake.org/t/trouble-with-find-package-iconv-and-include-findiconv-on-aix/2006)

<div class="topic-metadata">

**Author:** [@datalogics-robb](https://discourse.cmake.org/u/datalogics-robb)\
**Replies:** 4\
**Last updated:** [October 16, 2020, 11:50am UTC](https://discourse.cmake.org/t/trouble-with-find-package-iconv-and-include-findiconv-on-aix/2006 "2020-10-16T11:50:12Z")

</div>

I have discovered (while building Doxygen) that the iconv test fails on AIX with g++ because of incorrect (for AIX) linking. I took the test’s code: (python-env-nepal) robb@nepal:/raid/proj/procyon/checkouts-procyon/ro…

---

## [Replace default compiler option (-o, -c, etc..) with CCRX-supported options (-output,…)](https://discourse.cmake.org/t/replace-default-compiler-option-o-c-etc-with-ccrx-supported-options-output/2004)

<div class="topic-metadata">

**Author:** [@xuan97z1](https://discourse.cmake.org/u/xuan97z1)\
**Replies:** 3\
**Last updated:** [October 15, 2020, 1:59pm UTC](https://discourse.cmake.org/t/replace-default-compiler-option-o-c-etc-with-ccrx-supported-options-output/2004 "2020-10-15T13:59:55Z")

</div>

Hi, I am working on a Renesas CCRX-based CMakeLists.txt for AmazonFreeRTOS project. However, I ran into the following error when I did a ‘make all’: E0511108:The “-o” option is not recognized. E0511134:Input file “CM…

---

## [CMake Property + Generator expression to get all dependent libraries?](https://discourse.cmake.org/t/cmake-property-generator-expression-to-get-all-dependent-libraries/1898)

<div class="topic-metadata">

**Author:** [@AndrewGaspar](https://discourse.cmake.org/u/AndrewGaspar)\
**Replies:** 5\
**Last updated:** [October 15, 2020, 12:50pm UTC](https://discourse.cmake.org/t/cmake-property-generator-expression-to-get-all-dependent-libraries/1898 "2020-10-15T12:50:55Z")

</div>

Is there any way to get the list of all dependent libraries for a target, including transitive dependencies, via a generator expression? The Target property INTERFACE\_LINK\_LIBRARIES says it includes transitive dependenci…

---

## [VS 2017: Custom commands don't cascade correctly](https://discourse.cmake.org/t/vs-2017-custom-commands-dont-cascade-correctly/2000)

<div class="topic-metadata">

**Author:** [@Angew](https://discourse.cmake.org/u/Angew)\
**Replies:** 3\
**Last updated:** [October 15, 2020, 7:14am UTC](https://discourse.cmake.org/t/vs-2017-custom-commands-dont-cascade-correctly/2000 "2020-10-15T07:14:52Z")

</div>

I have a custom target which produces an end result using a two-step process similar to compilation & linking. My problem is that as soon as more than one source file is involved, updates do not cascade correctly in one …

---

## [IMPLICIT\_DEPENDS - does not work](https://discourse.cmake.org/t/implicit-depends-does-not-work/1966)

<div class="topic-metadata">

**Author:** [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)\
**Replies:** 12\
**Last updated:** [October 14, 2020, 3:56pm UTC](https://discourse.cmake.org/t/implicit-depends-does-not-work/1966 "2020-10-14T15:56:20Z")

</div>

I have been trying to do this: add\_custom\_command( OUTPUT … COMMAND … IMPLICIT\_DEPENDS C “C:/WS/project1/timer\_x.c” VERBATIM ) but I cannot get the dependencies scanner to work correctly What I want is, if any he…

---

## [Correct use of CMAKE\_CUDA\_ARCHITECTURES](https://discourse.cmake.org/t/correct-use-of-cmake-cuda-architectures/1250)

<div class="topic-metadata">

**Author:** [@mojca](https://discourse.cmake.org/u/mojca)\
**Replies:** 7\
**Last updated:** [October 14, 2020, 8:32am UTC](https://discourse.cmake.org/t/correct-use-of-cmake-cuda-architectures/1250 "2020-10-14T08:32:22Z")

</div>

I was looking for ways to properly target different compute capabilities of cuda devices and found a couple of new policies for 3.18. So I tried (simplified): cmake\_minimum\_required(VERSION 3.17 FATAL\_ERROR) cmake\_poli…

---

## [Disable warning on fetched projects](https://discourse.cmake.org/t/disable-warning-on-fetched-projects/1978)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 7\
**Last updated:** [October 13, 2020, 3:30am UTC](https://discourse.cmake.org/t/disable-warning-on-fetched-projects/1978 "2020-10-13T03:30:38Z")

</div>

Hi, I wonder how I could disable warnings on header files, which are not part of my project (e.g. those in libaries I use and included via fetchContent). For instance I get: »bool std::uncaught\_exception()« is depcrea…

---

## [What cmake method is used to configure the Additional Dependencies option in Librarian for VS Static library project ?](https://discourse.cmake.org/t/what-cmake-method-is-used-to-configure-the-additional-dependencies-option-in-librarian-for-vs-static-library-project/1993)

<div class="topic-metadata">

**Author:** [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Replies:** 1\
**Last updated:** [October 12, 2020, 5:25pm UTC](https://discourse.cmake.org/t/what-cmake-method-is-used-to-configure-the-additional-dependencies-option-in-librarian-for-vs-static-library-project/1993 "2020-10-12T17:25:37Z")

</div>

---

## [Ceres solver & CMake Issue on Ubuntu 18.04](https://discourse.cmake.org/t/ceres-solver-cmake-issue-on-ubuntu-18-04/1980)

<div class="topic-metadata">

**Author:** [@Ceccand](https://discourse.cmake.org/u/Ceccand)\
**Replies:** 4\
**Last updated:** [October 9, 2020, 4:39am UTC](https://discourse.cmake.org/t/ceres-solver-cmake-issue-on-ubuntu-18-04/1980 "2020-10-09T04:39:34Z")

</div>

Hello I am trying to install Ceres-solver on UBUNTU 18.04. But always I got following feedback related to CMake. \[100%\] Built target bundle\_adjuster ^Cexamples/CMakeFiles/nist.dir/build.make:62: recipe for target ‘exa…

---

## [CMake Configuration uses a file which will only be generated during Build time](https://discourse.cmake.org/t/cmake-configuration-uses-a-file-which-will-only-be-generated-during-build-time/1965)

<div class="topic-metadata">

**Author:** [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)\
**Replies:** 3\
**Last updated:** [October 7, 2020, 2:04pm UTC](https://discourse.cmake.org/t/cmake-configuration-uses-a-file-which-will-only-be-generated-during-build-time/1965 "2020-10-07T14:04:08Z")

</div>

I have a custom command which uses a file generated (during Build time) by another custom command: add\_custom\_command( #Command\_A … #generate myfile.txt … ) add\_custom\_command( #Command\_B … #uses myfile.txt … ) …

---

## [Rebuild external project's dependent targets when the external project changes?](https://discourse.cmake.org/t/rebuild-external-projects-dependent-targets-when-the-external-project-changes/1937)

<div class="topic-metadata">

**Author:** [@dtgriscom](https://discourse.cmake.org/u/dtgriscom)\
**Replies:** 4\
**Last updated:** [October 2, 2020, 5:51pm UTC](https://discourse.cmake.org/t/rebuild-external-projects-dependent-targets-when-the-external-project-changes/1937 "2020-10-02T17:51:58Z")

</div>

I’m working on a cross-compilation project with a top-level CMakeLists.txt file generating Makefiles. Some of the cross-compiled source code is generated by a host-based code generation tool; since that tool needs a diff…

---

## [install( FILES ... ) installing all files in directory when single file is specified](https://discourse.cmake.org/t/install-files-installing-all-files-in-directory-when-single-file-is-specified/1955)

<div class="topic-metadata">

**Author:** [@Matthew\_Polder](https://discourse.cmake.org/u/Matthew_Polder)\
**Replies:** 1\
**Last updated:** [October 2, 2020, 12:04am UTC](https://discourse.cmake.org/t/install-files-installing-all-files-in-directory-when-single-file-is-specified/1955 "2020-10-02T00:04:08Z")

</div>

Hi, I’m using cmake 3.17.0 and then tried 3.17.5. Our cmake code base uses the commands: message( STATUS “---- ${resolvedFileToInstall} -\> ${to\_directory}” ) install( FILES “${resolvedFileToInstall}” DESTINATION “${…

---

## [How do I pull full paths out of UNRESOLVED\_DEPENDENCIES\_VAR](https://discourse.cmake.org/t/how-do-i-pull-full-paths-out-of-unresolved-dependencies-var/1945)

<div class="topic-metadata">

**Author:** [@NotSven](https://discourse.cmake.org/u/NotSven)\
**Replies:** 2\
**Last updated:** [September 30, 2020, 5:06pm UTC](https://discourse.cmake.org/t/how-do-i-pull-full-paths-out-of-unresolved-dependencies-var/1945 "2020-09-30T17:06:36Z")

</div>

Very first post, please remove if silly. I’ve got something like this in my setup : file(GET\_RUNTIME\_DEPENDENCIES RESOLVED\_DEPENDENCIES\_VAR RES UNRESOLVED\_DEPENDENCIES\_VAR UNRES CONFLICTING\_DEPENDENCIES\_PREFIX CONFL…

---

## ["Mapping" lists of dependents and dependees files?](https://discourse.cmake.org/t/mapping-lists-of-dependents-and-dependees-files/1934)

<div class="topic-metadata">

**Author:** [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)\
**Replies:** 9\
**Last updated:** [September 30, 2020, 8:02am UTC](https://discourse.cmake.org/t/mapping-lists-of-dependents-and-dependees-files/1934 "2020-09-30T08:02:06Z")

</div>

Is there a way to “map” a list of dependants and dependees files? Like below: set(IF\_f \<file1.h file2.h\>) add\_custom\_command( OUTPUT \<file1.obj file2.obj\> COMMAND ${CMAKE\_CXX\_COMPILER} -debug -nofpu -output=obj=\<f…

---

## [Why can't this work? add\_custom\_command, add\_custom\_target?](https://discourse.cmake.org/t/why-cant-this-work-add-custom-command-add-custom-target/1929)

<div class="topic-metadata">

**Author:** [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)\
**Replies:** 4\
**Last updated:** [September 29, 2020, 4:56pm UTC](https://discourse.cmake.org/t/why-cant-this-work-add-custom-command-add-custom-target/1929 "2020-09-29T16:56:42Z")

</div>

Can anyone tell me why the below does not work correctly? I meant to do this: If timer\_cx.h is changed, then timer\_cx.c should be recompiled and timer\_cx.c.obj should be generated Then, MY\_Project should be re-built, …

---

## [CodeBlocks vs CMAKE\_BUILD\_TYPE](https://discourse.cmake.org/t/codeblocks-vs-cmake-build-type/1931)

<div class="topic-metadata">

**Author:** [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Replies:** 3\
**Last updated:** [September 28, 2020, 8:31pm UTC](https://discourse.cmake.org/t/codeblocks-vs-cmake-build-type/1931 "2020-09-28T20:31:35Z")

</div>

It seems that CMAKE\_BUILD\_TYPE cannot be evaluated when using the CodeBlocks IDE ?

---

## [CMake to replace Eclipse CDT GNU - how to deal with C\_DEPS?](https://discourse.cmake.org/t/cmake-to-replace-eclipse-cdt-gnu-how-to-deal-with-c-deps/1917)

<div class="topic-metadata">

**Author:** [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)\
**Replies:** 4\
**Last updated:** [September 27, 2020, 6:41pm UTC](https://discourse.cmake.org/t/cmake-to-replace-eclipse-cdt-gnu-how-to-deal-with-c-deps/1917 "2020-09-27T18:41:51Z")

</div>

I am using Eclipse CDT with GNU Make In the project makefile, there are these lines: -include $(C\_DEPS) where: C\_DEPS += time\_cx/src/time\_cx.d where time\_cx.d is: time\_cx/src/time\_cx.obj time\_cx/src/time\_cx.d:…

---

## [gollvm: -fPIC is not supported, if using ld or lld, with Clang++](https://discourse.cmake.org/t/gollvm-fpic-is-not-supported-if-using-ld-or-lld-with-clang/1921)

<div class="topic-metadata">

**Author:** [@Ivan\_Serdyuk](https://discourse.cmake.org/u/Ivan_Serdyuk)\
**Replies:** 1\
**Last updated:** [September 26, 2020, 4:09pm UTC](https://discourse.cmake.org/t/gollvm-fpic-is-not-supported-if-using-ld-or-lld-with-clang/1921 "2020-09-26T16:09:17Z")

</div>

It appears that there is a misconfigured CMake file, for gollvm project. https://github.com/golang/go/issues/41527 - this is my description. So to be short: there is a confusing warning, not proven by build attempts or…

---

## [Why is C++14 mode satisfied with -std=c++1y?](https://discourse.cmake.org/t/why-is-c-14-mode-satisfied-with-std-c-1y/1348)

<div class="topic-metadata">

**Author:** [@oliver](https://discourse.cmake.org/u/oliver)\
**Replies:** 6\
**Last updated:** [September 24, 2020, 2:28pm UTC](https://discourse.cmake.org/t/why-is-c-14-mode-satisfied-with-std-c-1y/1348 "2020-09-24T14:28:20Z")

</div>

Hi, I’m just getting started with CMake and have come upon a corner case related to C++14 support with older compilers. My target platform (RHEL 7) ships with G++ 4.8.5, which does not support C++14 completely. It prov…

---

## [set CMAKE\_CXX\_FLGAS composed of variables without parenthesis, not a good idea ?](https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907)

<div class="topic-metadata">

**Author:** [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Replies:** 2\
**Last updated:** [September 24, 2020, 12:46pm UTC](https://discourse.cmake.org/t/set-cmake-cxx-flgas-composed-of-variables-without-parenthesis-not-a-good-idea/1907 "2020-09-24T12:46:10Z")

</div>

Why does set(CMAKE\_CXX\_FLGAS "${CMAKE\_CXX\_FLAGS} ${extra\_flags}") works, but set(CMAKE\_CXX\_FLGAS ${CMAKE\_CXX\_FLAGS} ${extra\_flags}) doesn’t ? In my case, I got the g++ error: " no input files because of the above.

---

## [Is there any reason to prefer \`include(CTest)\` or \`enable\_testing()\` over the other?](https://discourse.cmake.org/t/is-there-any-reason-to-prefer-include-ctest-or-enable-testing-over-the-other/1905)

<div class="topic-metadata">

**Author:** [@alex](https://discourse.cmake.org/u/alex)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 10:46am UTC](https://discourse.cmake.org/t/is-there-any-reason-to-prefer-include-ctest-or-enable-testing-over-the-other/1905 "2020-09-24T10:46:28Z")

</div>

Like it says in the title… the main difference I’m aware of is that include(CTest) has extra features for integrating with CDash and defines the BUILD\_TESTING option. But should one be preferred over the other for new c…

---

## [How to use string(strip..) function?](https://discourse.cmake.org/t/how-to-use-string-strip-function/1872)

<div class="topic-metadata">

**Author:** [@swoo.quek](https://discourse.cmake.org/u/swoo.quek)\
**Replies:** 1\
**Last updated:** [September 22, 2020, 11:37pm UTC](https://discourse.cmake.org/t/how-to-use-string-strip-function/1872 "2020-09-22T23:37:53Z")

</div>

I have the following strings: S1 = “C:/myfolder/abc/myfile.txt” S2 = “C:/myfolder” I want to use string() function such that: S3 = “/abc/myfile.txt”, ie. (S3 = S1 - S2) How can I do that? Should I use string(strip…)…

---

## [INSTALL\_RPATH\_USE\_LINK\_PATH not working when CMAKE\_EXE\_LINKER\_FLAGS (LDFLAGS) is set](https://discourse.cmake.org/t/install-rpath-use-link-path-not-working-when-cmake-exe-linker-flags-ldflags-is-set/1892)

<div class="topic-metadata">

**Author:** [@ryanofsky](https://discourse.cmake.org/u/ryanofsky)\
**Replies:** 0\
**Last updated:** [September 22, 2020, 6:20pm UTC](https://discourse.cmake.org/t/install-rpath-use-link-path-not-working-when-cmake-exe-linker-flags-ldflags-is-set/1892 "2020-09-22T18:20:05Z")

</div>

I’m wondering if this is a bug. I’m using INSTALL\_RPATH\_USE\_LINK\_PATH TRUE for a target in my project, and generally it seems to work and set the target’s RUNPATH as expected on install, except it stops working and does…

---

## [What is the best way to search and replace strings in a file?](https://discourse.cmake.org/t/what-is-the-best-way-to-search-and-replace-strings-in-a-file/1879)

<div class="topic-metadata">

**Author:** [@Shane\_Dev](https://discourse.cmake.org/u/Shane_Dev)\
**Replies:** 3\
**Last updated:** [September 22, 2020, 6:24am UTC](https://discourse.cmake.org/t/what-is-the-best-way-to-search-and-replace-strings-in-a-file/1879 "2020-09-22T06:24:46Z")

</div>

Hi, In my CMake script, I need to modify other source files by searching and replacing specified strings. In my case, the configure\_file command is not a solution because I have no control over the input file. Previousl…

---

## [Remove linker flag needed by library, but not by test programs](https://discourse.cmake.org/t/remove-linker-flag-needed-by-library-but-not-by-test-programs/1860)

<div class="topic-metadata">

**Author:** [@starfire](https://discourse.cmake.org/u/starfire)\
**Replies:** 1\
**Last updated:** [September 19, 2020, 10:36am UTC](https://discourse.cmake.org/t/remove-linker-flag-needed-by-library-but-not-by-test-programs/1860 "2020-09-19T10:36:43Z")

</div>

I am migrating a project from autotools to CMake. One part is a static library with version information and a few testprograms in a subdirectory. So I tried: add\_library(wraster STATIC ${SOURCES}) target\_link\_libraries(…

---

## [Secondary Expansion in the cmake language](https://discourse.cmake.org/t/secondary-expansion-in-the-cmake-language/1779)

<div class="topic-metadata">

**Author:** [@jmon12](https://discourse.cmake.org/u/jmon12)\
**Replies:** 2\
**Last updated:** [September 18, 2020, 8:28pm UTC](https://discourse.cmake.org/t/secondary-expansion-in-the-cmake-language/1779 "2020-09-18T20:28:20Z")

</div>

I have a simple question: is there any concept of secondary expansion (such as !var in bash or GNU make secondary expansion) in the cmake language? One usage example could be in the second step of the cmake tutorial. On…

---

## [cmake 3.18: generator expressions with add\_subdirectory ?](https://discourse.cmake.org/t/cmake-3-18-generator-expressions-with-add-subdirectory/1801)

<div class="topic-metadata">

**Author:** [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Replies:** 19\
**Last updated:** [September 17, 2020, 12:05pm UTC](https://discourse.cmake.org/t/cmake-3-18-generator-expressions-with-add-subdirectory/1801 "2020-09-17T12:05:11Z")

</div>

How could I define a binary\_dir dependent on generator expression. The goal is to have a different build directory (binary\_dir) dependent on a configuration, when I call add\_subdirectory. Currently with cmake v3.18 I h…

---

## [parallel build (2) : add\_subdirectory to a non-subdirectory](https://discourse.cmake.org/t/parallel-build-2-add-subdirectory-to-a-non-subdirectory/1841)

<div class="topic-metadata">

**Author:** [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Replies:** 8\
**Last updated:** [September 17, 2020, 7:34am UTC](https://discourse.cmake.org/t/parallel-build-2-add-subdirectory-to-a-non-subdirectory/1841 "2020-09-17T07:34:48Z")

</div>

add\_subdirectory(${CMAKE\_CURRENT\_SOURCE\_DIR}/../myStaticLib ${BINARY\_OUTPUT\_PATH}) add\_executable(${EXE\_NAME} ${PROJECT\_SOURCE\_DIR}/exe.cpp) Always fails if a parallel build is triggered (e.g. make -j N), and the the bu…

---

## [CPack + WiX - setting working directory for desktop and menu shortcuts?](https://discourse.cmake.org/t/cpack-wix-setting-working-directory-for-desktop-and-menu-shortcuts/1846)

<div class="topic-metadata">

**Author:** [@starseeker](https://discourse.cmake.org/u/starseeker)\
**Replies:** 0\
**Last updated:** [September 15, 2020, 2:41pm UTC](https://discourse.cmake.org/t/cpack-wix-setting-working-directory-for-desktop-and-menu-shortcuts/1846 "2020-09-15T14:41:30Z")

</div>

Hi! I’m trying to match the functionality of our CPack/NSIS installer using CPack + WiX, and I’ve hit a bit of a tricky point. I’d like to alter the default working directory for applications launched via desktop and m…

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

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