来自 CMAKE 的 MIDL 编译器

MIDL compiler from CMAKE

我按照说明做了

set(MIDL_OUTPUT
    ${CMAKE_CURRENT_BINARY_DIR}/IFace.h
    ${CMAKE_CURRENT_BINARY_DIR}/GUIDS.c
    ${CMAKE_CURRENT_BINARY_DIR}/Proxy.c
    ${CMAKE_CURRENT_BINARY_DIR}/ProxyDll.c
    )
set(MIDL_FILE
    ${CMAKE_CURRENT_LIST_DIR}/BookSku.idl
    )
add_custom_command(
    OUTPUT ${MIDL_OUTPUT}
    COMMAND midl /h IFace.h /iid GUIDS.c /proxy Proxy.c /dlldata ProxyDll.c 
${MIDL_FILE}
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    DEPENDS ${MIDL_FILE}
    MAIN_DEPENDENCY ${MIDL_FILE}
    VERBATIM
    )

IDL 文件构建的输出依赖于许多 headers,因此它需要跟踪这些是否已更改以确定是否应该重建类型库。但是当你更改文件并推送 "Build" 时,VS2017 中的项目不会重建。需要推送"Rebuild"。 如何跟踪文件更改?

Answer in Cmake.org

DEPENDS: Specify files on which the command depends. Each argument is converted to a dependency as follows: