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,18 +27,15 @@ endfunction()
# DEPRECATED! Should be merged into add_module_library. # DEPRECATED! Should be merged into add_module_library.
function(enable_module target) function(enable_module target)
if (MSVC) if (MSVC)
if(CMAKE_GENERATOR STREQUAL "Ninja") if(NOT 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()
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI) file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI)
target_compile_options(${target} target_compile_options(${target}
PRIVATE /interface /ifcOutput ${BMI} PRIVATE /interface /ifcOutput ${BMI}
INTERFACE /reference fmt=${BMI}) INTERFACE /reference fmt=${BMI})
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI}) set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})
set_source_files_properties(${BMI} PROPERTIES GENERATED ON) set_source_files_properties(${BMI} PROPERTIES GENERATED ON)
endif()
endif () endif ()
endfunction() endfunction()