For an input idl file named "AxVJV.idl" the Visual Studio .NET 2003 wizard (by Microsoft) produces sections like this in the vcproj files:
           <Tool
               Name="VCMIDLTool"
               PreprocessorDefinitions="_DEBUG"
               MkTypLibCompatible="FALSE"
               TargetEnvironment="1"
               GenerateStublessProxies="TRUE"
               TypeLibraryName="$(IntDir)/AxVJV.tlb"
               HeaderFileName="AxVJV.h"
               DLLDataFileName=""
               InterfaceIdentifierFileName="AxVJV_i.c"
               ProxyFileName="AxVJV_p.c"/>

CMake 2.2.3 (and live CVS CMake) produces sections like this:
           <Tool
               Name="VCMIDLTool"/>

I think they should both produce sections like this (differences from wizard generated section highlighted in bold red) so that all the midl output files for different configurations are automatically sent to the $(IntDir) location. That way, midl output from one config won't clobber or accidentally depend on midl output from another config... Also, using InputName here allows for multiple idl files to co-exist in a single vcproj file semi-peacefully.
           <Tool
               Name="VCMIDLTool"
               PreprocessorDefinitions="_DEBUG"
               MkTypLibCompatible="FALSE"
               TargetEnvironment="1"
               GenerateStublessProxies="TRUE"
               TypeLibraryName="*$(InputName)*.tlb"
*                OutputDirectory="$(IntDir)"
*                HeaderFileName="*$(InputName)*.h"
               DLLDataFileName=""
               InterfaceIdentifierFileName="*$(InputName)*_i.c"
               ProxyFileName="*$(InputName)*_p.c"/>

Could we make CMake produce VCMIDLTool sections like I want them? :-)
The implementation might look like this (in cmLocalVisualStudio7Generator.cxx)

     fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"\n";
     fout << "\t\t\t\tPreprocessorDefinitions=\"" << pre;
     this->OutputDefineFlags(defineFlags.c_str(), fout);
     fout << "\"\n";
     fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";
     fout << "\t\t\t\tTargetEnvironment=\"1\"\n";
     fout << "\t\t\t\tGenerateStublessProxies=\"TRUE\"\n";
     fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n";
     fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n";
     fout << "\t\t\t\tHeaderFileName=\"$(InputName).h\"\n";
     fout << "\t\t\t\tDLLDataFileName=\"\"\n";
     fout << "\t\t\t\tInterfaceIdentifierFileName=\"$(InputName)_i.c\"\n";
     fout << "\t\t\t\tProxyFileName=\"$(InputName)_p.c\"/>\n";
     // end of <Tool Name=VCMIDLTool


Once this is implemented, there are two more things that need to be done to make idl files work "100%" with Visual Studio: include the generated "_i.c" file somehow and modify the include paths for c/c++ and rc files to include "$(IntDir)". These things are easy to implement, though: The include path is just another INCLUDE_DIRECTORIES statement in CMakeLists.txt and the "_i.c" and file can simply be #included by another one of your c/c++ source files. Having the extra include path happen *automatically *for projects that have an .idl source file would be a nice bonus, however.

Secondarily, but along the same lines... Perhaps a bit more work: could we add support for idl files to the make file generators? (At least to the NMake generator when midl is available as a command line tool on Windows...) Currently I get an error like this when I try to use a source file with an "idl" extension with the "NMake Makefiles" generator:

   -- Configuring done
   CMake Error: Source file "C:/blahblah/AxVJV.idl" has unknown type.
   -- Generating done
   -- Build files have been written to: C:/blahblah/bin

It generates a makefile, but then it can't build, because the first source file compiled depends on a header that should have been generated by midl. I can workaround this for now by adding a custom command for midl...


It's all just a little bit annoying when you're trying to convert a project that includes an idl file to be built via a CMake-centric build process.


Thanks,
David

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to