Re: [CMake] error executing script with cmake -P

2019-10-17 Thread Tom Finegan via CMake
On Thu, Oct 17, 2019 at 2:14 AM Edoardo Pasca  wrote:

> Hi Tom,
>
> I thought ${testdata} was going to be filled in by the actual
> patch_script.cmake at this line.
>
> file (STRINGS TestData.py testdata NEWLINE_CONSUME)
>

Sorry, some nasty formatting in my email client had me misreading your
script. My advice is mainly based on this error:

  CMake Error at build/patch_script.cmake:3 (string):
string sub-command REPLACE requires at least four arguments

Looking at this line:
string(REPLACE \"sys.prefix\" \"os.environ[\\\'SIRF_INSTALL_PATH\\\']\"
patched \${testdata})

The most likely possible reason for that error being reported by CMake is
that ${testdata} is not defined when that line of script is executed. What
does line 3 of patch_script.cmake look like immediately after the error
message is output? My guess is that it looks something like this:

  string(REPLACE "sys.prefix" "os.environ[\'SIRF_INSTALL_PATH\']" patched )

As you'll notice REPLACE is only receiving 3 args in the above version.

Also note: I don't think you need to escape the single quotes in the
os.environ argument (unless they must be escaped in the final output).
Basic toy scripts here show it as unnecessary unless they must be escaped
in the patched file.


>
>  So it appears that this command doesn't quite work.
>
> I'll try also Alan's suggestion.
>
> Thanks
>
> Edo
>
> On Tue, Oct 15, 2019 at 7:00 PM Tom Finegan  wrote:
>
>> It looks like you aren't passing the $testdata variable down to the
>> script. From your message it looks like you need to add the following to
>> your PATCH_COMMAND:
>>
>> -Dtestdata=${testdata}
>>
>> You must explicitly pass $testdata (and any other variables defined in
>> the calling script) to patch_script.cmake via -D parameters on the command
>> line. Also note that the -Dvar=value args must precede the -P 

Re: [CMake] error executing script with cmake -P

2019-10-17 Thread Edoardo Pasca
Hi Tom,

I thought ${testdata} was going to be filled in by the actual
patch_script.cmake at this line.

file (STRINGS TestData.py testdata NEWLINE_CONSUME)

 So it appears that this command doesn't quite work.

I'll try also Alan's suggestion.

Thanks

Edo

On Tue, Oct 15, 2019 at 7:00 PM Tom Finegan  wrote:

> It looks like you aren't passing the $testdata variable down to the
> script. From your message it looks like you need to add the following to
> your PATCH_COMMAND:
>
> -Dtestdata=${testdata}
>
> You must explicitly pass $testdata (and any other variables defined in the
> calling script) to patch_script.cmake via -D parameters on the command
> line. Also note that the -Dvar=value args must precede the -P