diff options
| author | James Rowe <jroweboy@gmail.com> | 2020-05-09 12:31:45 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-09 12:31:45 -0600 |
| commit | d4e1633fb78630b76ff4606b899a8d040d1a2ac4 (patch) | |
| tree | b37324af5286d3e7daf4563b7a7fb62b33ef1556 /externals/find-modules/FindCatch2.cmake | |
| parent | 7e376af8fcd60baaa127b459e83bf716067be233 (diff) | |
| parent | e8baf07136645a9b17875967f24375db1c68c059 (diff) | |
Merge pull request #3902 from degasus/cmake_version_checks
externals: Cmake version checks
Diffstat (limited to 'externals/find-modules/FindCatch2.cmake')
| -rw-r--r-- | externals/find-modules/FindCatch2.cmake | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/externals/find-modules/FindCatch2.cmake b/externals/find-modules/FindCatch2.cmake index a83c668bf..ce1d40bae 100644 --- a/externals/find-modules/FindCatch2.cmake +++ b/externals/find-modules/FindCatch2.cmake @@ -8,11 +8,25 @@ find_path(Catch2_INCLUDE_DIR PATH_SUFFIXES catch2 ) +if(Catch2_INCLUDE_DIR) + file(STRINGS "${Catch2_INCLUDE_DIR}/catch.hpp" _Catch2_version_lines + REGEX "#define[ \t]+CATCH_VERSION_(MAJOR|MINOR|PATCH)") + string(REGEX REPLACE ".*CATCH_VERSION_MAJOR +\([0-9]+\).*" "\\1" _Catch2_version_major "${_Catch2_version_lines}") + string(REGEX REPLACE ".*CATCH_VERSION_MINOR +\([0-9]+\).*" "\\1" _Catch2_version_minor "${_Catch2_version_lines}") + string(REGEX REPLACE ".*CATCH_VERSION_PATCH +\([0-9]+\).*" "\\1" _Catch2_version_patch "${_Catch2_version_lines}") + set(Catch2_VERSION "${_Catch2_version_major}.${_Catch2_version_minor}.${_Catch2_version_patch}") + unset(_Catch2_version_major) + unset(_Catch2_version_minor) + unset(_Catch2_version_patch) + unset(_Catch2_version_lines) +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Catch2 FOUND_VAR Catch2_FOUND REQUIRED_VARS Catch2_INCLUDE_DIR + Catch2_VERSION VERSION_VAR Catch2_VERSION ) |
