[CMake] CMake & win32 rc files

Gabriele Greco gabriele.greco at darts.it
Tue May 3 11:04:37 EDT 2011


On Tue, May 3, 2011 at 4:15 PM, Tyler <tyler at cryptio.net> wrote:

> It doesn't work if you just include your icon file as one of the
> source files in the call to add_executable()/add_library()?
>
> What do you mean by "cross building"? Do you mean cross-compiling? If
> so, from what platform to win32?
>
>
I'm compiling from linux to windows using the mingw32 compiler (on
debian/ubuntu is packetized).

The tracker issue 0011773 is just about what you are saying, it's not enough
to add the rc file to add_executable() to tell cmake to call the resource
compiler.

After a few hours of unfruitful attempts I've solved with the following
workaround:

I've added the following line to my "toolchain-mingw32.cmake":

*SET(CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff
-I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>")*
*
*
I also added in my CMakeLists.txt the following block:

if (WIN32)
    ENABLE_LANGUAGE(RC)
    set(SOURCES icon.rc ${SOURCES})
endif()

End of the workaround.

Please note that I had to remove <FLAGS> and <DEFINES> cause I found no way
to avoid CXX defines to be mirrored also inside RC_FLAGS, here is a piece of
my (autogenerated) flags.cmake:

RC_FLAGS =   -I/home/gabry/projects/mlmonitor/common
-I/home/gabry/projects/mlmonitor/build_w32/inc
-I/usr/i586-mingw32msvc/include/gtk-2.0
-I/usr/i586-mingw32msvc/lib/gtk-2.0/include
-I/usr/i586-mingw32msvc/include/atk-1.0
-I/usr/i586-mingw32msvc/include/cairo
-I/usr/i586-mingw32msvc/include/pango-1.0
-I/usr/i586-mingw32msvc/include/glib-2.0
-I/usr/i586-mingw32msvc/lib/glib-2.0/include
-I/usr/i586-mingw32msvc/include/libpng12
-I/home/gabry/projects/mlmonitor/client/oogtk   -mms-bitfields

I had also to insert -O coff otherwise the linker failed the build that is
strange because launching from the shell:

i586-mingw32msvc-windres icon.rc icon.o

Already creates a coff object...

-- 
Bye,
 Gabry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110503/a1b4f9bd/attachment.htm>


More information about the CMake mailing list