blt
blt copied to clipboard
blt_add_code_checks grabs too much for the file extension and throws an error
If given a file path such as "foo.bar.h", it will grab the ".bar.h" as the file extension. This needs to only get ".h".
Solution 1) If more than one "." then remove the first one and run get_filename_component(_ext ${_full_path} EXT) until there is only 1 (the first one).
Solution 2) Use some regex magic on the if checks for the file extension. This will need a loop because you won't be able to use IN_LIST at this point.
Solution 3) Create an string_endswith macro instead of grabbing the file extension.
How about adding a simple function (or string(REGEX ...)
) to store the shortest extension in a variable. You could use this for a one line replacement of the current code.
See: https://stackoverflow.com/a/30062299, although that replaces NAME_WE
instead of EXT
, so you'd want to use the REGEX MATCH
variant instead (e.g. string(REGEX MATCH <regular_expression> <output variable> <input>)
)