diff options
Diffstat (limited to '')
| -rw-r--r-- | externals/find-modules/Findfmt.cmake | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/externals/find-modules/Findfmt.cmake b/externals/find-modules/Findfmt.cmake index e0a04a344..8ba51cbea 100644 --- a/externals/find-modules/Findfmt.cmake +++ b/externals/find-modules/Findfmt.cmake | |||
| @@ -13,12 +13,38 @@ find_library(fmt_LIBRARY | |||
| 13 | PATHS ${PC_fmt_LIBRARY_DIRS} ${CONAN_LIB_DIRS_fmt} | 13 | PATHS ${PC_fmt_LIBRARY_DIRS} ${CONAN_LIB_DIRS_fmt} |
| 14 | ) | 14 | ) |
| 15 | 15 | ||
| 16 | if(fmt_INCLUDE_DIR) | ||
| 17 | set(_fmt_version_file "${fmt_INCLUDE_DIR}/core.h") | ||
| 18 | if(NOT EXISTS "${_fmt_version_file}") | ||
| 19 | set(_fmt_version_file "${fmt_INCLUDE_DIR}/format.h") | ||
| 20 | endif() | ||
| 21 | if(EXISTS "${_fmt_version_file}") | ||
| 22 | # parse "#define FMT_VERSION 60200" to 6.2.0 | ||
| 23 | file(STRINGS "${_fmt_version_file}" fmt_VERSION_LINE | ||
| 24 | REGEX "^#define[ \t]+FMT_VERSION[ \t]+[0-9]+$") | ||
| 25 | string(REGEX REPLACE "^#define[ \t]+FMT_VERSION[ \t]+([0-9]+)$" | ||
| 26 | "\\1" fmt_VERSION "${fmt_VERSION_LINE}") | ||
| 27 | foreach(ver "fmt_VERSION_PATCH" "fmt_VERSION_MINOR" "fmt_VERSION_MAJOR") | ||
| 28 | math(EXPR ${ver} "${fmt_VERSION} % 100") | ||
| 29 | math(EXPR fmt_VERSION "(${fmt_VERSION} - ${${ver}}) / 100") | ||
| 30 | endforeach() | ||
| 31 | set(fmt_VERSION | ||
| 32 | "${fmt_VERSION_MAJOR}.${fmt_VERSION_MINOR}.${fmt_VERSION_PATCH}") | ||
| 33 | endif() | ||
| 34 | unset(_fmt_version_file) | ||
| 35 | unset(fmt_VERSION_LINE) | ||
| 36 | unset(fmt_VERSION_MAJOR) | ||
| 37 | unset(fmt_VERSION_MINOR) | ||
| 38 | unset(fmt_VERSION_PATCH) | ||
| 39 | endif() | ||
| 40 | |||
| 16 | include(FindPackageHandleStandardArgs) | 41 | include(FindPackageHandleStandardArgs) |
| 17 | find_package_handle_standard_args(fmt | 42 | find_package_handle_standard_args(fmt |
| 18 | FOUND_VAR fmt_FOUND | 43 | FOUND_VAR fmt_FOUND |
| 19 | REQUIRED_VARS | 44 | REQUIRED_VARS |
| 20 | fmt_LIBRARY | 45 | fmt_LIBRARY |
| 21 | fmt_INCLUDE_DIR | 46 | fmt_INCLUDE_DIR |
| 47 | fmt_VERSION | ||
| 22 | VERSION_VAR fmt_VERSION | 48 | VERSION_VAR fmt_VERSION |
| 23 | ) | 49 | ) |
| 24 | 50 | ||