summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2017-06-21 22:04:07 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2017-06-21 22:04:07 +0000
commit52c64527391040043b8024a0662936da6325f0b5 (patch)
treef3a3e6042d0013422243d96e443e854903186e3e /cmake
parent998914d3010de151a99ac385ad0bfa786404c9da (diff)
TableGen.cmake: Use DEPFILE for Ninja Generator with CMake>=3.7.
CMake emits build targets as relative paths (from build.ninja) but Ninja doesn't identify absolute path (in *.d) as relative path (in build.ninja). So, let file names, in the command line, relative from ${CMAKE_BINARY_DIR}, where build.ninja is. Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory. Differential Revision: https://reviews.llvm.org/D33707 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/TableGen.cmake29
1 files changed, 26 insertions, 3 deletions
diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake
index 66d36fa5b50f..8c3e2d7d7004 100644
--- a/cmake/modules/TableGen.cmake
+++ b/cmake/modules/TableGen.cmake
@@ -14,8 +14,31 @@ function(tablegen project ofn)
message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
endif()
- file(GLOB local_tds "*.td")
- file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
+ # Use depfile instead of globbing arbitrary *.td(s)
+ # DEPFILE is available for Ninja Generator with CMake>=3.7.
+ if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_VERSION VERSION_LESS 3.7)
+ # Make output path relative to build.ninja, assuming located on
+ # ${CMAKE_BINARY_DIR}.
+ # CMake emits build targets as relative paths but Ninja doesn't identify
+ # absolute path (in *.d) as relative path (in build.ninja)
+ # Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
+ file(RELATIVE_PATH ofn_rel
+ ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
+ set(additional_cmdline
+ -o ${ofn_rel}.tmp
+ -d ${ofn_rel}.d
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
+ )
+ set(local_tds)
+ set(global_tds)
+ else()
+ file(GLOB local_tds "*.td")
+ file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
+ set(additional_cmdline
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ )
+ endif()
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
@@ -44,7 +67,7 @@ function(tablegen project ofn)
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
${LLVM_TABLEGEN_FLAGS}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
- -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ ${additional_cmdline}
# 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: