[Cmake] Troubles figure out how to include .RES files for .NET

rob rmathews at envoyww.com
Sat Apr 26 16:11:03 EDT 2003


----- Original Message -----
From: "William A. Hoffman" <bill.hoffman at kitware.com>
To: "Robert Mathews" <rmathews at envoyww.com>
Cc: <cmake at public.kitware.com>
Sent: Saturday, April 26, 2003 11:05 AM
Subject: Re: [Cmake] Troubles figure out how to include .RES files for .NET


>
> 1. I saw the following, and I do not agree, all of our projects are using
> SET now, I think there is a misunderstanding on your part:
> ## We need some of the stuff that was depreciated, like the SOURCE_FILES
> command
> , because
> ## the SET command doesn't work as well.
>
> You should switch to SET..., and let us know what the problems are.
> The big difference is that SET variables must be dereferenced with ${VAR}
and
> SOURCE_FILES lists just used the name.

I mostly meant that the SOURCE_FILES command seemed more convenient than
using the SET command plus a SET_SOURCE_FILE_PROPERTIES command.

While we're on the topic of convenience, it would  be nice if the
SOURCE_FILES command took a wildcard. Sure, that can lead to accidently
including extra files, but for the vast majority of the libraries I have to
maintain, it would be a huge convenience.

>
>
> 2.   The problem with your custom command is that the target is incorrect.
> There is no target ALL.
>
>     ADD_CUSTOM_COMMAND(
>             SOURCE ${MC_FILE}
>             OUTPUTS ${RC_FILE}
>             COMMAND ${MESSAGE_COMPILER}
>             ARGS ${MC_FILE}
>             TARGET ALL
>     )
>
> A Target can be one of three things:
>   - Library from ADD_LIBRARY
>   - Executable from ADD_EXECUTABLE
>   - custom target from ADD_CUSTOM Target.
>
> In this case you want the TARGET of the custom command to be the
> library that contains the .rc file in its sources.
>
> So, it should be something like this:
>
> # tell cmake that foo.rc is a generated file
> SET_SOURCE_FILE_PROPERTIES(foo.rc GENERATED)
> ADD_LIBRARY(FOO foo.rc  foo.cxx)     # create a library with foo.rc and
> other sources
> # add a custom command to generate foo.rc from foo.m
> ADD_CUSTOM_COMMAND(
> SOURCE foo.mc   # the source is the .mc file
> OUTPUTS foo.rc    # the output file is the foo.rc file
> COMMAND ${MESSAGE_COMPILER} ARGS foo.mc
> DEPENDS foo.mc  # if foo.rm changes re-run the command
> TARGET FOO)  # associate this custom command with the library FOO
>

Thanks, that works correctly (with the caveat that you either need to use
the infamous SOURCE_FILES command instead of SET_SOURCE_FILE_PROPERTIES, or
that there must be a missing line in the example that somehow adds "foo.rc"
into the set of source files. I tried it with just
SET_SOURCE_FILE_PROPERTIES, and that doesn't work.)

Rob.







More information about the CMake mailing list