2023-12-28 04:13:34 +08:00
|
|
|
message(STATUS "Enabling onnx_c_importer...")
|
|
|
|
|
|
|
|
include(FetchContent)
|
|
|
|
|
build: find Protobuf using config mode search (#2900)
This patch makes the Protobuf package mandatory in addition to forcing a
config mode search. The (default) module mode search looks for the
CMake-provided FindProtobuf.cmake file, but this file does not list
Abseil as a dependency, causing linker issues like the one below:
```
ld: Undefined symbols:
absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__1::basic_string_view<char, std::__1::char_traits<char>>), referenced from:
google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::RepeatedPtrField<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TypeHandler>(int) const (.cold.1) in OnnxImporter.cpp.o
```
By forcing a config mode search, CMake looks for the file that is
installed as part of the protobuf package and which does contain the
Abseil dependency. This workaround is also mentioned in a GitHub issue
for Protobuf:
https://github.com/protocolbuffers/protobuf/issues/12292#issuecomment-1529680040.
2024-02-13 07:31:41 +08:00
|
|
|
find_package(Protobuf REQUIRED CONFIG)
|
2023-12-28 04:13:34 +08:00
|
|
|
|
|
|
|
option(ONNX_DISABLE_EXCEPTIONS "For compatibility with LLVM build" ON)
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
onnx
|
|
|
|
EXCLUDE_FROM_ALL
|
|
|
|
GIT_REPOSITORY https://github.com/onnx/onnx.git
|
|
|
|
GIT_TAG v1.15.0
|
|
|
|
GIT_SHALLOW ON
|
|
|
|
GIT_PROGRESS ON
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(onnx)
|
|
|
|
|
|
|
|
add_llvm_executable(
|
|
|
|
torch-mlir-import-onnx
|
|
|
|
PARTIAL_SOURCES_INTENDED
|
|
|
|
|
|
|
|
import-onnx-main.cpp
|
|
|
|
OnnxImporter.h
|
|
|
|
OnnxImporter.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
torch-mlir-import-onnx
|
|
|
|
LLVMSupport
|
|
|
|
MLIRCAPIIR
|
|
|
|
TorchMLIRCAPI
|
|
|
|
onnx
|
|
|
|
)
|