@@ -13,6 +13,11 @@ function(add_idl target idl_files_with_proxy idl_files_no_proxy)
1313 string (TOLOWER ${TARGET_PLATFORM} IDL_ENV)
1414 set (PREVIOUS_OUTPUT "" )
1515
16+ set (IDL_DLLDATA ${OUTPUT_DIR} /dlldata_${TARGET_PLATFORM} .c)
17+
18+ list (LENGTH idl_files_with_proxy PROXY_IDL_COUNT)
19+ set (PROXY_IDL_INDEX 0)
20+
1621 foreach (idl_file ${idl_files_with_proxy} )
1722
1823 cmake_path (GET idl_file STEM IDL_NAME )
@@ -24,8 +29,14 @@ function(add_idl target idl_files_with_proxy idl_files_no_proxy)
2429 # "fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'ARM64'"
2530 set (IDL_I ${OUTPUT_DIR} /${IDL_NAME} _i_${TARGET_PLATFORM} .c)
2631 set (IDL_P ${OUTPUT_DIR} /${IDL_NAME} _p_${TARGET_PLATFORM} .c)
27- set (IDL_DLLDATA ${OUTPUT_DIR} /dlldata_${TARGET_PLATFORM} .c)
28- set (MIDL_OUTPUT ${IDL_HEADER} ${IDL_I} ${IDL_P} ${IDL_DLLDATA} )
32+
33+ # Only list dlldata as a tracked output of the last MIDL command.
34+ math (EXPR PROXY_IDL_INDEX "${PROXY_IDL_INDEX} + 1" )
35+ if (PROXY_IDL_INDEX EQUAL PROXY_IDL_COUNT)
36+ set (MIDL_OUTPUT ${IDL_HEADER} ${IDL_I} ${IDL_P} ${IDL_DLLDATA} )
37+ else ()
38+ set (MIDL_OUTPUT ${IDL_HEADER} ${IDL_I} ${IDL_P} )
39+ endif ()
2940
3041 add_custom_command (
3142 OUTPUT ${MIDL_OUTPUT}
@@ -51,7 +62,7 @@ function(add_idl target idl_files_with_proxy idl_files_no_proxy)
5162
5263 add_custom_command (
5364 OUTPUT ${IDL_HEADER}
54- COMMAND midl /nologo /target NT100 /env "${IDL_ENV} " /Zp8 /char unsigned /ms_ext /c_ext /h ${IDL_HEADER} ${idl_file} ${IDL_DEFINITIONS}
65+ COMMAND midl /nologo /target NT100 /env "${IDL_ENV} " /Zp8 /char unsigned /ms_ext /c_ext /h ${IDL_HEADER} /iid nul /proxy nul /dlldata nul ${idl_file} ${IDL_DEFINITIONS}
5566 WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
5667 DEPENDS ${idl_file}
5768 MAIN_DEPENDENCY ${idl_file}
@@ -63,6 +74,11 @@ function(add_idl target idl_files_with_proxy idl_files_no_proxy)
6374
6475 endforeach ()
6576
66- add_custom_target (${target} DEPENDS ${TARGET_OUTPUTS} SOURCES ${idl_files_with_proxy} ${idl_files_no_proxy} )
77+ # Touch the stamp file so Visual Studio's incremental build can track the
78+ # target as up-to-date.
79+ add_custom_target (${target}
80+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR} /CMakeFiles/${target}
81+ DEPENDS ${TARGET_OUTPUTS}
82+ SOURCES ${idl_files_with_proxy} ${idl_files_no_proxy} )
6783
6884endfunction ()
0 commit comments