# Broken build.ninja on FreeBSD

**URL:** https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474
**Category:** Development
**Created:** [July 1, 2020, 8:02pm UTC](https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474 "2020-07-01T20:02:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Holger](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/ed8c4c/32.png) [@Holger](https://discourse.cmake.org/u/Holger)
#### Post date: [July 1, 2020, 8:02pm UTC](https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474/1 "2020-07-01T20:02:47Z")

</div>

Hi guys,

I compiled CMake (cloned from GitLab) on FreeBSD-12.1-RELEASE and got a broken ninja file. Here is the CMakeLists.txt:

```nohighlight
cmake_minimum_required(VERSION 3.16)
project(NinjaOmitLocalOutputTest)
add_library(foo foo.cpp)

```

The command `cmake -G ninja --debug-trycompile` produces the following output:

```auto
debug trycompile on
-- The C compiler identification is Clang 8.0.1
-- The CXX compiler identification is Clang 8.0.1
-- Detecting C compiler ABI info
CMake Error:
  Running

   '/home/hsebert/local/bin/ninja' '-C' '/usr/home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp' '-t' 'cleandead'

  failed with:

   ninja: error: build.ninja:120: unknown target 'all'

  default all

             ^ near here
<snip>

```

Looking into the respective `build.ninja` file, I found this:

```auto
#############################################
# Folder: /home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp

build /home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp/all: phony /home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp/cmTC_91198

```

which should rather be (I suppose)

```auto
#############################################
# Folder: /home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp

build all: phony /home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp/cmTC_91198

```

(without the path before `all`).

What do you think?

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [July 1, 2020, 8:32pm UTC](https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474/2 "2020-07-01T20:32:24Z")

</div>

Looks to me like a problem with your home directory being symlinked (`/home -> /usr/home`.) This line in particular is interesting:

```auto
'/home/hsebert/local/bin/ninja' '-C' '/usr/home/hsebert/Documents/cmake_test/build.broken/CMakeFiles/CMakeTmp' '-t' 'cleandead'

```

In most cases, CMake preserves symlinks, but for the try-compile it seems to be going into the real path.

@brad.king @ben.boeckel any ideas?

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [July 1, 2020, 8:33pm UTC](https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474/3 "2020-07-01T20:33:32Z")

</div>

Please open an issue at [https://gitlab.kitware.com/cmake/cmake/-/issues](https://gitlab.kitware.com/cmake/cmake/-/issues).

---

<div class="post-metadata">

### Author: ![Holger](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/ed8c4c/32.png) [@Holger](https://discourse.cmake.org/u/Holger)
#### Post date: [July 1, 2020, 8:37pm UTC](https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474/4 "2020-07-01T20:37:39Z")

</div>

@kyle.edwards The problem also occurs when omitting the `--debug-trycompile` option.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [July 1, 2020, 8:46pm UTC](https://discourse.cmake.org/t/broken-build-ninja-on-freebsd/1474/5 "2020-07-01T20:46:22Z")

</div>

I see [CMake Issue 20900](https://gitlab.kitware.com/cmake/cmake/-/issues/20900), thanks.
