From 5e32d18fc20783bce0eecf15161a9f295b69dc67 Mon Sep 17 00:00:00 2001
From: Reid Kleckner <reid@kleckner.net>
Date: Wed, 5 Nov 2014 20:30:55 +0000
Subject: [PATCH] cmake: Conditionalize CodeGen's dependency on intrinsics_gen

Custom targets in cmake cannot be exported, and this dependency is only
needed in the combined build to ensure that Intrinsics.gen is created
before compiling CodeGen. In the standalone, all of LLVM is build first.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221391 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/CodeGen/CMakeLists.txt | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/CodeGen/CMakeLists.txt b/lib/CodeGen/CMakeLists.txt
index 2c38c24d677..10c2409f6bf 100644
--- a/lib/CodeGen/CMakeLists.txt
+++ b/lib/CodeGen/CMakeLists.txt
@@ -16,6 +16,15 @@ set(LLVM_LINK_COMPONENTS
   TransformUtils
   )
 
+# In a standard Clang+LLVM build, we need to generate intrinsics before
+# building codegen. In a standalone build, LLVM is already built and we don't
+# need this dependency. Furthermore, LLVM doesn't export it so we can't have
+# this dependency.
+set(codegen_deps intrinsics_gen)
+if (CLANG_BUILT_STANDALONE)
+  set(codegen_deps)
+endif()
+
 add_clang_library(clangCodeGen
   BackendUtil.cpp
   CGAtomic.cpp
@@ -65,7 +74,7 @@ add_clang_library(clangCodeGen
   TargetInfo.cpp
 
   DEPENDS
-  intrinsics_gen
+  ${codegen_deps}
 
   LINK_LIBS
   clangAST
-- 
GitLab