From eb3bc0ba5fae174160ef3822bb5c1fa9e093d410 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Fri, 24 Apr 2015 17:09:20 +0000 Subject: [PATCH] [CMake] Fix for PR 23328: LLVM_OPTIMIZED_TABLEGEN broken In CMake dependencies can be filenames or targets, and targets can't be filenames. The Ninja generator handles filename dependencies because it generates targets for every output file from a command. For example: add_custom_command(OUTPUT foo.txt COMMAND touch foo.txt) With the Ninja generator this generates a target foo.txt, but with the Makefile generator it doesn't. This is probably because Ninja explicitly requires these hard dependency ties, and Make just behaves oddly in general. To fix this we need to make the tablegen actions depend on a target rather than a filename. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235732 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/TableGen.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake index bb0d844605f..97e272b04a5 100644 --- a/cmake/modules/TableGen.cmake +++ b/cmake/modules/TableGen.cmake @@ -32,7 +32,7 @@ function(tablegen project ofn) # The file in LLVM_TARGET_DEFINITIONS may be not in the current # directory and local_tds may not contain it, so we must # explicitly list it here: - DEPENDS ${${project}_TABLEGEN_EXE} ${local_tds} ${global_tds} + DEPENDS ${${project}_TABLEGEN_TARGET} ${local_tds} ${global_tds} ${LLVM_TARGET_DEFINITIONS_ABSOLUTE} COMMENT "Building ${ofn}..." ) @@ -90,6 +90,7 @@ macro(add_tablegen target project) # Effective tblgen executable to be used: set(${project}_TABLEGEN_EXE ${${project}_TABLEGEN} PARENT_SCOPE) + set(${project}_TABLEGEN_TARGET ${${project}_TABLEGEN} PARENT_SCOPE) if(LLVM_USE_HOST_TOOLS) if( ${${project}_TABLEGEN} STREQUAL "${target}" ) @@ -101,8 +102,8 @@ macro(add_tablegen target project) DEPENDS CONFIGURE_LLVM_NATIVE ${target} WORKING_DIRECTORY ${LLVM_NATIVE_BUILD} COMMENT "Building native TableGen...") - add_custom_target(${project}NativeTableGen DEPENDS ${${project}_TABLEGEN_EXE}) - add_dependencies(${project}NativeTableGen CONFIGURE_LLVM_NATIVE) + add_custom_target(${project}-tablegen-host DEPENDS ${${project}_TABLEGEN_EXE}) + set(${project}_TABLEGEN_TARGET ${project}-tablegen-host PARENT_SCOPE) endif() endif() -- 2.34.1