From 98dd673cf829a69fb6a7715aa1341491a1a70930 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 14 Jun 2024 08:04:11 -0700 Subject: [PATCH] Cleanup cmake --- CMakeLists.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14ce361a6f73..523c299bed90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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.