[CMake] Visual Studio command line from CMake

Rob McDonald rob.a.mcdonald at gmail.com
Thu Jan 9 00:45:21 EST 2014


Very sorry for not replying to the list, I certainly meant to.  I didn't
mean to impose my problem on you -- and I was hoping that by flushing my
example out more fully, more people may be able to help out.  I will go
back and forward that response/question so people don't have to dig it out
of this chain.


On Wed, Jan 8, 2014 at 8:49 PM, J Decker <d3ck0r at gmail.com> wrote:

> (you should have replied that back to the list....)
> My uppermost project is a project chain of independant source parts in
> my tree... the topmost project writes out makeit.bat configuration
> files with a "cmake ..." command that has all the required options and
> switches (I'll append at end) and then the appropriate build command
> for the cmake environment...
>
> but then from the commandline I just do cmake --build . in the
> directory... (or makeit.bat)
>
> maybe you need something like... (I took the build command (and cmake
> command for the configuration of it)
>
>   if( MSVC )
>
>     if( NOT EXISTS ${BUILD}/${SOLUTION}.sln )
>
>       FILE( WRITE ${BUILD}/${SOLUTION}.sln )
>
>     endif()
>
>     if( ${CMAKE_MAKE_PROGRAM} MATCHES .*[Mm][Ss][Bb]uild.* )
>
>      build_command( BUILD_COMMAND CONFIGURATION ${CMAKE_BUILD_TYPE}
> PROJECT_NAME ${SOLUTION} TARGET INSTALL )
>
>           SET( MORE_ARGS /m:4 /v:m )
>
>     else()
>
>    build_command( BUILD_COMMAND CONFIGURATION ${CMAKE_BUILD_TYPE}
> PROJECT_NAME ${SOLUTION} TARGET INSTALL.vcxproj )
>
>     endif()
>
>     SEPARATE_ARGUMENTS( BUILD_COMMAND WINDOWS_COMMAND ${BUILD_COMMAND} )
>
>     SET( BUILD_COMMAND ${BUILD_COMMAND} ${MORE_ARGS} )
>
>     SET( ADD_SOURCES  SOURCES ${BUILD}/${SOLUTION}.sln )
>
>   else( MSVC )
>
>     build_command( BUILD_COMMAND CONFIGURATION ${CMAKE_BUILD_TYPE}
> PROJECT_NAME ${SOLUTION} TARGET install )
>
>     SEPARATE_ARGUMENTS( BUILD_COMMAND UNIX_COMMAND ${BUILD_COMMAND} )
>
>   endif( MSVC )
>
>
>
>
> ---- Then later I had to -----
>
>   string (REPLACE ";" " " FAKE_BUILD_COMMAND "${BUILD_COMMAND}")
>   FILE( APPEND ${BUILD}/${SCRIPTNAME} ${FAKE_BUILD_COMMAND} )
>
> I was writing the invokation to a file...  I don't know if the
> expansion from ';' to space is required if it's used with
> execute_process....
>
> EXECUTE_PROCESS(COMMAND ${BUILD_COMMAND} )
>
>
>  --- sample makeit.bat ---
> "c:/tools/unix/cmake/bin/cmake.exe" -G "Visual Studio 11" -T "v110_xp"
>  "M:/sack/cmake_all/.." -DCMAKE_BUILD_TYPE=debug
>
> -DCMAKE_INSTALL_PREFIX=C:/general/build/vs11-x86.monolithic/sack/debug_solution/../debug_out/core
> -DBUILD_MONOLITHIC=1 -D__NO_ODBC__= -DNEED_FREETYPE=1 -DNEED_JPEG=1
> -DNEED_PNG=1 -DNEED_ZLIB=1 -DBULLET_SOURCE=M:/bullet/source
>
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
> INSTALL.vcxproj /p:Configuration=debug /p:VisualStudioVersion=11.0
> /m:4 /v:m
>  --- end sample makeit.bat ---
>
>
> And Please understand I may be totally missing your point...
>
> When is it that you want to run msbuild?
>

As far as I know, I never run msbuild.

The command line Makefile driven system Erco put together (the non-FLTK
download link from before) is a one-stop shop.

By running 'gmake.bat', it configures the program and then launches the
build via gmake.exe.  I do not believe it ever creates a *.prj or *.sln
file.  I do not believe it ever runs msbuild.  I believe gmake works with
the Makefile to call the compiler via 'cl' directly.

However, I haven't dug super deep into Erco's magic.

Rob




> On Wed, Jan 8, 2014 at 7:50 PM, Rob McDonald <rob.a.mcdonald at gmail.com>
> wrote:
> > Thanks for the tip, but that hasn't been very helpful to me.  Perhaps I'm
> > not doing it right.  Here is a bit of CMake code so the conversation can
> be
> > more concrete...
> >
> > You'll need these two files...
> >
> >
> http://www.fltk.org/software.php?VERSION=1.3.2&FILE=fltk/1.3.2/fltk-1.3.2-source.tar.gz
> > http://seriss.com/people/erco/fltk/tmp/vsnet-makefiles.0.85.zip
> >
> > Place them in the same directory with the following in the CMakeLists.txt
> >
> > CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
> >
> > INCLUDE( ExternalProject )
> >
> > SET( VS_MAKEFILE_ZIP vsnet-makefiles.0.85.zip )
> >
> > ExternalProject_Add( FLTK
> > URL ${CMAKE_SOURCE_DIR}/fltk-1.3.2-source.tar
> > UPDATE_COMMAND
> > ${CMAKE_COMMAND} -E copy_if_different
> > ${CMAKE_SOURCE_DIR}/${VS_MAKEFILE_ZIP}
> > <SOURCE_DIR>/${VS_MAKEFILE_ZIP}
> > COMMAND
> > ${CMAKE_COMMAND} -E tar -xzf <SOURCE_DIR>/${VS_MAKEFILE_ZIP}
> >
> > PATCH_COMMAND ""
> > CONFIGURE_COMMAND ""
> > BUILD_COMMAND ""
> > INSTALL_COMMAND ""
> > )
> >
> >
> > To build this manually, first, unzip both files into the same directory.
> > Then, launch the Visual Studio Command Prompt, usually accessed via the
> > VS/vcvarsall.bat program included with Visual Studio.
> >
> > Once both files are unzipped into the same directory, and you are in the
> VS
> > prompt environment, you can build FLTK using the batch program
> 'gmake.bat'.
> >
> > For better or worse, it prompts the user to input for Debug or Release,
> and
> > then for Verbose or Quiet.  If you make a simple text file with the
> entries
> > one per line...
> >
> > ******* input.txt
> > R
> > Q
> > *******
> >
> > You can feed that to the batch program thusly....
> >
> > gmake < input.txt
> >
> > Alternately, if you can set DEBUG=R and VERBOSE=Q environment variables
> to
> > the shell used to run 'gmake.bat', then you don't have to feed the text
> file
> > for the user-input prompts.
> >
> > I tried something like the following....
> >
> > BUILD_COMMAND
> >    ${CMAKE_COMMAND} --build <SOURCE_DIR> -- gmake
> >
> > But, it didn't seem to do anything useful....
> >
> > Rob
> >
> >
> > On Wed, Jan 8, 2014 at 5:31 PM, J Decker <d3ck0r at gmail.com> wrote:
> >>
> >> cmake --build
> >>
> >> On Wed, Jan 8, 2014 at 3:53 PM, Rob McDonald <rob.a.mcdonald at gmail.com>
> >> wrote:
> >> > Short version:
> >> >
> >> > Does anyone have an elegant way to launch the visual studio command
> line
> >> > from within CMake?
> >> >
> >> > James Bigler asked essentially this question back in March of 2011.
> >> > David
> >> > responded with a link to a Blog entry, but I haven't figured out how
> to
> >> > translate that into something that works.
> >> >
> >> > The 'vcvarsall.bat' program that comes with Visual Studio will launch
> >> > the
> >> > command line with the full environment set.
> >> >
> >> > Once I find vcvarsall, I then need to launch something in it -- and
> pass
> >> > parameters to that thing.  All from within ExternalProject_Add.  For
> >> > now,
> >> > one step at a time...
> >> >
> >> > Long version:
> >> >
> >> > I'm trying to encapsulate the build of FLTK as an ExternalProject in
> >> > CMake.
> >> > One way or the other, it needs to work for Visual Studio on Windows,
> and
> >> > gcc
> >> > and llvm on Linux/MacOS.
> >> >
> >> > Although FLTK has a CMake build system, it is currently unmaintained
> >> > (broken
> >> > on at least some platforms), and none of the core FLTK developers use
> >> > it, so
> >> > I don't see this situation improving.
> >> >
> >> > I've got a ./configure based system working for Linux/MacOS.
> >> >
> >> > One of the FLTK developers maintains an unofficial Makefile setup for
> >> > FLKT/Visual Studio that must be run from the Visual Studio command
> >> > prompt.
> >> > Hence my question...
> >> >
> >> > http://seriss.com/people/erco/fltk/tmp/vsnet-makefiles.0.85.zip
> >> >
> >> > Thanks for any help,
> >> >
> >> > Rob
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> >
> >> > Powered by www.kitware.com
> >> >
> >> > Please keep messages on-topic and check the CMake FAQ at:
> >> > http://www.cmake.org/Wiki/CMake_FAQ
> >> >
> >> > Kitware offers various services to support the CMake community. For
> more
> >> > information on each offering, please visit:
> >> >
> >> > CMake Support: http://cmake.org/cmake/help/support.html
> >> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> >> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >> >
> >> > Visit other Kitware open-source projects at
> >> > http://www.kitware.com/opensource/opensource.html
> >> >
> >> > 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/20140108/b7914d6b/attachment-0001.htm>


More information about the CMake mailing list