@@ -13,7 +13,9 @@ syntax, e.g. 'find_package(RE2C 0.15.3)'.
13
13
14
14
## Cache variables
15
15
16
- * `RE2C_EXECUTABLE` - Path to the re2c program.
16
+ * `RE2C_EXECUTABLE` - Path to the re2c program. When RE2C is downloaded and
17
+ built from source as part of the built (using below ExternalProject), this
18
+ path will not exist until the built phase.
17
19
18
20
Custom target:
19
21
@@ -98,8 +100,15 @@ find_program(
98
100
NAMES re2c
99
101
DOC "The re2c executable path"
100
102
)
103
+ mark_as_advanced (RE2C_EXECUTABLE)
104
+
105
+ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)
106
+ set (_re2cCondition IS_EXECUTABLE ${RE2C_EXECUTABLE} )
107
+ else ()
108
+ set (_re2cCondition EXISTS ${RE2C_EXECUTABLE} )
109
+ endif ()
101
110
102
- if (RE2C_EXECUTABLE )
111
+ if (${_re2cCondition} )
103
112
execute_process (
104
113
COMMAND ${RE2C_EXECUTABLE} --vernum
105
114
OUTPUT_VARIABLE RE2C_VERSION_NUM
@@ -177,14 +186,13 @@ if(NOT RE2C_DISABLE_DOWNLOAD AND (NOT RE2C_EXECUTABLE OR NOT _re2cVersionValid))
177
186
PROPERTIES IMPORTED_LOCATION ${BINARY_DIR} /re2c
178
187
)
179
188
add_dependencies (RE2C::RE2C re2c)
180
- set_property (CACHE RE2C_EXECUTABLE PROPERTY VALUE RE2C::RE2C)
189
+ set_property (CACHE RE2C_EXECUTABLE PROPERTY VALUE ${BINARY_DIR} /re2c)
190
+ unset (BINARY_DIR)
181
191
182
192
list (PREPEND _re2cRequiredVars _re2cMsg)
183
193
set (_re2cMsg "downloading at build" )
184
194
endif ()
185
195
186
- mark_as_advanced (RE2C_EXECUTABLE)
187
-
188
196
find_package_handle_standard_args(
189
197
RE2C
190
198
REQUIRED_VARS ${_re2cRequiredVars}
@@ -193,6 +201,7 @@ find_package_handle_standard_args(
193
201
REASON_FAILURE_MESSAGE "re2c not found. Please install re2c."
194
202
)
195
203
204
+ unset (_re2cCondition)
196
205
unset (_re2cMsg)
197
206
unset (_re2cRequiredVars)
198
207
unset (_re2cVersionValid)
@@ -297,11 +306,11 @@ function(re2c_target)
297
306
298
307
add_custom_command (
299
308
OUTPUT ${outputs}
300
- COMMAND ${RE2C_EXECUTABLE}
309
+ COMMAND $<IF:$<TARGET_EXISTS:RE2C::RE2C>,RE2C::RE2C, $ {RE2C_EXECUTABLE}>
301
310
${options}
302
311
--output ${output}
303
312
${input}
304
- DEPENDS ${input} ${parsed_DEPENDS} $<TARGET_NAME_IF_EXISTS:RE2C::RE2C>
313
+ DEPENDS ${input} ${parsed_DEPENDS}
305
314
COMMENT "[RE2C][${ARGV0} ] Building lexer with re2c ${RE2C_VERSION} "
306
315
VERBATIM
307
316
COMMAND_EXPAND_LISTS
0 commit comments