The great thing is that cross compiling was very simple with to setup with
CMake in my case,  I didn't  require a "special" CMakeLists.txt.

All I do is create a file e.g. "setmingw" with:

export CC=i586-mingw32msvc-gcc
export CXX=i586-mingw32msvc-g++
export LD=i586-mingw32msvc-ld
export AR=i586-mingw32msvc-ar
export AS=i586-mingw32msvc-as
export NM=i586-mingw32msvc-nm
export STRIP=i586-mingw32msvc-strip
export RANLIB=i586-mingw32msvc-ranlib
export DLLTOOL=i586-mingw32msvc-dlltool
export OBJDUMP=i586-mingw32msvc-objdump
export RESCOMP=i586-mingw32msvc-windres
export CFLAGS=

then a
% source setmingw
% cmake
% make

Unfortunately the command SET_TARGET_PROPERTIES( ...) doesn't solve the
library problem, linking against the library will result in
"cannot find -lexample.dll"
(here the dll suffix is to much)
The thing that works is renaming the libraries e.g. libexample.so to
example.dll

I wasn't aware that CMake does not support cross-compiling. Apart from
linking against the library with the correct prefix/suffix it works in my
case. Also I didn't know the option CROSS_MINGW32, however it setting the
option doesn't solve the problem.

Thanks for your help,

Peter.


On 11/16/06, Eric Noulard <[EMAIL PROTECTED]> wrote:

I am really interested in getting sample CMakeLists.txt
since I just wanted to do what you've done, i.e. cross-compiling
for win32 under linux.

You should know that CMake does not currently support cross-compiling.
See
http://www.cmake.org/pipermail/cmake/2006-September/010959.html
or
http://www.cmake.org/pipermail/cmake/2006-September/010946.html

For your "problem" I think you may try this in your
project CMakeLists.txt

IF (UNIX)
    IF (CROSS_MINGW32)
        SET(MY_TARGETLIB_PREFIX "")
        SET(MY_TARGETLIB_SUFFIX ".dll")
    ELSE (CROSS_MINGW32)
        SET(MY_TARGETLIB_PREFIX "lib")
        SET(MY_TARGETLIB_SUFFIX ".so")
    ENDIF (CROSS_MINGW32)
ENDIF (UNIX)

I assume
OPTION(CROSS_MINGW32  "Cross compile Win32 using mingw32" OFF)

was set ON for mingw32 cross compiling
and OFF for Linux "native" compiling.

Then use your MY_TARGETLIB_xxx
in all other places:
SET_TARGET_PROPERTIES(ex1
   PROPERTIES
   PREFIX $(MY_TARGETLIB_PREFIX)
   SUFFIX $(MY_TARGETLIB_SUFFIX)
                                            )

2006/11/16, Peter Visser <[EMAIL PROTECTED]>:
>  Hi,
>
>  I have a working build under win32 with MSYS/MINGW, now I would like to
> cross-compile code for win32 with mingw from linux with by using the
same
> CMakelists.txt files. It almost works, the problem is that the shared
> libraries are not named "myex.dll" but "libmyex.so". By using the
following
> command for all the libraries it can be solved:
>
>  SET_TARGET_PROPERTIES(ex1
>
> PROPERTIES PREFIX ""
>                                                    SUFFIX
> ".dll"
>                                                   )
>
>  However, now I have to change the CMakelist.txt in all the
subdirectories
> and lose the ability to compile natively for linux (without adding an
> IF(UNIX) around the SET_TARGET_PROPERTIES).
>
>  Is there a global option to set the PREFIX and SUFFIX, set the
BUILD_TARGET
> to win32 or something alike?
>
>  I tried setting:
>
>  SET(UNIX FALSE)
>  SET(MINGW TRUE)
>  SET(WIN32 TRUE)
>
>  But that doesn't help.
>
>  Any help is appreciated,
>
>  Peter.
> _______________________________________________
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
>


--
Erk
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to