aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2022-05-26 18:02:37 +1000
committerfuzzard <fuzzard@kodi.tv>2022-06-01 19:10:35 +1000
commit6d327f6fc5c6e68f23eb7326bd3d4b8b7491de81 (patch)
treef2e254f39f80beaad1cc5743b36bf705100fd1a9 /cmake
parent5dfb2923e7f2937c907f2a4462b44ea95fb179fb (diff)
[cmake] Fmt use Fmt::Fmt target for depends
Implement Fmt::Fmt target to allow adding dependency target for ENABLE_INTERNAL_FMT.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindFmt.cmake33
1 files changed, 22 insertions, 11 deletions
diff --git a/cmake/modules/FindFmt.cmake b/cmake/modules/FindFmt.cmake
index 9747ae4e47..fa5f1c585c 100644
--- a/cmake/modules/FindFmt.cmake
+++ b/cmake/modules/FindFmt.cmake
@@ -10,16 +10,13 @@
#
# and the following imported targets::
#
-# fmt - The Fmt library
+# fmt::fmt - The Fmt library
if(ENABLE_INTERNAL_FMT)
include(cmake/scripts/common/ModuleHelpers.cmake)
set(MODULE_LC fmt)
- # fmt debug uses postfix d for all platforms
- set(FMT_DEBUG_POSTFIX d)
-
SETUP_BUILD_VARS()
if(APPLE)
@@ -45,6 +42,9 @@ if(ENABLE_INTERNAL_FMT)
-DFMT_INSTALL=ON
"${EXTRA_ARGS}")
+ # fmt debug uses postfix d for all platforms
+ set(FMT_DEBUG_POSTFIX d)
+
BUILD_DEP_TARGET()
else()
find_package(FMT 6.1.2 CONFIG REQUIRED QUIET)
@@ -78,14 +78,25 @@ if(FMT_FOUND)
set(FMT_LIBRARIES ${FMT_LIBRARY})
set(FMT_INCLUDE_DIRS ${FMT_INCLUDE_DIR})
- if(NOT TARGET fmt)
- add_library(fmt UNKNOWN IMPORTED)
- set_target_properties(fmt PROPERTIES
- IMPORTED_LOCATION "${FMT_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIR}")
+ if(NOT TARGET fmt::fmt)
+ add_library(fmt::fmt UNKNOWN IMPORTED)
+ if(FMT_LIBRARY_RELEASE)
+ set_target_properties(fmt::fmt PROPERTIES
+ IMPORTED_CONFIGURATIONS RELEASE
+ IMPORTED_LOCATION "${FMT_LIBRARY_RELEASE}")
+ endif()
+ if(FMT_LIBRARY_DEBUG)
+ set_target_properties(fmt::fmt PROPERTIES
+ IMPORTED_CONFIGURATIONS DEBUG
+ IMPORTED_LOCATION "${FMT_LIBRARY_DEBUG}")
+ endif()
+ set_target_properties(fmt::fmt PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIR}")
endif()
-
- set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP fmt)
+ if(TARGET fmt)
+ add_dependencies(fmt::fmt fmt)
+ endif()
+ set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP fmt::fmt)
endif()
mark_as_advanced(FMT_INCLUDE_DIR FMT_LIBRARY)