@@ -145,7 +145,7 @@ php_bison(foo foo.y foo.c OPTIONS -Wall --debug)
145
145
# bison -Wall --debug foo.y --output foo.c
146
146
```
147
147
148
- ### Specifying options
148
+ ### Example: Specifying options
149
149
150
150
This module provides some default options when using the `ADD_DEFAULT_OPTIONS`:
151
151
@@ -227,7 +227,16 @@ _php_bison_config()
227
227
228
228
include_guard (GLOBAL )
229
229
230
+ include (ExternalProject)
230
231
include (FeatureSummary)
232
+ include (FetchContent)
233
+
234
+ set_package_properties(
235
+ BISON
236
+ PROPERTIES
237
+ URL "https://www.gnu.org/software/bison/"
238
+ DESCRIPTION "General-purpose parser generator"
239
+ )
231
240
232
241
# Configuration after find_package() in this module.
233
242
macro (_php_bison_config_options)
@@ -655,8 +664,8 @@ function(_php_bison_download)
655
664
)
656
665
657
666
# Target created by ExternalProject:
658
- if (TARGET bison )
659
- add_dependencies (Bison::Bison bison )
667
+ if (TARGET BISON- install )
668
+ add_dependencies (Bison::Bison BISON- install )
660
669
endif ()
661
670
662
671
# Move dependency to PACKAGES_FOUND.
@@ -676,22 +685,35 @@ function(_php_bison_download)
676
685
_PHP_BISON_DOWNLOAD
677
686
TRUE
678
687
CACHE INTERNAL
679
- "Internal marker whether the Bison will be downloaded."
688
+ "Internal marker whether Bison is downloaded."
680
689
)
681
690
682
691
return (PROPAGATE BISON_FOUND BISON_VERSION)
683
692
endfunction ()
684
693
685
694
# Downloads GNU Bison.
686
695
function (_php_bison_download_gnu)
687
- message (STATUS "GNU Bison ${BISON_VERSION} will be downloaded at build phase" )
688
-
689
- include (ExternalProject)
696
+ message (
697
+ STATUS
698
+ "Downloading GNU Bison ${BISON_VERSION} from https://ftp.gnu.org/gnu/bison"
699
+ )
690
700
691
- ExternalProject_Add (
692
- bison
701
+ FetchContent_Declare (
702
+ BISON
693
703
URL https://ftp.gnu.org/gnu/bison/bison-${BISON_VERSION} .tar.gz
704
+ SOURCE_SUBDIR non-existing
694
705
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
706
+ OVERRIDE_FIND_PACKAGE
707
+ )
708
+
709
+ FetchContent_MakeAvailable(BISON)
710
+
711
+ ExternalProject_Add(
712
+ BISON
713
+ STEP_TARGETS build install
714
+ SOURCE_DIR ${bison_SOURCE_DIR}
715
+ BINARY_DIR ${bison_BINARY_DIR}
716
+ INSTALL_DIR ${FETCHCONTENT_BASE_DIR} /bison-install
695
717
CONFIGURE_COMMAND
696
718
<SOURCE_DIR>/configure
697
719
--disable-dependency-tracking
@@ -701,37 +723,32 @@ function(_php_bison_download_gnu)
701
723
LOG_INSTALL TRUE
702
724
)
703
725
704
- ExternalProject_Get_Property(bison INSTALL_DIR)
726
+ ExternalProject_Get_Property(BISON INSTALL_DIR)
705
727
706
728
set_property (CACHE BISON_EXECUTABLE PROPERTY VALUE ${INSTALL_DIR} /bin/bison)
707
729
endfunction ()
708
730
709
- # Downloads https://github.com/lexxmark/ winflexbison.
731
+ # Downloads winflexbison.
710
732
function (_php_bison_download_windows)
711
733
message (
712
734
STATUS
713
- "Downloading win_bison ${BISON_VERSION} (${PHP_BISON_WIN_VERSION_DOWNLOAD} )"
735
+ "Downloading win_bison ${BISON_VERSION} from "
736
+ "https://github.com/lexxmark/winflexbison "
737
+ "(${PHP_BISON_WIN_VERSION_DOWNLOAD} )"
714
738
)
715
739
716
- get_directory_property (dir EP_BASE)
717
- if (NOT dir)
718
- set (dir "${CMAKE_CURRENT_BINARY_DIR} /CMakeFiles" )
719
- endif ()
720
-
721
- set (file "${dir} /win_flex_bison.zip" )
722
-
723
- file (
724
- DOWNLOAD
725
- "https://github.com/lexxmark/winflexbison/releases/download/v${PHP_BISON_WIN_VERSION_DOWNLOAD} /win_flex_bison-${PHP_BISON_WIN_VERSION_DOWNLOAD} .zip"
726
- ${file}
727
- SHOW_PROGRESS
740
+ FetchContent_Declare(
741
+ BISON
742
+ URL https://github.com/lexxmark/winflexbison/releases/download/v${PHP_BISON_WIN_VERSION_DOWNLOAD} /win_flex_bison-${PHP_BISON_WIN_VERSION_DOWNLOAD} .zip
743
+ SOURCE_SUBDIR non-existing
744
+ OVERRIDE_FIND_PACKAGE
728
745
)
729
746
730
- file (ARCHIVE_EXTRACT INPUT " ${file} " DESTINATION " ${dir} /win_flex_bison" )
747
+ FetchContent_MakeAvailable(BISON )
731
748
732
749
set_property (
733
750
CACHE
734
751
BISON_EXECUTABLE
735
- PROPERTY VALUE "${dir} /win_flex_bison /win_bison.exe"
752
+ PROPERTY VALUE "${bison_SOURCE_DIR} /win_bison.exe"
736
753
)
737
754
endfunction ()
0 commit comments