[CMake] How to use CMAKE_POLICY?
Marcel Loose
marcel.loose at zonnet.nl
Wed Dec 19 08:52:38 EST 2012
Hi David,
I need to set a policy to OLD, because I have wrapped a few existing
Find*.cmake files to overcome some bugs or shortcomings. However, since
CMake 2.8.4 (or 2.8.3, I'm not sure), this triggers a policy warning
CMP0017 with newer versions of CMake, because some macros are now
included from my CMAKE_MODULE_PATH and some from CMAKE_CURRENT_LIST_DIR,
which expands to somewhere inside CMAKE_ROOT.
Best regards,
Marcel Loose.
Op 17-12-12 15:30, David Cole schreef:
> If you need to set a policy to OLD, then we have failed...
>
> Why do you need to set a policy to OLD?
>
> How can we make it work so that you don't need to do that?
>
>
>
>
> On Mon, Dec 17, 2012 at 3:58 AM, Marcel Loose <loose at astron.nl
> <mailto:loose at astron.nl>> wrote:
>
> Hi David,
>
> See my remarks inline.
>
>
> On 15/12/12 16:47, David Cole wrote:
>> On Sat, Dec 15, 2012 at 10:33 AM, Marcel Loose
>> <marcel.loose at zonnet.nl <mailto:marcel.loose at zonnet.nl>> wrote:
>>
>> Thanks, that seems to work.
>>
>> Is the idiom
>>
>> if(POLICY CMP<NNNN>)
>> cmake_policy(PUSH)
>> cmake_policy(SET CMP<NNNN> OLD)
>> cmake_policy(POP)
>> endif()
>>
>> one that you also need to use with newer CMakes? Or does it
>> then suffice to do
>>
>> cmake_policy(SET CMP<NNNN> OLD)
>>
>>
>> I assume you really mean:
>>
>> if(POLICY CMP<NNNN>)
>> cmake_policy(PUSH)
>> cmake_policy(SET CMP<NNNN> OLD)
>> endif()
>>
>> ...
>> other code where the policy is set to OLD
>> ...
>>
>> if(POLICY CMP<NNNN>)
>> cmake_policy(POP)
>> endif()
>>
> Yes, you're right. I was oversimplifying.
>>
>> The policies are tightly tied to the minimum required version of
>> CMake. So if you use cmake_minimum_required with a certain
>> version number, you can write code without if(POLICY assuming
>> that all the policies you need to set are known as of that
>> minimum version. If they are not (and they must not be in this
>> particular case), then you'll need the if(POLICY construct.
>>
> So, that basically means that you need to use if(POLICY...) for
> all policies that are not part of the minimum required version? Is
> there a way to find out which policies exist for which version of
> CMake?
>
> I was hoping for a more forward compatible solution. In other
> words, I was hoping that I could always use CMAKE_POLICY(SET...)
> unconditionally. It's a bit of a shame that I have to clutter my
> CMakeLists.txt and *.cmake files with these extra conditionals;
> and have to remove them (or should I say: clean up) whenever I
> bump the minimum required version.
>
> What's the reason that cmake doesn't silently ignore a
> CMAKE_POLICY(SET...) for a policy it doesn't know about?
>
>> The other option is to bump up your minimum required version.
> Sure, but that defeats the whole purpose of setting a minimum
> required version. I need to be compatible with version 2.6.2.
>
> Best regards,
> Marcel Loose.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121219/04661d61/attachment-0001.htm>
More information about the CMake
mailing list