I ran into this problem using Visual Studio 2008 and wrote up a macro to
generate the add_custom_command for each idl file. The function will rerun the
build command whenever the idl file is modified. There is very little
documentation for working with idl files online, so I hope this helps you.
Variables:
IDL_H_FILES: Generated header files
IDL_C_FILES: Generated C files
IDL_OUTPUT_LOC: The location where you want the build products to be
placed
idl_file1.idl ...: A list of idl files that you want to run the macro
against.
#IDL_COMPILE( IDL_H_FILES_VAR IDL_C_FILES_VAR IDL_OUTPUT_LOC_VAR idl_file1.idl
idl_file2.idl ... )
MACRO( IDL_COMPILE IDL_H_FILES_VAR IDL_C_FILES_VAR IDL_OUTPUT_LOC )
IF( WIN32 )
SET( ${IDL_H_FILES} "" )
SET( ${IDL_C_FILES} "" )
FOREACH( INDEX ${ARGN} )
GET_FILENAME_COMPONENT( INFILE_NAME ${INDEX} NAME_WE )
GET_FILENAME_COMPONENT( INFILE_PATH ${INDEX} PATH )
SET( OUT_H_FILE "${INFILE_NAME}.h" )
SET( OUT_H_FILE_FULL "${IDL_OUTPUT_LOC}/${OUT_H_FILE}" )
SET( OUT_IC_FILE "${INFILE_NAME}_i.c" )
SET( OUT_IC_FILE_FULL "${IDL_OUTPUT_LOC}/${OUT_IC_FILE}" )
SET( OUT_PC_FILE "${INFILE_NAME}_p.c" )
SET( OUT_PC_FILE_FULL "${IDL_OUTPUT_LOC}/${OUT_PC_FILE}" )
SET( OUT_TLB_FILE "${INFILE_NAME}.tlb" )
SET( OUT_TLB_FILE_FULL "${IDL_OUTPUT_LOC}/${OUT_TLB_FILE}" )
IF( "${ZEBRA_PLATFORM}" STREQUAL "x32" )
SET( DEST_PLATFORM "win32" )
ELSE( "${ZEBRA_PLATFORM}" STREQUAL "x32" )
SET( DEST_PLATFORM "x64" )
ENDIF( "${ZEBRA_PLATFORM}" STREQUAL "x32" )
ADD_CUSTOM_COMMAND( OUTPUT ${OUT_H_FILE_FULL} ${OUT_IC_FILE_FULL}
${OUT_TLB_FILE_FULL}
COMMAND midl
ARGS \"${INDEX}\" /I \"${INFILE_PATH}\" /char signed /env
${DEST_PLATFORM} /Oicf /tlb \"${OUT_TLB_FILE}\" /out \"${IDL_OUTPUT_LOC}\" /h
\"${OUT_H_FILE}\" /iid \"${OUT_IC_FILE}\" /proxy \"${OUT_PC_FILE}\"
MAIN_DEPENDENCY ${INDEX}
)
LIST( APPEND ${IDL_H_FILES_VAR} "${OUT_H_FILE_FULL}" )
LIST( APPEND ${IDL_C_FILES_VAR} "${OUT_IC_FILE_FULL}" )
ENDFOREACH( INDEX )
ENDIF( WIN32 )
ENDMACRO( ZEBRA_IDL_COMPILE )
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
avner cohen
Sent: Sunday, August 02, 2009 11:33 AM
To: [email protected]
Subject: [CMake] Auto detect IDL changes
Greetings all,
I've been deploying Cmake into our project for the past 2-3 months and just up
with a problem I was unable to resovle so far.
As part of the work we do, during Cmake execution, we also compile our C++ IDLs.
I've managed to come up with a clean EXECUTE_PROCESS code that will run this on
all OSs.
The problem is that IDLs do not change on a frequent basis and the fact that
these are added to the cmake makes it very generic, but forces a full build
with every build request.
Is there any way to come up with a way to identify the case where IDLs are
changed only than execute the compilation code?
Thanks in Advance,
Avner Cohen.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake