[CMake] How to set up Cygwin + CMake + GNU Makefiles + cl.exe correctly?
Maik Beckmann
beckmann.maik at googlemail.com
Fri May 30 14:59:24 EDT 2008
Am Freitag 30 Mai 2008 20:36:02 schrieb Bill Hoffman:
> Stefan Buschmann wrote:
> > Thanks! I finally got it to work now. The problem was that invoking the
> > script does not really "export" the variables to the shell - so in my
> > own tests, "cmake" had it's environment variables set right, because I
> > invoked it directly from the script, but when running "make" later, the
> > variables were not set. I'm now exporting all those variables directly
> > in my .bashrc file - is there a better way to invoke the script?
>
> No, you have to have the shell setup with a working cl for things to
> work...
>
> I just source a file that has the values in it each time I start a
> shell. Something like:
>
> . ~/vsEnv
>
> That will put the exports into the current shell.
>
> -Bill
I made a copy of the cygwin starter .bat, called it cygwin_vs2005.bat and
added
call C:\path\to\vcvars32.bat
This sets all variables to get cl to work and one hasn't to take care about
changing variable naming policies.
While this work at command line, the following works nicely with Visual Studio
Makefiles projects: create a .bat file i.e. set_vars.bat
{{{
call C:\path\to\vcvars32.bat
set PATH=%PATH%;C:\path\to\cygwin\bin
set CC=cl
set CXX=cl
rem set CFLAGS=whatever
rem set CXXFLAGS=whatever
}}}
Now Visual Studio can call i.e.
{{{set_vars.bat && sh -c "cd build && make"}}}
Or even better, place a cygwin.mk at the toplevel of you cmake project
containing i.e.
{{{
pwd=$(shell cygpath -d `pwd`)
BUILD_DIR=Debug
CMAKE_EXE=/path/to/cmake
CMAKE_ARGS= -G"Unix Makefiles"
CMAKE_ARGS+= -DCMAKE_BUILD_TYPE=$(BUILD_DIR)
CMAKE_ARGS+= -DCMAKE_VERBOSE_MAKEFILE=on
CMAKE_ARGS+= -DCMAKE_INSTALL_PREFIX=$(pwd)/stage
#change to "all: #$(BUILD_DIR)/CMakeCache.txt" if configured proper
all: $(BUILD_DIR)/CMakeCache.txt
cd $(BUILD_DIR) && $(MAKE)
$(BUILD_DIR)/CMakeCache.txt: $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE_EXE) $(CMAKE_ARGS) ../
$(BUILD_DIR):
mkdir $(BUILD_DIR)
}}}
Now Visual Studio can trigger this by
{{{set_vars.bat && sh -c "make -f cygwin.mk all"}}}
and if you got a quad core this
{{{set_vars.bat && sh -c "make -j5 -f cygwin.mk all"}}}
might be helpful :)
Best,
-- Maik
More information about the CMake
mailing list