Commit 4461b0f9 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-16424 replace cmake/bison.cmake with cmake's builtin FindBison module

parent 62d21dda
Branches unavailable
Tags unavailable
No related merge requests found
# Copyright (c) 2009 Sun Microsystems, Inc.
# Use is subject to license terms.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
# On Solaris, /opt/csw often contains a newer bison
IF(NOT BISON_EXECUTABLE AND EXISTS /opt/csw/bin/bison)
SET(BISON_EXECUTABLE /opt/csw/bin/bison)
ENDIF()
ENDIF()
IF(WIN32)
SET(BISON_PATH_HINTS
HINTS
C:/gnuwin32/bin
C:/cygwin64/bin
C:/cygwin/bin)
ENDIF()
FIND_PROGRAM(BISON_EXECUTABLE bison
${BISON_PATH_HINTS}
DOC "path to the bison executable")
MARK_AS_ADVANCED(BISON_EXECUTABLE "")
IF(NOT BISON_EXECUTABLE)
MESSAGE("Warning: Bison executable not found in PATH")
ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE)
# Check version as well
EXEC_PROGRAM(${BISON_EXECUTABLE} ARGS --version OUTPUT_VARIABLE BISON_VERSION_STR)
# Get first line in case it's multiline
STRING(REGEX REPLACE "([^\n]+).*" "\\1" FIRST_LINE "${BISON_VERSION_STR}")
# get version information
STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\1" BISON_VERSION_MAJOR "${FIRST_LINE}")
STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\2" BISON_VERSION_MINOR "${FIRST_LINE}")
IF (BISON_VERSION_MAJOR LESS 2)
MESSAGE("Warning: bison version is old. please update to version 2")
ELSE()
SET(BISON_USABLE 1 CACHE INTERNAL "Bison version 2 or higher")
ENDIF()
ENDIF()
# Use bison to generate C++ and header file
MACRO (RUN_BISON input_yy output_cc output_h name_prefix)
IF(BISON_TOO_OLD)
IF(EXISTS ${output_cc} AND EXISTS ${output_h})
SET(BISON_USABLE FALSE)
ENDIF()
ENDIF()
IF(BISON_USABLE)
# Workaround for VS regenerating output even
# when outputs are up-to-date. At least, fix output timestamp
# after build so that files that depend on generated header are
# not rebuilt.
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
FIND_PROGRAM(TOUCH_EXECUTABLE touch DOC "Path to touch executable"
PATHS "C:/Program Files/Git/usr/bin"
"C:/Program Files (x86)/Git/usr/bin")
IF(TOUCH_EXECUTABLE)
SET(VS_FIX_OUTPUT_TIMESTAMPS
COMMAND ${TOUCH_EXECUTABLE} -r ${input_yy} ${output_cc}
COMMAND ${TOUCH_EXECUTABLE} -r ${input_yy} ${output_h})
ENDIF()
ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${output_cc}
${output_h}
COMMAND ${BISON_EXECUTABLE} -y -p ${name_prefix}
--output=${output_cc}
--defines=${output_h}
${input_yy}
${VS_FIX_OUTPUT_TIMESTAMPS}
DEPENDS ${input_yy}
)
ELSE()
# Bison is missing or not usable, e.g too old
IF(EXISTS ${output_cc} AND EXISTS ${output_h})
IF(${input_yy} IS_NEWER_THAN ${output_cc} OR ${input_yy} IS_NEWER_THAN ${output_h})
# Possibly timestamps are messed up in source distribution.
MESSAGE("Warning: no usable bison found, ${input_yy} will not be rebuilt.")
ENDIF()
ELSE()
# Output files are missing, bail out.
SET(ERRMSG
"Bison (GNU parser generator) is required to build MySQL."
"Please install bison."
)
IF(WIN32)
SET(ERRMSG ${ERRMSG}
"You can download bison from http://gnuwin32.sourceforge.net/packages/bison.htm "
"Choose 'Complete package, except sources' installation. We recommend to "
"install bison into a directory without spaces, e.g C:\\GnuWin32.")
ENDIF()
MESSAGE(FATAL_ERROR ${ERRMSG})
ENDIF()
ENDIF()
ENDMACRO()
...@@ -67,8 +67,8 @@ IF(NOT GIT_EXECUTABLE) ...@@ -67,8 +67,8 @@ IF(NOT GIT_EXECUTABLE)
# Save bison output first. # Save bison output first.
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql_yacc.cc COPYONLY) ${CMAKE_BINARY_DIR}/sql_yacc.cc COPYONLY)
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql_yacc.h COPYONLY) ${CMAKE_BINARY_DIR}/sql_yacc.hh COPYONLY)
IF(CMAKE_GENERATOR MATCHES "Makefiles") IF(CMAKE_GENERATOR MATCHES "Makefiles")
# make clean # make clean
...@@ -81,10 +81,10 @@ IF(NOT GIT_EXECUTABLE) ...@@ -81,10 +81,10 @@ IF(NOT GIT_EXECUTABLE)
# Restore bison output # Restore bison output
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.cc CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPYONLY) ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPYONLY)
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.h CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPYONLY) ${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPYONLY)
FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.cc) FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.cc)
FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.h) FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.hh)
ENDIF() ENDIF()
EXECUTE_PROCESS( EXECUTE_PROCESS(
...@@ -102,10 +102,15 @@ IF(NOT GIT_EXECUTABLE) ...@@ -102,10 +102,15 @@ IF(NOT GIT_EXECUTABLE)
ENDIF() ENDIF()
# Copy bison output # Copy bison output
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
${PACKAGE_DIR}/sql/sql_yacc.h COPYONLY) ${PACKAGE_DIR}/sql/sql_yacc.hh COPYONLY)
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY) ${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY)
# Copy bison output
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
${PACKAGE_DIR}/sql/sql_yacc_ora.hh COPYONLY)
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
${PACKAGE_DIR}/sql/sql_yacc_orac.cc COPYONLY)
# Add documentation, if user has specified where to find them # Add documentation, if user has specified where to find them
IF(MYSQL_DOCS_LOCATION) IF(MYSQL_DOCS_LOCATION)
......
...@@ -28,9 +28,9 @@ ${SSL_INTERNAL_INCLUDE_DIRS} ...@@ -28,9 +28,9 @@ ${SSL_INTERNAL_INCLUDE_DIRS}
) )
SET(GEN_SOURCES SET(GEN_SOURCES
${CMAKE_BINARY_DIR}/sql/sql_yacc.h ${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.h ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc
${CMAKE_BINARY_DIR}/sql/lex_hash.h ${CMAKE_BINARY_DIR}/sql/lex_hash.h
) )
......
...@@ -45,23 +45,10 @@ ${CMAKE_BINARY_DIR}/sql ...@@ -45,23 +45,10 @@ ${CMAKE_BINARY_DIR}/sql
${WSREP_INCLUDES} ${WSREP_INCLUDES}
) )
SET(GEN_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
)
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES}
PROPERTIES GENERATED 1)
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(gen_lex_token gen_lex_token.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h)
ENDIF()
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
...@@ -151,7 +138,10 @@ SET (SQL_SOURCE ...@@ -151,7 +138,10 @@ SET (SQL_SOURCE
table_cache.cc encryption.cc temporary_tables.cc table_cache.cc encryption.cc temporary_tables.cc
proxy_protocol.cc proxy_protocol.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc ${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
${GEN_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
${MYSYS_LIBWRAP_SOURCE} ${MYSYS_LIBWRAP_SOURCE}
) )
...@@ -173,7 +163,6 @@ MYSQL_ADD_PLUGIN(sql_sequence ha_sequence.cc STORAGE_ENGINE MANDATORY STATIC_ONL ...@@ -173,7 +163,6 @@ MYSQL_ADD_PLUGIN(sql_sequence ha_sequence.cc STORAGE_ENGINE MANDATORY STATIC_ONL
RECOMPILE_FOR_EMBEDDED) RECOMPILE_FOR_EMBEDDED)
ADD_LIBRARY(sql STATIC ${SQL_SOURCE}) ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
ADD_DEPENDENCIES(sql GenServerSource)
DTRACE_INSTRUMENT(sql) DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS} TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
mysys mysys_ssl dbug strings vio pcre mysys mysys_ssl dbug strings vio pcre
...@@ -339,40 +328,48 @@ IF(WITH_MYSQLD_LDFLAGS) ...@@ -339,40 +328,48 @@ IF(WITH_MYSQLD_LDFLAGS)
"${MYSQLD_LINK_FLAGS} ${WITH_MYSQLD_LDFLAGS}") "${MYSQLD_LINK_FLAGS} ${WITH_MYSQLD_LDFLAGS}")
ENDIF() ENDIF()
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
FIND_PACKAGE(BISON 2.0)
# Handle out-of-source build from source package with possibly broken # Handle out-of-source build from source package with possibly broken
# bison. Copy bison output to from source to build directory, if not already # bison. Copy bison output to from source to build directory, if not already
# there # there
IF (NOT BISON_USABLE) IF (NOT BISON_FOUND)
IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc) FOREACH(file sql_yacc.cc sql_yacc.hh sql_yacc_ora.cc sql_yacc_ora.hh)
IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc) IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file} AND (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${file}))
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc COPYONLY) ${CMAKE_CURRENT_BINARY_DIR}/${file} COPYONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h COPYONLY)
ENDIF() ENDIF()
ENDFOREACH()
ENDIF() ENDIF()
ENDIF()
ENDIF()
RUN_BISON( IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc)
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy # Output files are missing, bail out.
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc SET(ERRMSG
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h "Bison (GNU parser generator) is required to build MySQL."
MYSQL "Please install bison."
) )
IF(WIN32)
SET(ERRMSG ${ERRMSG}
"You can download bison from http://gnuwin32.sourceforge.net/packages/bison.htm "
"Choose 'Complete package, except sources' installation. We recommend to "
"install bison into a directory without spaces, e.g C:\\GnuWin32.")
ENDIF()
MESSAGE(FATAL_ERROR ${ERRMSG})
ENDIF()
ELSE()
BISON_TARGET(gen_sql_yacc ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
COMPILE_FLAGS "-p MYSQL")
RUN_BISON( BISON_TARGET(gen_sql_yacc_ora ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc_ora.yy ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc_ora.yy COMPILE_FLAGS "-p ORA")
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc ENDIF()
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
ORA
)
# Gen_lex_hash
IF(NOT CMAKE_CROSSCOMPILING) IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(gen_lex_token gen_lex_token.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.hh)
ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc) ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
ENDIF() ENDIF()
...@@ -388,12 +385,12 @@ TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql mysys mysys_ssl) ...@@ -388,12 +385,12 @@ TARGET_LINK_LIBRARIES(mysql_tzinfo_to_sql mysys mysys_ssl)
ADD_CUSTOM_TARGET( ADD_CUSTOM_TARGET(
GenServerSource GenServerSource
DEPENDS ${GEN_SOURCES} DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
) )
#Need this only for embedded
SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE)
IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED) IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED)
ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def) ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def)
SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "")
...@@ -406,8 +403,8 @@ CONFIGURE_FILE( ...@@ -406,8 +403,8 @@ CONFIGURE_FILE(
ADD_CUSTOM_TARGET(dist ADD_CUSTOM_TARGET(dist
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake
DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.h DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.hh
DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.h DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
/* We only need the tokens here */ /* We only need the tokens here */
#define YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED
#include <sql_yacc.h> #include <sql_yacc.hh>
#include <lex.h> #include <lex.h>
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ #include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "sql_get_diagnostics.h" #include "sql_get_diagnostics.h"
/* Generated code */ /* Generated code */
#include "sql_yacc.h" #include "sql_yacc.hh"
#define LEX_TOKEN_WITH_DEFINITION #define LEX_TOKEN_WITH_DEFINITION
#include "lex_token.h" #include "lex_token.h"
......
...@@ -269,10 +269,10 @@ struct LEX_TYPE ...@@ -269,10 +269,10 @@ struct LEX_TYPE
#else #else
#include "lex_symbol.h" #include "lex_symbol.h"
#ifdef MYSQL_LEX #ifdef MYSQL_LEX
#include "item_func.h" /* Cast_target used in sql_yacc.h */ #include "item_func.h" /* Cast_target used in sql_yacc.hh */
#include "sql_get_diagnostics.h" /* Types used in sql_yacc.h */ #include "sql_get_diagnostics.h" /* Types used in sql_yacc.hh */
#include "sp_pcontext.h" #include "sp_pcontext.h"
#include "sql_yacc.h" #include "sql_yacc.hh"
#define LEX_YYSTYPE YYSTYPE * #define LEX_YYSTYPE YYSTYPE *
#else #else
#define LEX_YYSTYPE void * #define LEX_YYSTYPE void *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment