From 42abf1d299fed8e00a189f6f9c55fb344e5bb775 Mon Sep 17 00:00:00 2001
From: Oleksiy Obitotskyy <oobitots@cisco.com>
Date: Wed, 27 Jan 2021 04:01:34 -0800
Subject: [PATCH] bison: Remove #line directives

Append --no-lines option to bison to not
generate #line directives with absolute file path.

Upstream-Status: Pending
Signed-off-by: Oleksiy Obitotskyy <oobitots@cisco.com>
---
 cmake/modules/FindYACC.cmake | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/cmake/modules/FindYACC.cmake b/cmake/modules/FindYACC.cmake
index c96f87b..54a73cb 100644
--- a/cmake/modules/FindYACC.cmake
+++ b/cmake/modules/FindYACC.cmake
@@ -29,15 +29,28 @@ MACRO(ADD_YACC_FILES _source _generated)
 
       SET(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.c)
 
-      ADD_CUSTOM_COMMAND(
-         OUTPUT ${_out}
-         COMMAND ${YACC_EXECUTABLE}
-           -d
-           -p ${_basename}
-           -o${_out}
-           ${_in}
-         DEPENDS ${_in}
-      )
+      IF (DEFINED ENV{SOURCE_DATE_EPOCH})
+         ADD_CUSTOM_COMMAND(
+            OUTPUT ${_out}
+            COMMAND ${YACC_EXECUTABLE}
+              --no-lines
+              -d
+              -p ${_basename}
+              -o${_out}
+              ${_in}
+            DEPENDS ${_in}
+         )
+      ELSE ()
+         ADD_CUSTOM_COMMAND(
+            OUTPUT ${_out}
+            COMMAND ${YACC_EXECUTABLE}
+              -d
+              -p ${_basename}
+              -o${_out}
+              ${_in}
+            DEPENDS ${_in}
+         )
+      ENDIF ()
       LIST(APPEND ${_source} ${_in})
       LIST(APPEND ${_generated} ${_out})
    ENDFOREACH (_current_FILE)
-- 
2.26.2.Cisco

