yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b2386f36e
master
1find_package ( Git ) 2 3# Extract a version from the latest tag matching something like v1.2.3.4 4function ( get_git_version var_numeric var dir ) 5if ( NOT DEFINED ${ var }) 6set ( version_numeric "0.0.0" ) 7set ( version "0.0.0-unknown" ) 8if ( GIT_EXECUTABLE) 9set ( command 10" ${ GIT_EXECUTABLE } " 11-C 12" ${ dir } " 13describe 14--tags 15--match 16v* 17) 18execute_process ( 19COMMAND ${ command } 20RESULT_VARIABLE result 21OUTPUT_STRIP_TRAILING_WHITESPACE 22OUTPUT_VARIABLE version_out 23) 24if ( NOT resultEQUAL 0 ) 25message ( 26WARNING 27"Getting ${ var } failed: ${ command } returned ${ result } \nIs this a Git repo with tags?\nConsider settings -D ${ var } to specify a version manually" 28) 29elseif ( " ${ version_out } " MATCHES "^v(([0-9]+(\\.[0-9]+)*).*)" ) 30set ( version " ${ CMAKE_MATCH_1 } " ) 31set ( version_numeric " ${ CMAKE_MATCH_2 } " ) 32else () 33message ( 34WARNING 35"Couldn't parse version (like v1.2.3 or v1.2.3-foo) from ${ version_out } , using ${ version } for now" 36) 37endif () 38else () 39message ( 40WARNING 41"Couldn't find git executable to get ${ var } , please use -D ${ var } , using ${ version } for now" 42) 43endif () 44endif () 45 46set ( $ { var_numeric } 47${ version_numeric } 48CACHE STRING 49"The project version numeric part, detected using git if available" 50) 51set ( $ { var } 52${ version } 53CACHE STRING 54"The project version, detected using git if available" 55) 56endfunction ()