@@ -34,42 +34,42 @@ find_package(RE2C)
3434include (FeatureSummary)
3535include (FindPackageHandleStandardArgs)
3636
37- ################################################################################
38- # Configuration.
39- ################################################################################
40-
41- set_package_properties(
42- RE2C
43- PROPERTIES
44- URL "https://re2c.org/"
45- DESCRIPTION "Lexer generator "
46- )
47-
48- ################################################################################
49- # Find the executable.
50- ################################################################################
51-
52- set (_re2cRequiredVars RE2C_EXECUTABLE)
53- set (_reason "" )
54-
55- find_program (
56- RE2C_EXECUTABLE
57- NAMES re2c
58- DOC "The path to the re2c executable"
59- )
60- mark_as_advanced (RE2C_EXECUTABLE )
61-
62- if ( NOT RE2C_EXECUTABLE)
63- string ( APPEND _reason "The re2c command-line executable not found. " )
64- endif ( )
65-
66- ################################################################################
67- # Check version.
68- ################################################################################
69-
70- block(PROPAGATE RE2C_VERSION _reason _re2cRequiredVars)
37+ block(PROPAGATE RE2C_FOUND RE2C_VERSION)
38+ ##############################################################################
39+ # Configuration.
40+ ##############################################################################
41+
42+ set_package_properties(
43+ RE2C
44+ PROPERTIES
45+ URL "https://re2c.org/ "
46+ DESCRIPTION "Lexer generator"
47+ )
48+
49+ set (required_vars RE2C_EXECUTABLE)
50+ set (reason "" )
51+
52+ ##############################################################################
53+ # Find the executable.
54+ ##############################################################################
55+
56+ find_program (
57+ RE2C_EXECUTABLE
58+ NAMES re2c
59+ DOC "The path to the re2c executable"
60+ )
61+ mark_as_advanced (RE2C_EXECUTABLE)
62+
63+ if ( NOT RE2C_EXECUTABLE )
64+ string ( APPEND reason "The re2c command-line executable not found. " )
65+ endif ()
66+
67+ ##############################################################################
68+ # Check version.
69+ ##############################################################################
70+
7171 if (IS_EXECUTABLE "${RE2C_EXECUTABLE} " )
72- list (APPEND _re2cRequiredVars RE2C_VERSION)
72+ list (APPEND required_vars RE2C_VERSION)
7373 execute_process (
7474 COMMAND ${RE2C_EXECUTABLE} --version
7575 OUTPUT_VARIABLE version
@@ -79,22 +79,19 @@ block(PROPAGATE RE2C_VERSION _reason _re2cRequiredVars)
7979 )
8080
8181 if (NOT result EQUAL 0)
82- string (APPEND _reason "Command '${RE2C_EXECUTABLE} --version' failed. " )
82+ string (APPEND reason "Command '${RE2C_EXECUTABLE} --version' failed. " )
8383 elseif (version MATCHES "^re2c ([0-9.]+[^\n ]+)" )
8484 set (RE2C_VERSION "${CMAKE_MATCH_1} " )
8585 else ()
86- string (APPEND _reason "Invalid version format. " )
86+ string (APPEND reason "Invalid version format. " )
8787 endif ()
8888 endif ()
89- endblock()
90-
91- find_package_handle_standard_args(
92- RE2C
93- REQUIRED_VARS ${_re2cRequiredVars}
94- VERSION_VAR RE2C_VERSION
95- HANDLE_VERSION_RANGE
96- REASON_FAILURE_MESSAGE "${_reason} "
97- )
9889
99- unset (_re2cRequiredVars)
100- unset (_reason)
90+ find_package_handle_standard_args(
91+ RE2C
92+ REQUIRED_VARS ${required_vars}
93+ VERSION_VAR RE2C_VERSION
94+ HANDLE_VERSION_RANGE
95+ REASON_FAILURE_MESSAGE "${reason} "
96+ )
97+ endblock()
0 commit comments