Skip to content

Commit

Permalink
Fixes for swig builds and tests using MSVC
Browse files Browse the repository at this point in the history
On windows platforms, with paths set up for MSVC toolchains,
this works to build swig and run test suites, assuming
"windows" install of boost.

./autogen.sh;  ./configure CC='cl' CXX='cl' --with-boost=c:/boost_1_55_0 --without-pcre

Also remove -g flag generating annoying swig warnings.
May be some more proper autoconf way to do this.
  • Loading branch information
marvingreenberg committed Feb 21, 2014
1 parent d55692c commit 900cf4d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
35 changes: 27 additions & 8 deletions configure.ac
Expand Up @@ -27,11 +27,21 @@ AH_BOTTOM([

dnl Check for programs that a user requires to build SWIG
AC_PROG_CC
# When using CL for CC should use it for CXX too
# AM_PROG_CC_C_O rewrites $CC, so cannot test "$CC" = cl
MSVC=
$CC -? 2>&1 | grep -i microsoft >/dev/null && MSVC=yes
CXX=$CC
AC_PROG_CXX
AC_EXEEXT
AC_OBJEXT
AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS

# Want CXX to be same rewritten CC
if test "$MSVC" = yes; then
CFLAGS=`echo "$CFLAGS" | sed -e 's/-g//'`
CXXFLAGS=`echo "$CFLAGS" | sed -e 's/-g//'`
CXX=$CC
fi
AC_COMPILE_WARNINGS # Increase warning levels

AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG])
Expand Down Expand Up @@ -104,11 +114,15 @@ AS_IF([test "x$with_pcre" != xno],
])


if test "$MSVC" = yes; then
enable_ccache=
AC_MSG_NOTICE([Disabling ccache for $CC])
else
dnl CCache
AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes])
AC_MSG_CHECKING([whether to enable ccache-swig])
AC_MSG_RESULT([$enable_ccache])

fi
if test "$enable_ccache" = yes; then
AC_CONFIG_SUBDIRS(CCache)
ENABLE_CCACHE=1
Expand Down Expand Up @@ -187,9 +201,10 @@ then
if test "$GCC" = yes; then
LDSHARED="$CC -shared"
else
if test "cl" = $CC ; then
# Microsoft Visual C++ (MSVC)
LDSHARED="$CC -nologo -LD"

if test "$MSVC" = yes ; then
# Microsoft Visual C++ (MSVC). '/' else autotools 'compile' breaks
LDSHARED='$(CC) /nologo /LD'
else
# Unknown compiler try gcc approach
LDSHARED="$CC -shared"
Expand Down Expand Up @@ -253,9 +268,9 @@ then
if test "$GCC" = yes; then
TRYLINKINGWITHCXX="CXXSHARED= $CXX -shared "
else
if test "cl" = $CXX ; then
# Microsoft Visual C++ (MSVC)
TRYLINKINGWITHCXX="CXXSHARED= $CXX -nologo -LD"
if test "$MSVC" = yes ; then
# Microsoft Visual C++ (MSVC). '/' else autotools 'compile' breaks
TRYLINKINGWITHCXX='CXXSHARED= $(CXX) /nologo /LD'
else
TRYLINKINGWITHCXX="#unknown Windows compiler"
fi
Expand Down Expand Up @@ -356,9 +371,13 @@ fi
# libc++ for tests and examples to run under mono. May affect
# other language targets as well - problem is an OSX incompatibility
# between libraries depending on libstdc++ and libc++.
# MS compiler requires /EHsc for exception support to run tests
CLANGXX=
$CXX -v 2>&1 | grep -i clang >/dev/null && CLANGXX=yes
case $host in
*-*-cygwin* |*-*-mingw* ) if test "$MSVC" = "yes";
then PLATCXXFLAGS="$PLATCXXFLAGS -EHsc"
fi;;
*-*-darwin11* | *-*-darwin12* |*-*-darwin13* ) if test "$CLANGXX" = "yes";
then PLATCXXFLAGS="$PLATCXXFLAGS -stdlib=libc++"
fi;;
Expand Down
4 changes: 3 additions & 1 deletion preinst-swig.in
Expand Up @@ -2,6 +2,8 @@
builddir=`dirname $0`
srcdir=`cd "$builddir" && cd '@srcdir@' && pwd`
SWIG_LIB=$srcdir/Lib
#SWIG_LIB=`cygpath -w $srcdir/Lib` # For native Windows version of SWIG
# For native Windows version of SWIG
"$builddir/swig" -version 2>&1 | \
grep -i 'compiled with' | grep -i -e ' cl ' -e ' cl.exe ' && SWIG_LIB=`cygpath -w $srcdir/Lib`

This comment has been minimized.

Copy link
@vadz

vadz Feb 21, 2014

Couldn't we just do

case `uname` in
    CYGWIN*)
        SWIG_LIB=`cygpath -w $srcdir/Lib`
        ;;
esac

here, as usual? It would be slightly less cryptic IMHO.

This comment has been minimized.

Copy link
@marvingreenberg

marvingreenberg Feb 21, 2014

Author Owner

Depending on what you're trying to do, you could still be configured to use cygwin toolchain gcc/g++, so cannot just hardcode. OTOH, this could just be an autoconf substitution. It's just the last thing I fixed.

export SWIG_LIB
exec "$builddir/swig" $*

0 comments on commit 900cf4d

Please sign in to comment.