[CMake] compiling idl files

Guilherme Balena Versiani guibv at comunip.com.br
Fri Jun 22 18:16:04 EDT 2007


You have to add .c (or .cpp) and .h files to the source list for the 
project, as usual, but you need to mark them as 'generated' (if you 
forget this, cmake will complain about missing files for the first 
build). You should look MSDN for midl syntax, but you can remove the 
"/nologo" flag from a MSVC6 generated project that uses some 'idl' 
files, so it will print out the command line (it should be a good start 
point). I done a similar work when I ported my old MSVC6 project base to 
cmake.

Regards,

Guilherme Balena Versiani.


Jon W wrote:
> Adding the idl files as source seems to work to a certain point, but
> I'm missing some syntax to have this work in reality.  I'm not sure
> how to write this syntax to then compile the .c and .h files that are
> generated by midl.  Maybe another cmakelist.txt file?
>
> Thank you for the macro.  Right now I'll try this with midl to compile
> the idl files.
>
> If anybody else has examples, please let me know.
> -Jon
>
> On 6/22/07, Guilherme Balena Versiani <guibv at comunip.com.br> wrote:
>> AFAIK, you just need to add these files as source ones (I didn't tested
>> to make sure, but I think it do the job)...
>>
>> If you are talking about XPCOM IDLs, then you need to use
>> ADD_CUSTOM_COMMAND, in a similar way as you do for .y and .l files
>> (yacc/flex), put these IDL files as a dependecy for each .h file
>> generated and mark that .h files as 'generated', so cmake does not
>> complain the missing headers (if you like to add the generated headers
>> as source ones). I have a 'MacroAddInterfaces.cmake' file in my own
>> project with something like:
>>
>> ----
>> # MACRO_ADD_INTERFACES(idl_files...)
>>
>> # Copyright (c) 2007, Guilherme Balena Versiani, <guibv at comunip.com.br>
>> #
>> # Redistribution and use is allowed according to the terms of the BSD
>> license.
>> # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
>>
>> MACRO (MACRO_ADD_INTERFACES)
>>
>>   FOREACH(_in_FILE ${ARGN})
>>
>>     GET_FILENAME_COMPONENT(_out_FILE ${_in_FILE} NAME_WE)
>>     GET_FILENAME_COMPONENT(_in_PATH ${_in_FILE} PATH)
>>
>>     ADD_CUSTOM_COMMAND(
>>       OUTPUT ${XPCOM_INTERFACES_DIR}/${_out_FILE}.h
>>       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE}
>>       COMMAND ${XPIDL_EXECUTABLE} -m header ${VXIDL_INCLUDES} -I
>> ${CMAKE_CURRENT_SOURCE_DIR}/${_in_PATH} -o ${_out_FILE}
>> ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE}
>>       WORKING_DIRECTORY ${XPCOM_INTERFACES_DIR}
>>     )
>>
>>     MACRO_ADD_FILE_DEPENDENCIES(
>>       ${XPCOM_INTERFACES_DIR}/${_out_FILE}.h
>>       ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE}
>>     )
>>
>>     SET_SOURCE_FILES_PROPERTIES(
>>       ${XPCOM_INTERFACES_DIR}/${_out_FILE}.h
>>       PROPERTIES
>>       GENERATED TRUE
>>     )
>>
>>   ENDFOREACH(_in_FILE ${ARGN})
>>
>> ENDMACRO (MACRO_ADD_INTERFACES)
>>
>> Regards,
>>
>> Guilherme Balena Versiani.
>>
>>
>> Jon W wrote:
>> > Does anybody have a CMakelists.txt example on how to properly compile
>> > idl files into visual studio projects?  I'm not sure if I need to use
>> > ADD_CUSTOM_COMMAND or just list the idl files in the sources, etc..
>> >
>> > Thanks,
>> > Jon
>> > _______________________________________________
>> > CMake mailing list
>> > CMake at cmake.org
>> > http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list