From 1786706c9b7f4b291caa77806c7daef229f9ca6e Mon Sep 17 00:00:00 2001
From: Afshin Pir <afshinpir@users.noreply.github.com>
Date: Wed, 29 Jul 2020 21:19:56 +0430
Subject: [PATCH] Previously, I had incorrectly used some newer features of
 CMake(version 3.14). But Now I have updated this code to work with older
 versions of CMake too.

---
 cmake/protobuf-config.cmake.in | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in
index 11b85d3c0..fac5efe44 100644
--- a/cmake/protobuf-config.cmake.in
+++ b/cmake/protobuf-config.cmake.in
@@ -99,13 +99,17 @@ function(protobuf_generate)
   foreach(_proto ${protobuf_generate_PROTOS})
     get_filename_component(_abs_file ${_proto} ABSOLUTE)
     get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
-    get_filename_component(_basename ${_proto} NAME_WLE)
+
+    get_filename_component(_file_full_name ${_proto} NAME)
+    string(FIND "${_file_full_name}" "." _file_last_ext_pos REVERSE)
+    string(SUBSTRING "${_file_full_name}" 0 ${_file_last_ext_pos} _basename)

     set(_suitable_include_found FALSE)
     foreach(DIR ${_protobuf_include_path})
       if(NOT DIR STREQUAL "-I")
         file(RELATIVE_PATH _rel_dir ${DIR} ${_abs_dir})
-        if(NOT "${_rel_dir}" MATCHES "^\.\.[/\\].*")
+        string(FIND "${_rel_dir}" "../" _is_in_parent_folder)
+        if (NOT ${_is_in_parent_folder} EQUAL 0)
           set(_suitable_include_found TRUE)
           break()
         endif()
--
