CMake: Builds main LLVM Target library before its sublibraries. This
authorOscar Fuentes <ofv@wanadoo.es>
Fri, 14 Aug 2009 05:17:24 +0000 (05:17 +0000)
committerOscar Fuentes <ofv@wanadoo.es>
Fri, 14 Aug 2009 05:17:24 +0000 (05:17 +0000)
way we ensure that tablegenned files exist before they are #include'd
by the LLVM Target sublibraries. Required for parallel builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78996 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
cmake/modules/AddLLVM.cmake

index 068ef963aff2c20491cde55a8b8445d13e69a2b0..32dcae79f639db50e80d6ef15d48d04a80652e25 100644 (file)
@@ -266,6 +266,7 @@ set(LLVM_ENUM_ASM_PRINTERS "")
 set(LLVM_ENUM_ASM_PARSERS "")
 foreach(t ${LLVM_TARGETS_TO_BUILD})
   message(STATUS "Targeting ${t}")
+  set(CURRENT_LLVM_TARGET ${t})
   add_subdirectory(lib/Target/${t})
   add_subdirectory(lib/Target/${t}/TargetInfo)
   if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
@@ -278,6 +279,7 @@ foreach(t ${LLVM_TARGETS_TO_BUILD})
     set(LLVM_ENUM_ASM_PARSERS 
       "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n")
   endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmParser/CMakeLists.txt )
+  set(CURRENT_LLVM_TARGET)
 endforeach(t)
 
 # Produce llvm/Config/AsmPrinters.def
index 0d263f83655089d9dae5eed2f7d290083745e20f..597160326047ed4edfef89e6d8b5cd3a27771908 100755 (executable)
@@ -12,6 +12,13 @@ macro(add_llvm_library name)
   install(TARGETS ${name}
     LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
     ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+  # The LLVM Target library shall be built before its sublibraries
+  # (asmprinter, etc) because those may use tablegenned files which
+  # generation is triggered by the main LLVM target library. Necessary
+  # for parallel builds:
+  if( CURRENT_LLVM_TARGET )
+    add_dependencies(${name} LLVM${CURRENT_LLVM_TARGET})
+  endif()
 endmacro(add_llvm_library name)