From a0ecfe3e1cce86049c6a30b398dbba69d23c2d02 Mon Sep 17 00:00:00 2001 From: autoantwort <41973254+autoantwort@users.noreply.github.com> Date: Sun, 13 Jul 2025 19:28:00 +0200 Subject: [PATCH] msvc + ninja + modules: Fix build when consuming fmtlib while using a Ninja generator (#4495) Co-authored-by: Leander Schulten --- CMakeLists.txt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd0e0743..5ef6c2ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,18 +27,15 @@ 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}") + file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI) + target_compile_options(${target} + PRIVATE /interface /ifcOutput ${BMI} + INTERFACE /reference fmt=${BMI}) + set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI}) + set_source_files_properties(${BMI} PROPERTIES GENERATED ON) endif() - file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI) - target_compile_options(${target} - PRIVATE /interface /ifcOutput ${BMI} - INTERFACE /reference fmt=${BMI}) - set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI}) - set_source_files_properties(${BMI} PROPERTIES GENERATED ON) endif () endfunction()