I have a COM server that tlb should integrate into. I collect it using cmake (ToolChain Visual Studio 2019) with the following commands
set(SOURCES ... myLib.idl myLib.rc)
add_executable(myLib.exe WIN32 ${SOURCES})
set(MIDL_OUTPUT
${CMAKE_CURRENT_LIST_DIR}/myLib_i.h
${CMAKE_CURRENT_LIST_DIR}/myLib_i.c
)
set(MIDL_FILE ${CMAKE_CURRENT_LIST_DIR}/myLib.idl)
set(TLB_NAME "${CMAKE_CURRENT_LIST_DIR}/myLib.tlb")
add_custom_command(
OUTPUT ${MIDL_OUTPUT}
COMMENT "midl /h myLib_i.h /iid myLib_i.c /tlb ${TLB_NAME} /proxy myLib_p.c ${MIDL_FILE} /env x64 /W1 /char signed /robust /nologo /Oicf /target NT60"
COMMAND midl /h myLib_i.h /iid myLib_i.c /tlb ${TLB_NAME} /proxy myLib_p.c ${MIDL_FILE} /env x64 /W1 /char signed /robust /nologo /Oicf /target "NT60"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${MIDL_FILE}
MAIN_DEPENDENCY ${MIDL_FILE}
VERBATIM
)
target_sources(myLib.exe PRIVATE ${MIDL_FILE} ${MIDL_OUTPUT})
and myLib.rc
file
1 TYPELIB "myLib.tlb"
Problem: after modifying the idl file, the tlb file of the previous version is added as a resource. Until I do a build of the project
As I understand it, the problem is that myLib.rc.res
file is not updated during compilation. How can I make it update?
It turned out like this:
add_custom_command(
OUTPUT ${MIDL_OUTPUT}
COMMENT "midl /h myLib_i.h /iid myLib_i.c /tlb ${TLB_NAME} /proxy myLib_p.c ${MIDL_FILE} /env x64 /W1 /char signed /robust /nologo /Oicf /target NT60"
COMMAND midl /h myLib_i.h /iid myLib_i.c /tlb ${TLB_NAME} /proxy myLib_p.c ${MIDL_FILE} /env x64 /W1 /char signed /robust /nologo /Oicf /target "NT60"
COMMAND "C:/Program Files/Git/usr/bin/touch.exe" -c "-r${TLB_NAME}" "${CMAKE_CURRENT_LIST_DIR}/myLib.rc"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${MIDL_FILE}
MAIN_DEPENDENCY ${MIDL_FILE}
VERBATIM
)
I added another command to add_custom_command
, which, when creating a tlb, changes the creation date of the rc file. After that, the compiler itself rebuilds myLib.rc.res