[cmake-developers] A CMAKE_EMULATOR variable

Matt McCormick matt.mccormick at kitware.com
Sun Mar 29 21:32:40 EDT 2015


Hi Brad,

On Thu, Mar 5, 2015 at 9:51 AM, Brad King <brad.king at kitware.com> wrote:
> On 03/04/2015 08:15 PM, Matt McCormick wrote:
>> On Wed, Mar 4, 2015 at 12:00 PM, Brad King wrote:
>>> I do not think a global setting like this makes sense.  We cannot
>>> unconditionally add the cross-compiling target launcher in front of
>>> all tests.  Some tests may be running host tools.  See below.
>>
>> This set of patches does not globally and unconditionally add a
>> launcher in front of all tests. It uses build system knowledge to add
>> the emulator commands in front of target executables only.
>
> Good, but it may take more work.  I see the key logic here:
>
>>    cmTarget* target = mf->FindTargetToUse(exe);
>>    if(target && target->GetType() == cmTarget::EXECUTABLE)
>>      {
>>      // Use the target file on disk.
>>      exe = target->GetFullPath(config);
>> +
>> +    // Prepend with the emulator when cross compiling if required.
>
> This if() condition is not sufficient to know that the executable
> is for the target architecture.  The cmTarget could be IMPORTED, in
> which case we don't know whether it references a host tool or one
> built for the target architecture.  Some kind of target property
> may be needed to say "use the emulator to run me" more explicitly.
> Once we have such a property, then it might as well refer to the
> tool to be used, e.g.
>
>   add_executable(myexe ...)
>   set_property(TARGET myexe PROPERTY CROSSCOMPILING_EMULATOR ${emulator})
>
>> The point about the overloaded meaning of "targets" is a good one.  I
>> think the best name is then CMAKE_CROSSCOMPILING_EMULATOR.
>
> Sounds good.  This variable could be used to initialize the above
> property on target creation (see SetPropertyDefault calls).  In
> try_run we simply need to pass the value into the inner project
> and its executable will pick it up too.

That sounds cool. I have implemented it in the emulator-property branch [1].

The variable name that defines the default for the
CROSSCOMPILING_EMULATOR property
is CMAKE_CROSSCOMPILING_EMULATOR.

Thanks,
Matt

[1] http://www.cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/emulator-property


More information about the cmake-developers mailing list