summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindFmt.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindFmt.cmake')
-rw-r--r--cmake/modules/FindFmt.cmake57
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/modules/FindFmt.cmake b/cmake/modules/FindFmt.cmake
new file mode 100644
index 0000000..5473ed5
--- /dev/null
+++ b/cmake/modules/FindFmt.cmake
@@ -0,0 +1,57 @@
1# FindFmt
2# -------
3# Finds the Fmt library
4#
5# This will define the following variables::
6#
7# FMT_FOUND - system has Fmt
8# FMT_INCLUDE_DIRS - the Fmt include directory
9# FMT_LIBRARIES - the Fmt libraries
10#
11# and the following imported targets::
12#
13# Fmt::Fmt - The Fmt library
14
15if(CORE_SYSTEM_NAME STREQUAL windows OR CORE_SYSTEM_NAME STREQUAL windowsstore)
16 # TODO: fix windows fmt package to include fmt-config.cmake and fmt-config-version.cmake
17 set(FMT_VERSION 3.0.1)
18else()
19 find_package(FMT 3.0.1 CONFIG REQUIRED QUIET)
20endif()
21
22if(PKG_CONFIG_FOUND)
23 pkg_check_modules(PC_FMT libfmt QUIET)
24 if(PC_FMT_VERSION AND NOT FMT_VERSION)
25 set(FMT_VERSION ${PC_FMT_VERSION})
26 endif()
27endif()
28
29find_path(FMT_INCLUDE_DIR NAMES fmt/format.h
30 PATHS ${PC_FMT_INCLUDEDIR})
31
32find_library(FMT_LIBRARY_RELEASE NAMES fmt
33 PATHS ${PC_FMT_LIBDIR})
34find_library(FMT_LIBRARY_DEBUG NAMES fmtd
35 PATHS ${PC_FMT_LIBDIR})
36
37include(SelectLibraryConfigurations)
38select_library_configurations(FMT)
39
40include(FindPackageHandleStandardArgs)
41find_package_handle_standard_args(Fmt
42 REQUIRED_VARS FMT_LIBRARY FMT_INCLUDE_DIR FMT_VERSION
43 VERSION_VAR FMT_VERSION)
44
45if(FMT_FOUND)
46 set(FMT_LIBRARIES ${FMT_LIBRARY})
47 set(FMT_INCLUDE_DIRS ${FMT_INCLUDE_DIR})
48
49 if(NOT TARGET Fmt::Fmt)
50 add_library(Fmt::Fmt UNKNOWN IMPORTED)
51 set_target_properties(Fmt::Fmt PROPERTIES
52 IMPORTED_LOCATION "${FMT_LIBRARY}"
53 INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIR}")
54 endif()
55endif()
56
57mark_as_advanced(FMT_INCLUDE_DIR FMT_LIBRARY)