<div dir="ltr">Good Idea!  I'll do that.<div><br></div><div>Steve</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 3, 2020 at 10:57 AM Tom Stellard via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 04/03/2020 10:48 AM, Stephen Neuendorffer via llvm-commits wrote:<br>
> <br>
> Author: Stephen Neuendorffer<br>
> Date: 2020-04-03T10:47:36-07:00<br>
> New Revision: f288c216875d6cba6465230cbb0677e839775cd9<br>
> <br>
> URL: <a href="https://github.com/llvm/llvm-project/commit/f288c216875d6cba6465230cbb0677e839775cd9" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/f288c216875d6cba6465230cbb0677e839775cd9</a><br>
> DIFF: <a href="https://github.com/llvm/llvm-project/commit/f288c216875d6cba6465230cbb0677e839775cd9.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/f288c216875d6cba6465230cbb0677e839775cd9.diff</a><br>
> <br>
> LOG: Revert "[CMAKE] Plumb include_directories() into tablegen()"<br>
> <br>
> This reverts commit ae044c5b0caa095602b6ef4cca40d57efc26a8f6.<br>
> <br>
> This breaks the buildbots, which use an older version of cmake.<br>
> <br>
<br>
Would you be able to add a comment to the code where you wanted<br>
to make the change.  Something like:<br>
<br>
FIXME: With cmake X.Y we could simplify this by ...<br>
<br>
It's helpful when deciding which version to upgrade to have<br>
this documented in some way.  I started doing this the last<br>
time this happened to me:<br>
<br>
<a href="https://github.com/llvm/llvm-project/blob/master/clang/tools/clang-shlib/CMakeLists.txt#L22" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/blob/master/clang/tools/clang-shlib/CMakeLists.txt#L22</a><br>
<br>
-Tom<br>
<br>
> Added: <br>
>     <br>
> <br>
> Modified: <br>
>     clang/cmake/modules/AddClang.cmake<br>
>     llvm/cmake/modules/TableGen.cmake<br>
>     mlir/cmake/modules/AddMLIR.cmake<br>
>     mlir/examples/toy/Ch3/CMakeLists.txt<br>
>     mlir/examples/toy/Ch4/CMakeLists.txt<br>
>     mlir/examples/toy/Ch4/include/toy/CMakeLists.txt<br>
>     mlir/examples/toy/Ch5/CMakeLists.txt<br>
>     mlir/examples/toy/Ch5/include/toy/CMakeLists.txt<br>
>     mlir/examples/toy/Ch6/CMakeLists.txt<br>
>     mlir/examples/toy/Ch6/include/toy/CMakeLists.txt<br>
>     mlir/examples/toy/Ch7/CMakeLists.txt<br>
>     mlir/examples/toy/Ch7/include/toy/CMakeLists.txt<br>
> <br>
> Removed: <br>
>     <br>
> <br>
> <br>
> ################################################################################<br>
> diff  --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake<br>
> index c1bb386de6f7..577cc11ab015 100644<br>
> --- a/clang/cmake/modules/AddClang.cmake<br>
> +++ b/clang/cmake/modules/AddClang.cmake<br>
> @@ -17,7 +17,7 @@ function(clang_tablegen)<br>
>      message(FATAL_ERROR "SOURCE source-file required by clang_tablegen")<br>
>    endif()<br>
>  <br>
> -  set( CLANG_TABLEGEN_ARGUMENTS "" )<br>
> +  set( CLANG_TABLEGEN_ARGUMENTS -I ${CLANG_SOURCE_DIR}/include )<br>
>    set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )<br>
>    tablegen(CLANG ${CTG_UNPARSED_ARGUMENTS} ${CLANG_TABLEGEN_ARGUMENTS})<br>
>  <br>
> <br>
> diff  --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake<br>
> index 8d0c5afabe96..632f69aa3386 100644<br>
> --- a/llvm/cmake/modules/TableGen.cmake<br>
> +++ b/llvm/cmake/modules/TableGen.cmake<br>
> @@ -2,6 +2,10 @@<br>
>  # Extra parameters for `tblgen' may come after `ofn' parameter.<br>
>  # Adds the name of the generated file to TABLEGEN_OUTPUT.<br>
>  <br>
> +if(LLVM_MAIN_INCLUDE_DIR)<br>
> +  set(LLVM_TABLEGEN_FLAGS -I ${LLVM_MAIN_INCLUDE_DIR})<br>
> +endif()<br>
> +<br>
>  function(tablegen project ofn)<br>
>    # Validate calling context.<br>
>    if(NOT ${project}_TABLEGEN_EXE)<br>
> @@ -71,8 +75,6 @@ function(tablegen project ofn)<br>
>      set(tblgen_change_flag "--write-if-changed")<br>
>    endif()<br>
>  <br>
> -  get_directory_property(includes "INCLUDE_DIRECTORIES")<br>
> -  list(TRANSFORM includes PREPEND -I)<br>
>    # We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the  DEPENDS list<br>
>    # (both the target and the file) to have .inc files rebuilt on<br>
>    # a tablegen change, as cmake does not propagate file-level dependencies<br>
> @@ -84,7 +86,6 @@ function(tablegen project ofn)<br>
>    # but lets us having smaller and cleaner code here.<br>
>    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}<br>
>      COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}<br>
> -    ${includes}<br>
>      ${LLVM_TABLEGEN_FLAGS}<br>
>      ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}<br>
>      ${tblgen_change_flag}<br>
> <br>
> diff  --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake<br>
> index 7449f54ea877..2adb8f2f2935 100644<br>
> --- a/mlir/cmake/modules/AddMLIR.cmake<br>
> +++ b/mlir/cmake/modules/AddMLIR.cmake<br>
> @@ -1,5 +1,5 @@<br>
>  function(mlir_tablegen ofn)<br>
> -  tablegen(MLIR ${ARGV})<br>
> +  tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")<br>
>    set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}<br>
>        PARENT_SCOPE)<br>
>  endfunction()<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch3/CMakeLists.txt b/mlir/examples/toy/Ch3/CMakeLists.txt<br>
> index ef70dcbac309..4dab5e4d0626 100644<br>
> --- a/mlir/examples/toy/Ch3/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch3/CMakeLists.txt<br>
> @@ -1,4 +1,3 @@<br>
> -include_directories(include)<br>
>  add_subdirectory(include)<br>
>  <br>
>  set(LLVM_LINK_COMPONENTS<br>
> @@ -6,7 +5,7 @@ set(LLVM_LINK_COMPONENTS<br>
>    )<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)<br>
> -mlir_tablegen(ToyCombine.inc -gen-rewriters)<br>
> +mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")<br>
>  add_public_tablegen_target(ToyCh3CombineIncGen)<br>
>  <br>
>  add_toy_chapter(toyc-ch3<br>
> @@ -21,6 +20,7 @@ add_toy_chapter(toyc-ch3<br>
>    ToyCh3CombineIncGen<br>
>    )<br>
>  <br>
> +include_directories(include/)<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR})<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)<br>
>  target_link_libraries(toyc-ch3<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch4/CMakeLists.txt b/mlir/examples/toy/Ch4/CMakeLists.txt<br>
> index ae30a691894e..3589b10645a6 100644<br>
> --- a/mlir/examples/toy/Ch4/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch4/CMakeLists.txt<br>
> @@ -1,4 +1,3 @@<br>
> -include_directories(include)<br>
>  add_subdirectory(include)<br>
>  <br>
>  set(LLVM_LINK_COMPONENTS<br>
> @@ -6,7 +5,7 @@ set(LLVM_LINK_COMPONENTS<br>
>    )<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)<br>
> -mlir_tablegen(ToyCombine.inc -gen-rewriters)<br>
> +mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")<br>
>  add_public_tablegen_target(ToyCh4CombineIncGen)<br>
>  <br>
>  add_toy_chapter(toyc-ch4<br>
> @@ -23,6 +22,7 @@ add_toy_chapter(toyc-ch4<br>
>    ToyCh4CombineIncGen<br>
>    )<br>
>  <br>
> +include_directories(include/)<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR})<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)<br>
>  target_link_libraries(toyc-ch4<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt<br>
> index 7f60477fc272..798d0df1d8d6 100644<br>
> --- a/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt<br>
> @@ -1,6 +1,6 @@<br>
>  set(LLVM_TARGET_DEFINITIONS Ops.td)<br>
> -mlir_tablegen(Ops.h.inc -gen-op-decls)<br>
> -mlir_tablegen(Ops.cpp.inc -gen-op-defs)<br>
> +mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
> +mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
>  add_public_tablegen_target(ToyCh4OpsIncGen)<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch5/CMakeLists.txt b/mlir/examples/toy/Ch5/CMakeLists.txt<br>
> index ba3a88e03c0b..c3627cf11cd7 100644<br>
> --- a/mlir/examples/toy/Ch5/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch5/CMakeLists.txt<br>
> @@ -1,4 +1,3 @@<br>
> -include_directories(include)<br>
>  add_subdirectory(include)<br>
>  <br>
>  set(LLVM_LINK_COMPONENTS<br>
> @@ -6,7 +5,7 @@ set(LLVM_LINK_COMPONENTS<br>
>    )<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)<br>
> -mlir_tablegen(ToyCombine.inc -gen-rewriters)<br>
> +mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")<br>
>  add_public_tablegen_target(ToyCh5CombineIncGen)<br>
>  <br>
>  add_toy_chapter(toyc-ch5<br>
> @@ -24,6 +23,7 @@ add_toy_chapter(toyc-ch5<br>
>    ToyCh5CombineIncGen<br>
>    )<br>
>  <br>
> +include_directories(include/)<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR})<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)<br>
>  get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt<br>
> index e8bd1fc0bc2e..aaa932896d0f 100644<br>
> --- a/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt<br>
> @@ -1,6 +1,6 @@<br>
>  set(LLVM_TARGET_DEFINITIONS Ops.td)<br>
> -mlir_tablegen(Ops.h.inc -gen-op-decls)<br>
> -mlir_tablegen(Ops.cpp.inc -gen-op-defs)<br>
> +mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
> +mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
>  add_public_tablegen_target(ToyCh5OpsIncGen)<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch6/CMakeLists.txt b/mlir/examples/toy/Ch6/CMakeLists.txt<br>
> index be797c6c1e96..5d39a9ab5fc1 100644<br>
> --- a/mlir/examples/toy/Ch6/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch6/CMakeLists.txt<br>
> @@ -1,4 +1,3 @@<br>
> -include_directories(include)<br>
>  add_subdirectory(include)<br>
>  <br>
>  set(LLVM_LINK_COMPONENTS<br>
> @@ -7,7 +6,7 @@ set(LLVM_LINK_COMPONENTS<br>
>    )<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)<br>
> -mlir_tablegen(ToyCombine.inc -gen-rewriters)<br>
> +mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")<br>
>  add_public_tablegen_target(ToyCh6CombineIncGen)<br>
>  <br>
>  add_toy_chapter(toyc-ch6<br>
> @@ -26,6 +25,7 @@ add_toy_chapter(toyc-ch6<br>
>    ToyCh6CombineIncGen<br>
>    )<br>
>  <br>
> +include_directories(include/)<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR})<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)<br>
>  get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt<br>
> index c6adf5a15a73..aecf11fab6c9 100644<br>
> --- a/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt<br>
> @@ -1,6 +1,6 @@<br>
>  set(LLVM_TARGET_DEFINITIONS Ops.td)<br>
> -mlir_tablegen(Ops.h.inc -gen-op-decls)<br>
> -mlir_tablegen(Ops.cpp.inc -gen-op-defs)<br>
> +mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
> +mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
>  add_public_tablegen_target(ToyCh6OpsIncGen)<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch7/CMakeLists.txt b/mlir/examples/toy/Ch7/CMakeLists.txt<br>
> index 9a9f335d3a92..760052ee840f 100644<br>
> --- a/mlir/examples/toy/Ch7/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch7/CMakeLists.txt<br>
> @@ -1,4 +1,3 @@<br>
> -include_directories(include)<br>
>  add_subdirectory(include)<br>
>  <br>
>  set(LLVM_LINK_COMPONENTS<br>
> @@ -7,7 +6,7 @@ set(LLVM_LINK_COMPONENTS<br>
>    )<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)<br>
> -mlir_tablegen(ToyCombine.inc -gen-rewriters)<br>
> +mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")<br>
>  add_public_tablegen_target(ToyCh7CombineIncGen)<br>
>  <br>
>  add_toy_chapter(toyc-ch7<br>
> @@ -26,6 +25,7 @@ add_toy_chapter(toyc-ch7<br>
>    ToyCh7CombineIncGen<br>
>    )<br>
>  <br>
> +include_directories(include/)<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR})<br>
>  include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)<br>
>  get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)<br>
> <br>
> diff  --git a/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt<br>
> index 43eb23bf93b8..fa30bd2e8e03 100644<br>
> --- a/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt<br>
> +++ b/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt<br>
> @@ -1,6 +1,6 @@<br>
>  set(LLVM_TARGET_DEFINITIONS Ops.td)<br>
> -mlir_tablegen(Ops.h.inc -gen-op-decls)<br>
> -mlir_tablegen(Ops.cpp.inc -gen-op-defs)<br>
> +mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
> +mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")<br>
>  add_public_tablegen_target(ToyCh7OpsIncGen)<br>
>  <br>
>  set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)<br>
> <br>
> <br>
>         <br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
> <br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>