[CMake] Can cmake generate Visual Studio projects without generating a makefile?

David Cole david.cole at kitware.com
Sat Dec 12 09:32:16 EST 2009


Why would add_custom_command call the C++ compiler?

add_custom_command will add a build rule that runs whatever command you tell
it to run. You also have to tell it what the OUTPUT is (full path to a file)
and what the DEPENDS (also full paths to files) are...

It doesn't do anything with the C++ compiler unless you tell it to....

If you are going to run "make" from a custom command, then the OUTPUT might
be a *.lib, *.dll or *.exe file that you expect to be there after a
successful make... And the DEPENDS would be the makefile and anything else
that you would want to cause a rebuild if it changed...

Does that make sense?

There are examples of add_custom_command on the CMake wiki and in the CMake
Tests directory. Check those out, too.


HTH,
David


On Sat, Dec 12, 2009 at 7:26 AM, Mark Jones <mark.jones1112 at gmail.com>wrote:

> Hi David,
>
> The documentation for add_custom_command seems to imply that it will only
> add a build command and not replace a build command.  The way that I
> interpret this is that cmake will generate a vcproj that executes my custom
> build command (gmake) that I add using add_custom_command but will also
> attempt to build the project in the normal Visual Studio fashion by calling
> the C++ compiler (CL.exe) directly.
>
> Am I misreading it?
>
> Mark
>
>
>
> On Fri, Dec 11, 2009 at 10:14 AM, David Cole <david.cole at kitware.com>wrote:
>
>> You can do what you want with add_custom_command and add_custom_target.
>> Have you read about those CMake commands...?
>>
>> http://cmake.org/cmake/help/cmake-2-8-docs.html#command:add_custom_command
>> http://cmake.org/cmake/help/cmake-2-8-docs.html#command:add_custom_target
>>
>>
>> HTH,
>> David
>>
>>
>> On Fri, Dec 11, 2009 at 9:17 AM, Mark Jones <mark.jones1112 at gmail.com>wrote:
>>
>>> If I have a build system in place (that uses gmake) that I am already
>>> comfortable with and would just like to use cmake to create Visual Studio
>>> (or XCode) projects that simply have release and debug targets that call
>>> gmake for me, can I do that with cmake?  Or, does cmake always generate a
>>> makefile too that is used by the projects that it creates?
>>>
>>> In other words, I want cmake to generate something like the following in
>>> the vcproj file:
>>>
>>>     <Configurations>
>>>         <Configuration
>>>             Name="debug|Win32"
>>>             OutputDirectory="log"
>>>             IntermediateDirectory="log"
>>>             ConfigurationType="0"
>>>             >
>>>             <Tool
>>>                 Name="VCNMakeTool"
>>>                 BuildCommandLine="gmake DEBUG=1 build"
>>>                 ReBuildCommandLine="gmake DEBUG=1 rebuild"
>>>                 CleanCommandLine="gmake DEBUG=1 clean"
>>>                 Output=""
>>>                 PreprocessorDefinitions="_DEBUG;DEBUG"
>>> [snip]
>>>             />
>>>         </Configuration>
>>>
>>> and I don't want it to write out any makefile at all as I want gmake to
>>> use the makefile that I already have in place.
>>>
>>> Also, I'd like to do the same kind of thing with XCode project generation
>>> and I'd like to know if that is possible too.
>>>
>>> If it always generates a makefile too, I imagine a workaround would be to
>>> let cmake create the vcproj file that builds using the cmake generated
>>> makefile, but then tell cmake to generate the makefile so that it then calls
>>> gmake on my already existing makefile, but that is not ideal since it would
>>> be an unnecessary step in the build process.
>>>
>>> Thanks,
>>> Mark
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091212/a95e2fc8/attachment.htm>


More information about the CMake mailing list