# cmake picks up LDFLAGS from environment

**URL:** https://discourse.cmake.org/t/cmake-picks-up-ldflags-from-environment/4130
**Category:** Code
**Created:** [September 21, 2021, 3:24pm UTC](https://discourse.cmake.org/t/cmake-picks-up-ldflags-from-environment/4130 "2021-09-21T15:24:22Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)
#### Post date: [September 22, 2021, 11:13am UTC](https://discourse.cmake.org/t/cmake-picks-up-ldflags-from-environment/4130/13 "2021-09-22T11:13:28Z")

</div>

I removed the environment variables `CFLAGS` and `LDFLAGS` to avoid them being picked up by cmake.

This cmake behavior is quite problematic and undesirable. In my case a build machine had these environment variables defined giving a different build result. This kind of behavior is not good for reproducible builds and can be hard to track down. A toolchain file should be the input to the compiler and linker flags.

---

_[View the full topic](https://discourse.cmake.org/t/cmake-picks-up-ldflags-from-environment/4130)._
