From ed27df5760490eaaa620c2537c59c6ace2d90c4e Mon Sep 17 00:00:00 2001 From: Thomas Khyn Date: Mon, 10 Feb 2025 21:18:33 +1300 Subject: [PATCH] Replace forward slashes by backslashes in BMI path for MSVC. (#4344) * Fix slashes in BMI path for MSVC builds * Fix BMI path for MSVC builds when building with Ninja generator --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8df6670d..00c05908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,13 @@ endfunction() # DEPRECATED! Should be merged into add_module_library. function(enable_module target) if (MSVC) - set(BMI ${CMAKE_CURRENT_BINARY_DIR}/${target}.ifc) + 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() + 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} INTERFACE /reference fmt=${BMI})