# Current directory during link step?

**URL:** https://discourse.cmake.org/t/current-directory-during-link-step/4608
**Category:** Usage
**Created:** [December 7, 2021, 10:42am UTC](https://discourse.cmake.org/t/current-directory-during-link-step/4608 "2021-12-07T10:42:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![PlatonCM](https://discourse.cmake.org/user_avatar/discourse.cmake.org/platoncm/32/1910_2.png) [@PlatonCM](https://discourse.cmake.org/u/PlatonCM)
#### Post date: [December 7, 2021, 10:42am UTC](https://discourse.cmake.org/t/current-directory-during-link-step/4608/1 "2021-12-07T10:42:12Z")

</div>

I’m having cross-crompiling issues with the armcc/armlink toolchain when I run armlink with our scatter file. The scatter file includes a header file from a relative path (has to work on developer machines and it works when building from the uVision IDE).  
With CMake, the linker no longer finds that header file. When armlink is running, the current directory is different from the one when uVision runs the build.  
The original scatter file uses `#! armcc -E -I..` and then the `#include path/to/file.h`.  
With CMake, I have to use `#! armcc -E -I../<folder of my CMakeLists.txt>`.

What is the “current directory” when CMake is running the link step? `CMAKE_BIN_DIR`? The scatter file mechanism is somewhat odd. Essentially, the linker takes all its inputs (the object files) from the build tree - except for a scatter file, which is located in the source tree and may include other files from the source tree.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 11, 2021, 7:15pm UTC](https://discourse.cmake.org/t/current-directory-during-link-step/4608/2 "2021-12-11T19:15:08Z")

</div>

I think it may be useful to generate that scatter file instead of assuming some static build tree layout. That way you can just generate it with an absolute path.

---

<div class="post-metadata">

### Author: ![PlatonCM](https://discourse.cmake.org/user_avatar/discourse.cmake.org/platoncm/32/1910_2.png) [@PlatonCM](https://discourse.cmake.org/u/PlatonCM)
#### Post date: [December 13, 2021, 5:44am UTC](https://discourse.cmake.org/t/current-directory-during-link-step/4608/3 "2021-12-13T05:44:24Z")

</div>

We hope to make building easier and won’t have to add complexity by creating generators. Well, we have control over the source and build trees. The existing IDE works relative to its project file. With CMake we could use `CMAKE_SOURCE_DIR` as the “anchor” since we define where the build tree lies relative to that.
