msvc + ninja + modules: Fix build when consuming fmtlib while using a Ninja generator (#4495)

Co-authored-by: Leander Schulten <Leander.Schulten@tetys.de>
This commit is contained in:
autoantwort
2025-07-13 19:28:00 +02:00
committed by GitHub
parent 127413ddaa
commit a0ecfe3e1c

View File

@@ -27,12 +27,8 @@ endfunction()
# DEPRECATED! Should be merged into add_module_library.
function(enable_module target)
if (MSVC)
if(CMAKE_GENERATOR STREQUAL "Ninja")
# Ninja dyndep expects the .ifc output to be located in a specific relative path
file(RELATIVE_PATH BMI_DIR "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir")
else()
if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI)
target_compile_options(${target}
PRIVATE /interface /ifcOutput ${BMI}
@@ -40,6 +36,7 @@ function(enable_module target)
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})
set_source_files_properties(${BMI} PROPERTIES GENERATED ON)
endif()
endif ()
endfunction()
set(FMT_USE_CMAKE_MODULES FALSE)