File: bison.cmake

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (148 lines) | stat: -rw-r--r-- 5,313 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright (c) 2009, 2025, Oracle and/or its affiliates.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is designed to work with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation.  The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have either included with
# the program or referenced in the documentation.
#
# 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, version 2.0, 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 

# This should be REQUIRED, but we have to support source tarball build.
# https://dev.mysql.com/doc/refman/8.0/en/source-installation.html

SET(MIN_BISON_VERSION_REQUIRED "3.0.4")

# Bison seems to be stuck at version 2.3 in macOS.
# Look for alternative custom installations, e.g.
# /opt/bison-3.8.2/bin
IF(APPLE AND NOT DEFINED BISON_EXECUTABLE)
  SET(OPT_BISON_DIR "/opt")
  IF(IS_DIRECTORY "${OPT_BISON_DIR}")
    SET(PREFERRED_BISON_VERSION "3.8.2")
    FILE(GLOB FOUND_BISON_BIN_DIRS
      LIST_DIRECTORIES true
      "${OPT_BISON_DIR}/bison-*/bin"
      )
    IF(FOUND_BISON_BIN_DIRS)
      # FILE GLOB seems to sort entries, but we need to REVERSE the list:
      # NATURAL uses strverscmp(3)
      LIST(SORT FOUND_BISON_BIN_DIRS COMPARE NATURAL ORDER DESCENDING)
      IF(IS_DIRECTORY "${OPT_BISON_DIR}/bison-${PREFERRED_BISON_VERSION}/bin")
        SET(BISON_PATHS "${OPT_BISON_DIR}/bison-${PREFERRED_BISON_VERSION}/bin")
        LIST(REMOVE_ITEM FOUND_BISON_BIN_DIRS "${BISON_PATHS}")
      ENDIF()
      FOREACH(path ${FOUND_BISON_BIN_DIRS})
        LIST(APPEND BISON_PATHS ${path})
      ENDFOREACH()
      MESSAGE(STATUS "Looking for bison in ${BISON_PATHS}")
      FIND_PROGRAM(BISON_EXECUTABLE bison
        NO_DEFAULT_PATH
        PATHS ${BISON_PATHS})
    ENDIF()
  ENDIF()
ENDIF()

# Look for HOMEBREW bison before the standard OS version.
# Note that it is *not* symlinked like most other executables.
# /usr/local/opt/bison/bin/bison
# /usr/local/opt/bison -> ../Cellar/bison/3.8.2
# /opt/homebrew/opt/bison
IF(APPLE AND NOT DEFINED BISON_EXECUTABLE)
  FIND_PROGRAM(BREW_EXECUTABLE brew)
  IF(BREW_EXECUTABLE)
    EXECUTE_PROCESS(COMMAND ${BREW_EXECUTABLE} --prefix bison
      OUTPUT_VARIABLE BREW_BISON_PREFIX_OUTPUT
      RESULT_VARIABLE BREW_BISON_PREFIX_RESULT
      OUTPUT_STRIP_TRAILING_WHITESPACE
      )
    IF(BREW_BISON_PREFIX_RESULT EQUAL 0)
      SET(BISON_HOMEBREW_PATH "${BREW_BISON_PREFIX_OUTPUT}/bin")
    ENDIF()
  ENDIF()
  FIND_PROGRAM(BISON_EXECUTABLE bison
    NO_DEFAULT_PATH
    PATHS "${BISON_HOMEBREW_PATH}" "${HOMEBREW_HOME}/bison/bin")
ENDIF()

# Look for winflexbison3, see e.g.
# https://github.com/lexxmark/winflexbison/releases
# or
# https://chocolatey.org/install
# choco install winflexbison3
IF(WIN32 AND NOT DEFINED BISON_EXECUTABLE)
  SET(MY_BISON_PATHS
    c:/bin/bin
    c:/bin/lib/winflexbison3/tools
    c:/ProgramData/chocolatey/bin
    )
  FOREACH(_path ${MY_BISON_PATHS})
    FILE(TO_NATIVE_PATH ${_path} NATIVE_PATH)
    LIST(APPEND NATIVE_BISON_PATHS "${NATIVE_PATH}")
  ENDFOREACH()
  MESSAGE(STATUS "Looking for win_bison in ${NATIVE_BISON_PATHS}")
  FIND_PROGRAM(BISON_EXECUTABLE
    NAMES win_bison win-bison
    NO_DEFAULT_PATH
    PATHS ${NATIVE_BISON_PATHS}
    )
  # Look for Flex also, we may need it later.
  IF(BISON_EXECUTABLE)
    FIND_PROGRAM(FLEX_EXECUTABLE
      NAMES flex win-flex win_flex
      NO_DEFAULT_PATH
      PATHS ${NATIVE_BISON_PATHS}
      )
    FIND_PATH(FLEX_INCLUDE_DIR FlexLexer.h
      NO_DEFAULT_PATH
      PATHS ${NATIVE_BISON_PATHS}
      )
  ENDIF()
ENDIF()

FIND_PACKAGE(BISON)

IF(NOT BISON_FOUND)
  MESSAGE(WARNING "No bison found!!")
  MESSAGE(WARNING "If you have bison in a non-standard location, "
    "you can do 'cmake -DBISON_EXECUTABLE=</path/to/bison-executable>"
    )
  IF(APPLE)
    MESSAGE(WARNING "We recommend Homebrew bison.")
  ENDIF()
  RETURN()
ENDIF()

IF(BISON_VERSION VERSION_LESS "${MIN_BISON_VERSION_REQUIRED}")
  MESSAGE(WARNING "Bison version ${BISON_VERSION} is old.")
  MESSAGE(WARNING "If you have a newer bison in a non-standard location, "
    "you can do 'cmake -DBISON_EXECUTABLE=</path/to/bison-executable>"
    )
  IF(APPLE)
    MESSAGE(WARNING "We recommend Homebrew bison.")
  ENDIF()
  MESSAGE(FATAL_ERROR
    "Please update to version ${MIN_BISON_VERSION_REQUIRED} or higher"
    )
ENDIF()

# TODO(tdidriks): replace with "--warnings=all"
# Legacy backward compatibility suppressions:
# * no-yacc: for --yacc
# * no-precedence: for useless precedence or/and associativity rules
SET(BISON_FLAGS_WARNINGS
  "--warnings=all,no-yacc,no-precedence"
  CACHE INTERNAL "BISON 3.x flags")