Can cmake generate Visual Studio projects without generating a makefile?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Can cmake generate Visual Studio projects without generating a makefile?

Mark Jones-3
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
Reply | Threaded
Open this post in threaded view
|

Re: Can cmake generate Visual Studio projects without generating a makefile?

David Cole
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_target


HTH,
David


On Fri, Dec 11, 2009 at 9:17 AM, Mark Jones <[hidden email]> 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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Can cmake generate Visual Studio projects without generating a makefile?

Mark Jones-3
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 <[hidden email]> 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_target


HTH,
David


On Fri, Dec 11, 2009 at 9:17 AM, Mark Jones <[hidden email]> 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



_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Can cmake generate Visual Studio projects without generating a makefile?

David Cole
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 <[hidden email]> 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 <[hidden email]> 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_target


HTH,
David


On Fri, Dec 11, 2009 at 9:17 AM, Mark Jones <[hidden email]> 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




_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Can cmake generate Visual Studio projects without generating a makefile?

David Cole
On Sun, Dec 13, 2009 at 8:20 AM, Mark Jones <[hidden email]> wrote:
Hi David,

Thank you for all of your help so far.

You're welcome...

Am I attempting to use cmake in a way that is incompatible with cmake, or in a way that it wasn't intended for?  It is OK if I am attempting to use it in a way it isn't designed for (in which case I can accept that and move on), 

Yes, unfortunately, you are. (So accept it, and move on...)   :-)

You can *either* do add_custom_command stuff and have a bare Visual Studio project without any source files in (but that drives your build through Visual Studio and your existing makefiles without intellisense and all that)...

*Or* you can convert the makefiles you do have into CMakeLists.txt files that list all the sources, do add_library, add_executable and include_directories calls and generate VS project files that *replace* your makefiles...

But not both. (At least not without major CMake re-work...)

Why not convert your existing makefiles and just use CMake? It wouldn't be that much more effort than getting CMake to generate a hybrid/fake thing like you're trying to do already...


HTH,
David


_______________________________________________
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