From f40a480b72956ded588ecdad25b4996ac92e6ae5 Mon Sep 17 00:00:00 2001
From: Treeve Jelbert <treeve@sourcemage.org>
Date: Sat, 6 Jun 2015 14:14:47 +0200
Subject: [PATCH] add an option to regenerate files using bison/flex. setting
 this will change these files in the source tree

---
 src/CMakeLists.txt | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 38c904a..9489b72 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,6 +3,7 @@ simple_option(KDB_EXPRESSION_DEBUG "Debugging of Expression classes" OFF)
 simple_option(KDB_DRIVERMANAGER_DEBUG "Debugging of the Driver Manager class" OFF)
 simple_option(KDB_TRANSACTIONS_DEBUG "Debugging of the Transaction class" OFF)
 simple_option(KDB_DEBUG_GUI "GUI for debugging" OFF)
+simple_option(KDB_REGEN "regenerate files" OFF)
 configure_file(config-kdb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdb.h)
 
 add_subdirectory(drivers)
@@ -12,6 +13,7 @@ add_definitions(
     -D__KDB__=
 )
 
+if($KDB_REGEN)
 ########### generate parser/lexer files ###############
 # as described at http://public.kitware.com/pipermail/cmake/2002-September/003028.html
 
@@ -29,6 +31,13 @@ add_custom_command(
         ${PARSER_SOURCE_DIR}/generated/sqlscanner.cpp
     COMMENT "Creating parser/lexer files"
 )
+# Mark files as generated
+set_source_files_properties(
+    ${PARSER_SOURCE_DIR}/generated/sqlparser.h
+    ${PARSER_SOURCE_DIR}/generated/sqlparser.cpp
+    ${PARSER_SOURCE_DIR}/generated/sqlscanner.cpp
+  PROPERTIES GENERATED TRUE)
+endif()
 
 string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
 if("${CMAKE_BUILD_TYPE_LOWER}" MATCHES "debug")
@@ -39,20 +48,18 @@ if(WIN32)
     set(EXTRA_PARSER_COMPILE_FLAGS "-DYY_NO_UNISTD_H=1")
 endif()
 
-# Mark files as generated, set compile flags
-set_source_files_properties(${PARSER_SOURCE_DIR}/generated/sqlparser.cpp
+# set compile flags
+
+set_source_files_properties(parser/generated/sqlparser.cpp
     PROPERTIES
-        GENERATED TRUE
         # YYERROR_VERBOSE=1 needed to get a token table for tokenName() even for release builds
         COMPILE_FLAGS "-DYYERROR_VERBOSE=1 ${EXTRA_PARSER_COMPILE_FLAGS} "
 )
-set_source_files_properties(${PARSER_SOURCE_DIR}/generated/sqlparser.h PROPERTIES GENERATED TRUE)
 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/kdb/KDbConnectionData_sdc.cpp PROPERTIES GENERATED TRUE)
 
 set_source_files_properties(
-    ${PARSER_SOURCE_DIR}/generated/sqlscanner.cpp
+    parser/generated/sqlscanner.cpp
     PROPERTIES
-        GENERATED TRUE
         COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-function "
 )
 
-- 
2.4.1

