Fix language detection for files with dot in their names

This commit is contained in:
Andrey Dotsenko
2018-08-24 20:47:43 +03:00
parent 6f451ad0cf
commit 0590614f30
3 changed files with 45 additions and 1 deletions

View File

@ -24,7 +24,9 @@
# Helper function to get the language of a source file.
function (sanitizer_lang_of_source FILE RETURN_VAR)
get_filename_component(FILE_EXT "${FILE}" EXT)
get_filename_component(LONGEST_EXT "${FILE}" EXT)
# Get shortest extension as some files can have dot in their names
string(REGEX REPLACE "^.*(\\.[^.]+)$" "\\1" FILE_EXT ${LONGEST_EXT})
string(TOLOWER "${FILE_EXT}" FILE_EXT)
string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT)