Skip to content

Commit a0ecfe3

Browse files
autoantwortLeander Schulten
andauthored
msvc + ninja + modules: Fix build when consuming fmtlib while using a Ninja generator (#4495)
Co-authored-by: Leander Schulten <Leander.Schulten@tetys.de>
1 parent 127413d commit a0ecfe3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

CMakeLists.txt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ endfunction()
2727
# DEPRECATED! Should be merged into add_module_library.
2828
function(enable_module target)
2929
if (MSVC)
30-
if(CMAKE_GENERATOR STREQUAL "Ninja")
31-
# Ninja dyndep expects the .ifc output to be located in a specific relative path
32-
file(RELATIVE_PATH BMI_DIR "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir")
33-
else()
30+
if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
3431
set(BMI_DIR "${CMAKE_CURRENT_BINARY_DIR}")
32+
file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI)
33+
target_compile_options(${target}
34+
PRIVATE /interface /ifcOutput ${BMI}
35+
INTERFACE /reference fmt=${BMI})
36+
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})
37+
set_source_files_properties(${BMI} PROPERTIES GENERATED ON)
3538
endif()
36-
file(TO_NATIVE_PATH "${BMI_DIR}/${target}.ifc" BMI)
37-
target_compile_options(${target}
38-
PRIVATE /interface /ifcOutput ${BMI}
39-
INTERFACE /reference fmt=${BMI})
40-
set_target_properties(${target} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})
41-
set_source_files_properties(${BMI} PROPERTIES GENERATED ON)
4239
endif ()
4340
endfunction()
4441

0 commit comments

Comments
 (0)