diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake index 3cfaedd573..f8cd9c1d61 100644 --- a/src/cmake/externalpackages.cmake +++ b/src/cmake/externalpackages.cmake @@ -332,7 +332,7 @@ macro (find_or_download_fmt) # If an external copy wasn't found and we requested that missing # packages be built, or we we are forcing a local copy to be built, then # download and build it. - if ((BUILD_MISSING_FMT AND NOT FMT_FOUND) OR BUILD_FMT_FORCE) + if ((BUILD_MISSING_FMT AND NOT fmt_FOUND) OR BUILD_FMT_FORCE) message (STATUS "Downloading local fmtlib/fmt") set (FMT_INSTALL_DIR "${PROJECT_SOURCE_DIR}/ext/fmt") set (FMT_GIT_REPOSITORY "https://github.com/fmtlib/fmt") @@ -350,16 +350,18 @@ macro (find_or_download_fmt) endif () set (FMT_INCLUDE_DIR "${FMT_INSTALL_DIR}/include") set (OIIO_USING_FMT_LOCAL TRUE) + set (fmt_VERSION ${BUILD_FMT_VERSION}) else () + get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) set (OIIO_USING_FMT_LOCAL FALSE) + checked_find_package (fmt REQUIRED + VERSION_MIN 7.0) endif () - checked_find_package (fmt REQUIRED - VERSION_MIN 7.0) endmacro() find_or_download_fmt() -if (FMT_VERSION VERSION_EQUAL 90100 +if (fmt_VERSION VERSION_EQUAL 9.1.0 AND GCC_VERSION VERSION_GREATER 0.0 AND NOT GCC_VERSION VERSION_GREATER 7.2) message (WARNING "${ColorRed}fmt 9.1 is known to not work with gcc <= 7.2${ColorReset}") endif () diff --git a/src/cmake/modules/Findfmt.cmake b/src/cmake/modules/Findfmt.cmake deleted file mode 100644 index 9ee436da33..0000000000 --- a/src/cmake/modules/Findfmt.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# Find fmt library -# -# Copyright Contributors to the OpenImageIO project. -# SPDX-License-Identifier: Apache-2.0 -# https://github.com/AcademySoftwareFoundation/OpenImageIO -# -# Sets the usual variables expected for find_package scripts: -# -# FMT_INCLUDES - header location -# FMT_FOUND - true if fmt was found. -# FMT_VERSION - combined version number (e.g. 60102 for 6.1.2) - -find_path (FMT_INCLUDE_DIR fmt/format.h - HINTS "${PROJECT_SOURCE_DIR}/ext/fmt" - ) - -if (FMT_INCLUDE_DIR) - file(STRINGS "${FMT_INCLUDE_DIR}/fmt/core.h" TMP REGEX "^#define FMT_VERSION .*$") - string (REGEX MATCHALL "[0-9]+[.0-9]+" FMT_VERSION ${TMP}) -endif () - -# Support the REQUIRED and QUIET arguments, and set FMT_FOUND if found. -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (fmt - REQUIRED_VARS FMT_INCLUDE_DIR - VERSION_VAR FMT_VERSION) - -if (FMT_FOUND) - set (FMT_INCLUDES ${FMT_INCLUDE_DIR}) -endif () - -mark_as_advanced (FMT_INCLUDE_DIR) diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 006cb65a77..5a00f722fd 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -66,13 +66,13 @@ install (FILES ${detail_headers} if (INTERNALIZE_FMT OR OIIO_USING_FMT_LOCAL) set (fmt_headers - ${FMT_INCLUDES}/fmt/core.h - ${FMT_INCLUDES}/fmt/format-inl.h - ${FMT_INCLUDES}/fmt/format.h - ${FMT_INCLUDES}/fmt/ostream.h - ${FMT_INCLUDES}/fmt/printf.h ) - if (fmt_VERSION VERSION_GREATER_EQUAL 90000) - list (APPEND fmt_headers ${FMT_INCLUDES}/fmt/std.h) + ${FMT_INCLUDE_DIR}/fmt/core.h + ${FMT_INCLUDE_DIR}/fmt/format-inl.h + ${FMT_INCLUDE_DIR}/fmt/format.h + ${FMT_INCLUDE_DIR}/fmt/ostream.h + ${FMT_INCLUDE_DIR}/fmt/printf.h ) + if (fmt_VERSION VERSION_GREATER_EQUAL 9) + list (APPEND fmt_headers ${FMT_INCLUDE_DIR}/fmt/std.h) endif () file (COPY ${fmt_headers} DESTINATION ${CMAKE_BINARY_DIR}/include/OpenImageIO/detail/fmt) @@ -85,7 +85,7 @@ else () file (WRITE "${CMAKE_BINARY_DIR}/include/OpenImageIO/detail/fmt/${f}" "#include ") endforeach () - if (fmt_VERSION VERSION_GREATER_EQUAL 90000) + if (fmt_VERSION VERSION_GREATER_EQUAL 9) list (APPEND fmt_headers ${CMAKE_BINARY_DIR}/include/OpenImageIO/detail/fmt/std.h) file (WRITE "${CMAKE_BINARY_DIR}/include/OpenImageIO/detail/fmt/std.h" "#include ")