Skip to content

Commit 97c03eb

Browse files
authored
Potential tablegen dependency fix (#139)
This PR attempts to fix a missing dependency issue in the cmake system. Occasionally we will run into build errors of the form: ``` No such file or directory 28 | #include "Dialect/QUIR/IR/QUIRTypes.h.inc" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` This is caused by a missing dependency between the files created by tablegen and any source file that attempts to include something that includes them (such as the dialect headers). I have added explicit dependencies to the `mlir-headers` cmake target that is defined by `add_mlir_dialect` to hopefully resolve this problem. Unfortunately source file creation is not a typical part of the build process outside of LLVM, so it's hard to be sure that cmake will still respect this dependency the way we want.
1 parent f134762 commit 97c03eb

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ endforeach()
382382
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES})
383383

384384
add_library(qss-compiler-opt ${SOURCE_FILES})
385+
add_dependencies(qss-compiler-opt mlir-headers)
385386

386387
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
387388
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})

lib/API/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ target_sources(QSSCAPI
2626
FILES ${QSSC_INCLUDE_DIR}/API/api.h ${QSSC_INCLUDE_DIR}/API/error.h
2727
)
2828

29-
add_dependencies(QSSCAPI QSSCError MLIROQ3Dialect MLIRQCSDialect MLIRQUIRDialect)
29+
add_dependencies(QSSCAPI QSSCError MLIROQ3Dialect MLIRQCSDialect MLIRQUIRDialect mlir-headers)

lib/Arguments/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
# that they have been altered from the originals.
1212

1313
add_library(QSSCArguments Signature.cpp Arguments.cpp)
14+
add_dependencies(QSSCArguments mlir-headers)
1415

1516
target_link_libraries(QSSCArguments QSSCPayloadZip libzip::zip)

lib/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set(SOURCES
2424
QSSC.cpp
2525
)
2626
add_library(QSSCCore ${SOURCES})
27+
add_dependencies(QSSCCore mlir-headers)
2728

2829
get_property(qssc_targets GLOBAL PROPERTY QSSC_TARGETS)
2930
get_property(mlir_dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
@@ -59,6 +60,7 @@ set_property(GLOBAL PROPERTY QSSC_API_LIBS ${qssc_api_libs})
5960
# INTERFACE and dependencies to all targets that refer to the library yet does
6061
# not materialize as an artifact by itself
6162
add_library(QSSCLib INTERFACE)
63+
add_dependencies(QSSCLib mlir-headers)
6264
target_link_libraries(QSSCLib INTERFACE ${qssc_api_libs})
6365

6466
if(INSTALL_BUNDLED_STATIC_LIB)
@@ -67,6 +69,7 @@ if(INSTALL_BUNDLED_STATIC_LIB)
6769
# If you consider adding that support, MacOS's libtool could be an option since it appears capable of bundling static libraries.
6870
endif()
6971
add_library(QSSCompiler STATIC API/api.cpp)
72+
add_dependencies(QSSCompiler mlir-headers)
7073
target_link_libraries(QSSCompiler PUBLIC
7174
${qssc_targets}
7275
QSSCAPI

lib/Payload/ZipPayload/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ qssc_add_plugin(QSSCPayloadZip QSSC_PAYLOAD_PLUGIN
3030
PLUGIN_REGISTRATION_HEADERS
3131
${CMAKE_CURRENT_SOURCE_DIR}/Payload.inc
3232
)
33+
34+
add_dependencies(QSSCPayloadZip mlir-headers)

0 commit comments

Comments
 (0)