Sorry, typo. In the case of add_custom_target(), the files would be listed as DEPENDS.<br><br>Petr<br><br>On Tue, Sep 11, 2012 at 9:13 AM, Petr Kmoch <<a href="mailto:petr.kmoch@gmail.com">petr.kmoch@gmail.com</a>> wrote:<br>
> Hi Robert.<br>><br>> What you're after is pretty standard cmake. You'll need<br>><br>> add_custom_command(<br>> OUTPUT path_to/generated_header.h path_to/generated_source.cpp<br>> COMMAND midl.exe arguments to midl<br>
> other options of add_custom_command as necessary<br>> )<br>> # as many times as necessary (probably once per IDL source file)<br>><br>> Then, you can use the generated sources in add_library/add_executable<br>
> calls as normal, e.g.<br>> add_executable(UsesIDL path_to/some_source.cpp<br>> path_to/generated_header.h path_to/generated_source.cpp)<br>><br>> cmake knows internally when a source file is generated by a custom<br>
> command and does not require the file to be present at generation time<br>> in such case.<br>><br>> The above assumes all files generated from IDL are used in subsequent<br>> library/executable targets (or if they are not, they don't need to be<br>
> generated). If you need to run MIDL to generate files which are not<br>> used anywhere else in the build, you will need to add_custom_target()<br>> which uses these files as <span style="color:rgb(204,0,0)">DEPENDS</span>.<br>
><br>> Hope this helps.<br>><br>> Petr<br>><br>> On Tue, Sep 11, 2012 at 1:38 AM, Robert Dailey <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>> wrote:<br>>> I'm creating a shared library target that needs to compile and include<br>
>> source generated by an IDL. I want CMake to create a custom target<br>>> that will invoke MIDL.EXE (comes with Windows SDK) against the IDL<br>>> file to generate the header / source files needed. These header/source<br>
>> files will then be built by the shared library target. I saw a similar<br>>> post on this here:<br>>><br>>> <a href="http://www.cmake.org/pipermail/cmake/2011-July/045617.html">http://www.cmake.org/pipermail/cmake/2011-July/045617.html</a><br>
>><br>>> This seems complicated and I'm not sure it even works, since from my<br>>> tests, if source files don't exist by the time add_library,<br>>> add_executable, etc is called, generation will fail. I also don't want<br>
>> CMake to invoke MIDL for me since that would require us to run CMake<br>>> again every time the IDL file changes (this shouldn't be the case, we<br>>> should just have to rebuild the target again using Visual Studio or<br>
>> NMake).<br>>><br>>> Any ideas on a simple solution to this?<br>>><br>>> Thanks in advance.<br>>> --<br>>><br>>> Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>
>><br>>> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>>><br>>> Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
>><br>>> Follow this link to subscribe/unsubscribe:<br>>> <a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><br><br>