Skip to content

Commit

Permalink
Update the fmt cmake module
Browse files Browse the repository at this point in the history
* Avoid the conda special case
  • Loading branch information
DavidAce committed Apr 24, 2023
1 parent 3888555 commit 1feffe3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmake/modules/Findfmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,23 @@ function(find_fmt_manual)
fmt_check_version_include(FMT_INCLUDE_DIR)

if(FMT_VERSION_OK AND FMT_INCLUDE_DIR)
add_library(fmt::fmt INTERFACE IMPORTED)
add_library(fmt::fmt-header-only INTERFACE IMPORTED)
if(NOT TARGET fmt::fmt)
if(FMT_LIBRARY)
add_library(fmt::fmt UNKNOWN IMPORTED)
set_target_properties(fmt::fmt PROPERTIES IMPORTED_LOCATION ${FMT_LIBRARY})
else()
add_library(fmt::fmt INTERFACE IMPORTED)
endif()
endif()
if(NOT TARGET fmt::fmt-header-only)
add_library(fmt::fmt-header-only INTERFACE IMPORTED)
endif()
target_include_directories(fmt::fmt SYSTEM INTERFACE ${FMT_INCLUDE_DIR})
target_include_directories(fmt::fmt-header-only SYSTEM INTERFACE ${FMT_INCLUDE_DIR})

target_compile_definitions(fmt::fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
target_compile_features(fmt::fmt INTERFACE cxx_variadic_templates)
target_compile_features(fmt::fmt-header-only INTERFACE cxx_variadic_templates)

if(FMT_LIBRARY AND NOT FMT_LIBRARY MATCHES "conda")
set_target_properties(fmt::fmt PROPERTIES IMPORTED_LOCATION ${FMT_LIBRARY})
else()
# Choose header-only because conda libraries sometimes give linking errors
target_compile_definitions(fmt::fmt INTERFACE FMT_HEADER_ONLY=1)
endif()
endif()
endif()
endfunction()
Expand Down

0 comments on commit 1feffe3

Please sign in to comment.