1- # Copyright (c) 2009 Sun Microsystems, Inc.
2- # Use is subject to license terms.
1+ # Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
32#
43# This program is free software; you can redistribute it and/or modify
54# it under the terms of the GNU General Public License as published by
1211#
1312# You should have received a copy of the GNU General Public License
1413# along with this program; if not, write to the Free Software
15- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1615
17- IF (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
18- # On Solaris, /opt/csw often contains a newer bison
19- IF (NOT BISON_EXECUTABLE AND EXISTS /opt/csw/bin/bison)
20- SET (BISON_EXECUTABLE /opt/csw/bin/bison)
21- ENDIF ()
22- ENDIF ()
2316FIND_PROGRAM (BISON_EXECUTABLE bison DOC "path to the bison executable" )
2417MARK_AS_ADVANCED (BISON_EXECUTABLE "" )
18+
2519IF (NOT BISON_EXECUTABLE)
26- MESSAGE ("Warning: Bison executable not found in PATH" )
20+ MESSAGE (WARNING " Bison executable not found in PATH" )
2721ELSEIF (BISON_EXECUTABLE AND NOT BISON_USABLE)
2822 # Check version as well
2923 EXEC_PROGRAM (${BISON_EXECUTABLE} ARGS --version OUTPUT_VARIABLE BISON_VERSION_STR)
@@ -33,19 +27,26 @@ ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE)
3327 STRING (REGEX REPLACE ".* ([0-9]+)\\ .([0-9]+)" "\\ 1" BISON_VERSION_MAJOR "${FIRST_LINE} " )
3428 STRING (REGEX REPLACE ".* ([0-9]+)\\ .([0-9]+)" "\\ 2" BISON_VERSION_MINOR "${FIRST_LINE} " )
3529 IF (BISON_VERSION_MAJOR LESS 2)
36- MESSAGE ("Warning: bison version is old. please update to version 2" )
30+ MESSAGE (WARNING "Bison version is old. please update to version 2" )
3731 ELSE ()
3832 SET (BISON_USABLE 1 CACHE INTERNAL "Bison version 2 or higher" )
3933 ENDIF ()
4034ENDIF ()
4135
36+
37+ # Handle out-of-source build from source package with possibly broken
38+ # bison. Copy bison output to from source to build directory, if not already
39+ # there
40+ MACRO (COPY_BISON_OUTPUT input_cc input_h output_cc output_h)
41+ IF (EXISTS ${input_cc} AND NOT EXISTS ${output_cc} )
42+ CONFIGURE_FILE (${input_cc} ${output_cc} COPYONLY )
43+ CONFIGURE_FILE (${input_h} ${output_h} COPYONLY )
44+ ENDIF ()
45+ ENDMACRO ()
46+
47+
4248# Use bison to generate C++ and header file
4349MACRO (RUN_BISON input_yy output_cc output_h)
44- IF (BISON_TOO_OLD)
45- IF (EXISTS ${output_cc} AND EXISTS ${output_h} )
46- SET (BISON_USABLE FALSE )
47- ENDIF ()
48- ENDIF ()
4950 IF (BISON_USABLE)
5051 ADD_CUSTOM_COMMAND (
5152 OUTPUT ${output_cc}
@@ -61,7 +62,7 @@ MACRO (RUN_BISON input_yy output_cc output_h)
6162 IF (EXISTS ${output_cc} AND EXISTS ${output_h} )
6263 IF (${input_yy} IS_NEWER_THAN ${output_cc} OR ${input_yy} IS_NEWER_THAN ${output_h} )
6364 # Possibly timestamps are messed up in source distribution.
64- MESSAGE ("Warning: no usable bison found, ${input_yy} will not be rebuilt." )
65+ MESSAGE (WARNING "No usable bison found, ${input_yy} will not be rebuilt." )
6566 ENDIF ()
6667 ELSE ()
6768 # Output files are missing, bail out.
0 commit comments