[cmake-developers] [PATCH] FindCUDA: Wrap keyword in if() string comparison
Nils Gladitz
nilsgladitz at gmail.com
Fri Sep 19 02:31:19 EDT 2014
On 09/19/2014 07:30 AM, James Bigler wrote:
> Could someone please explain to me why we need to change all the if
> statements to look super ugly?
It sounds like you might have missed the follow up within this thread.
> Expanding "WIN32" to dereference the value is just a recipe for
> confusion. Honestly I would prefer if there was a policy to never
> deference variables in if statements and replace the if's with:
>
> if ("${arg}" STREQAL "WIN32")
To recap I did introduce a policy similar to this:
http://www.cmake.org/cmake/help/git-master/policy/CMP0054.html
This is paradoxically also the reason for the proposed "super ugly" changes.
The policy not only changes the behavior when set to NEW it also warns
about ambiguities like "WIN32" in an if statement while using the OLD
behavior.
Since the policy may or may not be active (depending on the user's
project) they might be using FindCUDA.cmake with CMP0054 set to NEW or
OLD. To get identical (and warning free) behavior irregardless of the
current policy setting Adam added the proposed ugliness.
Afterwards I proposed setting all policies to NEW for internal CMake
modules but Brad argues that since there is no proper coverage for find
modules within the test suite this might have unintended consequences.
As Brad further stated you could set CMP0054 to NEW explicitly within
FindCUDA.cmake (so that the ugliness could be avoided) if you can verify
that this does not break the module for existing projects.
Nils
More information about the cmake-developers
mailing list