[CMake] Cannot find source file: *.rc

Michael Hertling mhertling at online.de
Fri May 27 10:19:37 EDT 2011


On 05/27/2011 11:46 AM, Michael Wild wrote:
> On 05/26/2011 06:45 PM, Aaron_Wright at selinc.com wrote:
>>> From: Michael Wild <themiwi at gmail.com>
>>> To: cmake at cmake.org
>>> Date: 05/25/2011 10:08 PM
>>> Subject: Re: [CMake] Cannot find source file: *.rc
>>> Sent by: cmake-bounces at cmake.org
>>>
>>> On 05/25/2011 11:40 PM, Aaron_Wright at selinc.com wrote:
>>>> I use mc.exe to generate an *.rc file and some headers for my program.
>>>> The *.rc file is listed as an output of a custom command and as a source
>>>> to an executable. During configuration CMake tells me it can't find a
>>>> source file and lists the *.rc file. I've check the generated property
>>>> of the *.rc file and it is true, so why does CMake expect it to be
>>>> present during configuration?
>>>>
>>>> I've tried to make a small example, but when I try to do that everything
>>>> works. What I'm looking for is a reason why it would only effect large
>>>> build systems on not small build system, or why does this only effect
>>>> this *.rc and none of the other twenty or thirty files I generate? Is
>>>> there something special about *.rc files?
>>>>
>>>> I'm really just grabbing at straws here because I've been trying to fix
>>>> this for months, with no luck. So any ideas are welcome.
>>>>
>>>> ---
>>>> Aaron Wright
>>>
>>> Is the add_custom_command call generating the *.rc file in the same
>>> directory as your add_executable call?
>>>
>>> Michael
>>
>> It is neither in the same CMakeLists.txt nor is the *.rc file generated
>> anywhere close to the executable.
>>
>> I did work around this by writing a dummy file at configure time with
>> FILE(WRITE. Thought that seems a little hacky.
> 
> That is the problem. GENERATED source files only seem to work when used
> in the same directory.
> 
> Michael

This is even documented explicitly: In the CMake manual, search for "in
the same directory (CMakeLists.txt file)", and see FAQ 4.7. If a custom
command's output is to be referred to from another CMakeLists.txt file,
one must trigger it by a custom target, e.g. Moreover, note that source
properties like GENERATED are not only associated to source files, but
also restricted to directories, i.e. a source file marked as GENERATED
in one CMakeLists.txt won't bear this mark in another CMakeLists.txt.

Regards,

Michael


More information about the CMake mailing list