Cleanup cmake

This commit is contained in:
Victor Zverovich 2024-06-14 08:04:11 -07:00
parent a245a8d4b9
commit 98dd673cf8

View File

@ -36,6 +36,12 @@ function(enable_module target)
endif ()
endfunction()
set(FMT_USE_CMAKE_MODULES FALSE)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND
CMAKE_GENERATOR STREQUAL "Ninja")
set(FMT_USE_CMAKE_MODULES TRUE)
endif ()
# Adds a library compiled with C++20 module support.
# `enabled` is a CMake variables that specifies if modules are enabled.
# If modules are disabled `add_module_library` falls back to creating a
@ -65,8 +71,9 @@ function(add_module_library name)
target_compile_definitions(${name} PRIVATE FMT_MODULE)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja")
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES FILES ${sources})
if (FMT_USE_CMAKE_MODULES)
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES
FILES ${sources})
else()
# `std` is affected by CMake options and may be higher than C++20.
get_target_property(std ${name} CXX_STANDARD)
@ -403,10 +410,9 @@ if (FMT_INSTALL)
set(INSTALL_TARGETS fmt fmt-header-only)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja")
set(INSTALL_FILE_SET)
if (FMT_USE_CMAKE_MODULES)
set(INSTALL_FILE_SET FILE_SET fmt DESTINATION "${FMT_INC_DIR}/fmt")
else()
set(INSTALL_FILE_SET)
endif()
# Install the library and headers.