diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8b7fb76..3aa0f1f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -69,12 +69,23 @@ if (SPM_USE_BUILTIN_PROTOBUF)
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/protobuf-lite)
   include_directories(builtin_pb)
 else()
-  find_package(Protobuf REQUIRED)
+  include_directories(${REPO_ROOT}/cmake/external/protobuf/src)
+  if(EXISTS "${ONNX_CUSTOM_PROTOC_EXECUTABLE}")
+    set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
+  else()
+    set(PROTOC_EXECUTABLE ${CMAKE_BINARY_DIR}/external/protobuf/cmake/protoc)
+  endif()
+  execute_process(COMMAND ${PROTOC_EXECUTABLE} --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/builtin_pb --proto_path=${CMAKE_CURRENT_SOURCE_DIR} sentencepiece_model.proto)
+  execute_process(COMMAND ${PROTOC_EXECUTABLE} --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/builtin_pb --proto_path=${CMAKE_CURRENT_SOURCE_DIR} sentencepiece.proto)
   include_directories(${Protobuf_INCLUDE_DIRS})
-  protobuf_generate_cpp(SPM_PROTO_SRCS SPM_PROTO_HDRS sentencepiece.proto)
-  protobuf_generate_cpp(SPM_MODEL_PROTO_SRCS SPM_MODEL_PROTO_HDRS sentencepiece_model.proto)
   set(PROTOBUF_LITE_SRCS "")
+  set(PROTOBUF_LITE_LIBRARY "")
   include_directories(${PROTOBUF_INCLUDE_DIR})
+  include_directories(builtin_pb)
+  set(SPM_PROTO_HDRS builtin_pb/sentencepiece.pb.h)
+  set(SPM_PROTO_SRCS builtin_pb/sentencepiece.pb.cc)
+  set(SPM_MODEL_PROTO_HDRS builtin_pb/sentencepiece_model.pb.h)
+  set(SPM_MODEL_PROTO_SRCS builtin_pb/sentencepiece_model.pb.cc)
 endif()
 
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index d00ecba..b355ccc 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -1,4 +1,4 @@
-include_directories(absl/strings darts_clone esaxx protobuf-lite)
+include_directories(absl/strings darts_clone esaxx)
 
 
 
