curl-library
Re: Build using CMake
Date: Sat, 28 Mar 2009 15:19:24 +0000
Piotr Dobrogost wrote:
> By the way; is/was there any effort to make auto* tools work under Windows?
Yes, I do this with my projects. It's quite easy.
You just have to install Mingw or Cygwin on Windows, and then you can
use the ./configure scripts etc. with Visual Studio as the compiler.
You need a tiny wrapper script to translate unix-style compiler
command lines (used by Autoconf and most Makefiles) to VC-style. Then
it works nicely: ./configure detects all the VC++ header files and
library functions, builds working executables etc. Your source needs
to be Windowsy to work with VC++ of course, but your build system can
use GNU Make and Autotools as usual.
Below is the wrapper script I used last time I did this.
The script is called "msvc". "cl" is the command line Microsoft Visual C++.
You also need to set the environment to be the same as "Visual Studio
Command Prompt". Either by actually using that directly, or by
copying the environment variables into a shell script for Mingw or
Cygwin to use.
Then to use the script, the command is
CC=msvc ./configure
make
(Another way to build Windows code is using Mingw and/or Cygwin
themselves. Mingw for native Windows executables and libraries
(similar to using VC++, uses Microsoft libraries and native Windows
code, but you get the niceness of the GNU compiler instead), and
Cygwin for unixy source code. I use all three for testing my projects
in different configurations.)
-- Jamie
#!/bin/ash
echo Input: "$@"
next= type=link outfile= default=
for arg; do
arg=$next$arg next=
shift
case "$arg" in
*/cygdrive/*)
prefix=${arg%%/cygdrive/*}
suffix=${arg#*/cygdrive/}
drive=${suffix%%/*}
case "$suffix" in */*) suffix=${suffix#*/} ;; *) suffix= ;; esac
case "$drive" in
?) arg=$prefix$drive:/$suffix ;;
*) arg=$prefix//$drive/$suffix ;;
esac ;;
esac
case "$arg" in
-g) ;; # Ignore this.
-o) next=$arg ;;
-l) next=$arg ;;
-o*)
outfile="${arg#-o}" ;;
-l*)
set x "$@" "${arg#-l}".lib; shift ;;
-O2* | -O3*)
set x "$@" /O2 /Ox; shift ;;
-O0*)
set x "$@" /Od; shift ;;
-Os | -O*)
set x "$@" /Os /O1; shift ;;
-c) type=nolink ;;
-*)
set x "$@" /"${arg#-}"; shift ;;
*.c | *.cc | *.C | *.CC | *.cxx | *.CXX | *.cs | *.CS )
: ${default:=${arg%.*}}
set x "$@" "$arg"; shift ;;
*)
set x "$@" "$arg"; shift ;;
esac
done
case "$type" in
nolink)
set x "$@" /c /Fo"${outfile:-$default.obj}"; shift ;;
*)
set x "$@" /Fe"${outfile:-a.exe}"; shift ;;
esac
echo Running: CL "$@"
exec CL "$@"
Received on 2009-03-28