Re: [cmake-developers] FindGTest.cmake and CMP0064

2015-11-18 Thread David Chen


> Date: Wed, 18 Nov 2015 10:44:24 -0500
> From: Brad King 
> To: cmake-developers@cmake.org
> Subject: Re: [cmake-developers] FindGTest.cmake and CMP0064
> Message-ID: <564c9cd8.9090...@kitware.com>
> Content-Type: text/plain; charset=utf-8
> 
> On 11/17/2015 11:37 AM, Rolf Eike Beer wrote:
>> Am 17.11.2015 17:08, schrieb David Chen:
>>> We?ve been getting a warning from FindGTest.cmake about CMP0064 when
>>> building SimpleITK.  The warning occurs at lines 127, 129 and 131 when
>>> the variable ${test_type} is equal to ?TEST?.  With CMP0064 this TEST
>>> could be interpreted as commands in the if() and elseif() statements
>>> unless the policy is set to OLD.
> 
> With CMP0054 and CMP0064 both set to NEW then the original code
> would work as expected.  However, CMake's modules must tolerate
> many policy (non-)setting combinations.
> 
>> The correct fix would probably to just remove the dereference, i.e. 
>> change
>> 
>>   if(${test_type} STREQUAL "TEST_P")
>> 
>> to
>> 
>>   if(test_type STREQUAL "TEST_P")
> 
> The code
> 
>  if(test_type STREQUAL "TEST")
> 
> could still trigger CMP0064 warnings.  We can use the style
> 
>  if("x${test_type}" STREQUAL "xTEST_P")
> 
> to avoid both CMP0054 and CMP0064.  Done here:
> 
> FindGTest: Refactor test type checks to avoid cases triggering CMP0064
> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5e7b22d
> 
> David, please verify that this approach still works for your case.

Your patch works fine for me.

Thanks,
Dave


David T. Chen, PhD  [MSC contractor]
mailto:dc...@mail.nih.gov <mailto:dc...@mail.nih.gov>   
http://lhncbc.nlm.nih.gov/personnel/david-chen 
<http://lhncbc.nlm.nih.gov/personnel/david-chen>
phone:301.435.3264   iphone:301.524.3174 

Office of High Performance Computing and Communications
National Library of Medicine


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] FindGTest.cmake and CMP0064

2015-11-18 Thread Brad King
On 11/18/2015 11:26 AM, Ben Boeckel wrote:
>>   if(test_type STREQUAL "TEST")
> 
> is it triggering on the right-hand "TEST" argument?

Yes.

> That's not ambiguous to me; is the if() argument parser misdetecting it?

With CMP0054 and CMP0064 set to NEW then

 set(var TEST)
 if(var STREQUAL TEST)

works as expected.  With CMP0054 set to NEW and CMP0064 not set it
warns.  I do not think it should warn, but looking at the code it
would take major refactoring to be able to avoid the false positive.
Either way projects should just set CMP0064 to NEW.

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] FindGTest.cmake and CMP0064

2015-11-18 Thread Ben Boeckel
On Wed, Nov 18, 2015 at 10:44:24 -0500, Brad King wrote:
> The code
> 
>   if(test_type STREQUAL "TEST")
> 
> could still trigger CMP0064 warnings.  We can use the style

How would this trigger the warning? Do we look for keywords *after*
variable expansion? Or is it triggering on the right-hand "TEST"
argument? That's not ambiguous to me; is the if() argument parser
misdetecting it?

--Ben
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] FindGTest.cmake and CMP0064

2015-11-18 Thread Brad King
On 11/17/2015 11:37 AM, Rolf Eike Beer wrote:
> Am 17.11.2015 17:08, schrieb David Chen:
>> We’ve been getting a warning from FindGTest.cmake about CMP0064 when
>> building SimpleITK.  The warning occurs at lines 127, 129 and 131 when
>> the variable ${test_type} is equal to “TEST”.  With CMP0064 this TEST
>> could be interpreted as commands in the if() and elseif() statements
>> unless the policy is set to OLD.

With CMP0054 and CMP0064 both set to NEW then the original code
would work as expected.  However, CMake's modules must tolerate
many policy (non-)setting combinations.

> The correct fix would probably to just remove the dereference, i.e. 
> change
> 
>if(${test_type} STREQUAL "TEST_P")
> 
> to
> 
>if(test_type STREQUAL "TEST_P")

The code

  if(test_type STREQUAL "TEST")

could still trigger CMP0064 warnings.  We can use the style

  if("x${test_type}" STREQUAL "xTEST_P")

to avoid both CMP0054 and CMP0064.  Done here:

 FindGTest: Refactor test type checks to avoid cases triggering CMP0064
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5e7b22d

David, please verify that this approach still works for your case.

I've queued this for merge to 'release' for 3.4.1.

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] FindGTest.cmake and CMP0064

2015-11-17 Thread Rolf Eike Beer

Am 17.11.2015 17:08, schrieb David Chen:

We’ve been getting a warning from FindGTest.cmake about CMP0064 when
building SimpleITK.  The warning occurs at lines 127, 129 and 131 when
the variable ${test_type} is equal to “TEST”.  With CMP0064 this TEST
could be interpreted as commands in the if() and elseif() statements
unless the policy is set to OLD.

I’ve attached a patch for your consideration that re-writes those
statements.  I have changed the STREQUAL comparisons to regex MATCHES
comparisons.  This change removes the possibility of “TEST” being the
first word inside the parentheses.


The correct fix would probably to just remove the dereference, i.e. 
change


  if(${test_type} STREQUAL "TEST_P")

to

  if(test_type STREQUAL "TEST_P")

Greetings,

Eike
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

[cmake-developers] FindGTest.cmake and CMP0064

2015-11-17 Thread David Chen
We’ve been getting a warning from FindGTest.cmake about CMP0064 when building SimpleITK.  The warning occurs at lines 127, 129 and 131 when the variable ${test_type} is equal to “TEST”.  With CMP0064 this TEST could be interpreted as commands in the if() and elseif() statements unless the policy is set to OLD.I’ve attached a patch for your consideration that re-writes those statements.  I have changed the STREQUAL comparisons to regex MATCHES comparisons.  This change removes the possibility of “TEST” being the first word inside the parentheses.

0001-Refactored-if-statements-for-TEST.patch
Description: Binary data

David T. Chen, PhD                      [MSC contractor]mailto:dc...@mail.nih.gov               http://lhncbc.nlm.nih.gov/personnel/david-chenphone:301.435.3264                      iphone:301.524.3174Office of High Performance Computing and CommunicationsNational Library of Medicine

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers