llvm.org GIT mirror llvm / 52c6452
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 NAKAMURA Takumi 2 years ago
1 changed file(s) with 26 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1313 message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
1414 endif()
1515
16 file(GLOB local_tds "*.td")
17 file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
16 # Use depfile instead of globbing arbitrary *.td(s)
17 # DEPFILE is available for Ninja Generator with CMake>=3.7.
18 if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_VERSION VERSION_LESS 3.7)
19 # Make output path relative to build.ninja, assuming located on
20 # ${CMAKE_BINARY_DIR}.
21 # CMake emits build targets as relative paths but Ninja doesn't identify
22 # absolute path (in *.d) as relative path (in build.ninja)
23 # Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
24 file(RELATIVE_PATH ofn_rel
25 ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
26 set(additional_cmdline
27 -o ${ofn_rel}.tmp
28 -d ${ofn_rel}.d
29 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
30 DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
31 )
32 set(local_tds)
33 set(global_tds)
34 else()
35 file(GLOB local_tds "*.td")
36 file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
37 set(additional_cmdline
38 -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
39 )
40 endif()
1841
1942 if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
2043 set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
4366 COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
4467 ${LLVM_TABLEGEN_FLAGS}
4568 ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
46 -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
69 ${additional_cmdline}
4770 # The file in LLVM_TARGET_DEFINITIONS may be not in the current
4871 # directory and local_tds may not contain it, so we must
4972 # explicitly list it here: