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.<br><br>All I do is create a file e.g. "setmingw" with:<br><br>
export CC=i586-mingw32msvc-gcc<br>export CXX=i586-mingw32msvc-g++<br>export LD=i586-mingw32msvc-ld<br>export AR=i586-mingw32msvc-ar<br>export AS=i586-mingw32msvc-as<br>export NM=i586-mingw32msvc-nm<br>export STRIP=i586-mingw32msvc-strip
<br>export RANLIB=i586-mingw32msvc-ranlib<br>export DLLTOOL=i586-mingw32msvc-dlltool<br>export OBJDUMP=i586-mingw32msvc-objdump<br>export RESCOMP=i586-mingw32msvc-windres<br>export CFLAGS=<br><br>then a <br>% source setmingw
<br>% cmake<br>% make<br><br>Unfortunately the command SET_TARGET_PROPERTIES( ...) doesn't solve the library problem, linking against the library will result in <br>"cannot find -lexample.dll"<br>(here the dll suffix is to much)
<br>The thing that works is renaming the libraries e.g. libexample.so to example.dll<br><br>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.
<br><br>Thanks for your help,<br><br>Peter.<br><br><br><div><span class="gmail_quote">On 11/16/06, <b class="gmail_sendername">Eric Noulard</b> <<a href="mailto:eric.noulard@gmail.com">eric.noulard@gmail.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am really interested in getting sample CMakeLists.txt<br>since I just wanted to do what you've done,
i.e. cross-compiling<br>for win32 under linux.<br><br>You should know that CMake does not currently support cross-compiling.<br>See<br><a href="http://www.cmake.org/pipermail/cmake/2006-September/010959.html">http://www.cmake.org/pipermail/cmake/2006-September/010959.html
</a><br>or<br><a href="http://www.cmake.org/pipermail/cmake/2006-September/010946.html">http://www.cmake.org/pipermail/cmake/2006-September/010946.html</a><br><br>For your "problem" I think you may try this in your
<br>project CMakeLists.txt<br><br>IF (UNIX)<br> IF (CROSS_MINGW32)<br> SET(MY_TARGETLIB_PREFIX "")<br> SET(MY_TARGETLIB_SUFFIX ".dll")<br> ELSE (CROSS_MINGW32)<br> SET(MY_TARGETLIB_PREFIX "lib")
<br> SET(MY_TARGETLIB_SUFFIX ".so")<br> ENDIF (CROSS_MINGW32)<br>ENDIF (UNIX)<br><br>I assume<br>OPTION(CROSS_MINGW32 "Cross compile Win32 using mingw32" OFF)<br><br>was set ON for mingw32 cross compiling
<br>and OFF for Linux "native" compiling.<br><br>Then use your MY_TARGETLIB_xxx<br>in all other places:<br>SET_TARGET_PROPERTIES(ex1<br> PROPERTIES<br> PREFIX $(MY_TARGETLIB_PREFIX)<br> SUFFIX $(MY_TARGETLIB_SUFFIX)
<br> )<br><br>2006/11/16, Peter Visser <<a href="mailto:pervulgo@gmail.com">pervulgo@gmail.com</a>>:<br>> Hi,<br>><br>> I have a working build under win32 with MSYS/MINGW, now I would like to
<br>> cross-compile code for win32 with mingw from linux with by using the same<br>> CMakelists.txt files. It almost works, the problem is that the shared<br>> libraries are not named "myex.dll" but "
libmyex.so". By using the following<br>> command for all the libraries it can be solved:<br>><br>> SET_TARGET_PROPERTIES(ex1<br>><br>> PROPERTIES PREFIX ""<br>> SUFFIX
<br>> ".dll"<br>> )<br>><br>> However, now I have to change the CMakelist.txt in all the subdirectories<br>> and lose the ability to compile natively for linux (without adding an
<br>> IF(UNIX) around the SET_TARGET_PROPERTIES).<br>><br>> Is there a global option to set the PREFIX and SUFFIX, set the BUILD_TARGET<br>> to win32 or something alike?<br>><br>> I tried setting:<br>>
<br>> SET(UNIX FALSE)<br>> SET(MINGW TRUE)<br>> SET(WIN32 TRUE)<br>><br>> But that doesn't help.<br>><br>> Any help is appreciated,<br>><br>> Peter.<br>> _______________________________________________
<br>> CMake mailing list<br>> <a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>> <a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><br>><br>><br><br>
<br>--<br>Erk<br>_______________________________________________<br>CMake mailing list<br><a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br><a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake
</a><br></blockquote></div><br>