# Build failure with Ninja Multi-Config

**URL:** https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290
**Category:** Usage
**Created:** [May 29, 2020, 2:34am UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290 "2020-05-29T02:34:38Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 2:34am UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/1 "2020-05-29T02:34:38Z")

</div>

Hi all, I just tried testing out Ninja Multi-Config for the first time on Windows. My project has worked with both the Ninja and Visual Studio 19 generators before without issue.

I try running in a developer command prompt:

```auto
> cmake -G "Ninja Multi-Config" ^
        -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake ^
        -DWITH_TESTS=OFF ^
        -DWITH_TUTORIALS=OFF ^
        -DWITH_UTILS=OFF ^
        ..\Halide
> cmake --build . --config Release

```

and after some time I get (manually wrapped)

```auto
cmd.exe /C "cmd.exe /C ""C:\Program Files\CMake\bin\cmake.exe" -E __create_def 
D:\Halide-build\src\CMakeFiles\Halide.dir\${CONFIGURATION}\exports.def 
D:\Halide-build\src\CMakeFiles\Halide.dir\${CONFIGURATION}\exports.def.objs &&
cd D:\Halide-build" && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll 
--intdir=src\CMakeFiles\Halide.dir\Release 
--rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe 
--mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe 
--manifests -- 
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\bin\Hostx64\x64\link.exe 
/nologo @CMakeFiles\Halide.rsp /out:bin\Release\Halide.dll /implib:src\Release\Halide.lib 
/pdb:bin\Release\Halide.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO  
/DEF:src\CMakeFiles\Halide.dir\$Release\exports.def && cmd.exe /C "cd /D
D:\Halide-build\src && powershell -noprofile -executionpolicy Bypass -file 
D:/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary 
D:/Halide-build/bin/Release/Halide.dll -installedDir 
D:/vcpkg/installed/x64-windows/bin -OutVariable out""

Couldn't open file 'src\runtime\CMakeFiles\Halide_initmod.dir\Debug\_initmod_aarch64_cpu_features_32_debug.cpp.obj' with CreateFile()

```

Where did `\Debug\` come from in the output path? I specified Release at the command line.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 2:46am UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/2 "2020-05-29T02:46:04Z")

</div>

For what it’s worth, these build commands work fine:

```auto
> cmake -G "Visual Studio 16 2019" -Thost=x64 -A x64 ^
        -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake ^
        -DWITH_TESTS=OFF ^
        -DWITH_TUTORIALS=OFF ^
        -DWITH_UTILS=OFF ^
        ..\Halide
> cmake --build . --config Release

```

and

```auto
> cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ^
        -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake ^
        -DWITH_TESTS=OFF -DWITH_TUTORIALS=OFF -DWITH_UTILS=OFF ^
        ..\Halide
> cmake --build .

```

And here’s a link to the project on GitHub: [https://github.com/halide/Halide](https://github.com/halide/Halide)  
The CMakeLists.txt that created the target with the erroneous output path is here: [https://github.com/halide/Halide/blob/master/src/runtime/CMakeLists.txt](https://github.com/halide/Halide/blob/master/src/runtime/CMakeLists.txt)

As far as I can tell, I’m not doing anything improper with `CMAKE_BUILD_TYPE` (prefer to use `$<CONFIG>` wherever that matters)

---

<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: [May 29, 2020, 3:17pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/3 "2020-05-29T15:17:39Z")

</div>

I’m taking a look at this now. I can’t think of anything off the top of my head that would cause this happen, but who knows.

~~What compiler are you using?~~ Never mind, I see you’re using VS2019.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 3:43pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/4 "2020-05-29T15:43:02Z")

</div>

Thanks, Kyle. Let me know if you need any help reproducing the error.

---

<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: [May 29, 2020, 5:19pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/5 "2020-05-29T17:19:04Z")

</div>

I have successfully built LLVM 10.0.0 and configured Halide against it. Unfortunately, running `cmake --build . --config Release` sends CMake into an infinite loop of re-running CMake, and it never even has a chance to start the build. Is this a known bug in Halide?

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 5:19pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/6 "2020-05-29T17:19:19Z")

</div>

Nope. That has never come up before. Can you tell me more about your environment, the commands you ran, etc.?

---

<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: [May 29, 2020, 5:21pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/7 "2020-05-29T17:21:28Z")

</div>

Oh… I think it might be an issue on my end. I cloned the repo while my computer was in UTC mode (I spend most of my time on Linux and rarely boot into Windows) but the build files have been generated after Windows set the correct time zone, leading to Ninja always thinking the source files have changed. I’ll see if re-cloning the repository helps.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 5:22pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/8 "2020-05-29T17:22:09Z")

</div>

Wow! Nice catch! I would never have guessed that one. I _hate_ the timezone issues between Windows and Linux, too.

---

<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: [May 29, 2020, 6:05pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/9 "2020-05-29T18:05:38Z")

</div>

Confirmed, fixing the timestamps fixed it. I’m now waiting for the build.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 6:07pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/10 "2020-05-29T18:07:15Z")

</div>

Great, thanks for your effort on this.

---

<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: [May 29, 2020, 6:30pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/11 "2020-05-29T18:30:11Z")

</div>

I’m getting an error with a missing LLVM header:

```auto
C:\Users\kyle.edwards\development\halide\src\src\LLVM_Headers.h(28): fatal error C1083: Cannot open include file: 'llvm/ExecutionEngine/JITEventListener.h': No such file or directory

```

Any ideas?

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 6:31pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/12 "2020-05-29T18:31:36Z")

</div>

Did you point Halide to a build directory of LLVM’s or an _install_ directory?

---

<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: [May 29, 2020, 6:32pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/13 "2020-05-29T18:32:25Z")

</div>

Build directory

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 6:33pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/14 "2020-05-29T18:33:53Z")

</div>

That would be the issue. LLVM isn’t really usable until it’s been installed somewhere. Try `cmake --install . --prefix D:\llvm-install` (for instance) and then set `LLVM_DIR=D:\llvm-install\lib\cmake\llvm`.

Also, LLVM’s Clang package is broken (missing ClangConfigVersion.cmake), so you need to set LLVM\_DIR instead of CMAKE\_PREFIX\_PATH / CMAKE\_MODULE\_PATH. Various package managers seem to fix this somehow on their own (eg. Ubuntu and vcpkg)

---

<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: [May 29, 2020, 6:36pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/15 "2020-05-29T18:36:54Z")

</div>

OK, trying that now… and if the build tree for LLVM doesn’t work, someone should probably let the LLVM team know about that. If the build tree exports an `LLVMConfig.cmake` file, we’d expect it to work like the install file.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 6:37pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/16 "2020-05-29T18:37:11Z")

</div>

I have tried to open issues with them and they have all been ignored.

---

<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: [May 29, 2020, 6:46pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/17 "2020-05-29T18:46:36Z")

</div>

OK, I’ve reproduced the error, but with slightly different output:

```auto
Couldn't open file 'src\runtime\CMakeFiles\Halide_initmod.dir\RelWithDebInfo\_initmod_aarch64_cpu_features_32_debug.cpp.obj' with CreateFile()

```

For some reason mine tried to use `RelWithDebInfo` instead of `Debug`, but it’s close enough. I’m investigating now.

---

<div class="post-metadata">

### Author: ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)
#### Post date: [May 29, 2020, 6:47pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/18 "2020-05-29T18:47:25Z")

</div>

Great! Glad you could (mostly) repro. Thanks again for putting so much time into this.

---

<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: [May 29, 2020, 6:54pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/19 "2020-05-29T18:54:52Z")

</div>

One thing that would greatly help here is if you can create a minimal example that reproduces this. I would like to use it as a test case for the bugfix.

---

<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: [May 29, 2020, 7:07pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290/20 "2020-05-29T19:07:29Z")

</div>

Scratch that, I have a minimal example:

```cmake
cmake_minimum_required(VERSION 3.17)
project(test C)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

add_library(testlib SHARED empty.c)

```

The problem is with `CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS`. I’ve opened [cmake/cmake#20775](https://gitlab.kitware.com/cmake/cmake/-/issues/20775) for this issue.

[Next page](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290.md?page=2)
