[PATCH] [CMake] Update required version to 2.8.12 to improve build time with target_link_libraries(INTERFACE)

NAKAMURA Takumi geek4civic at gmail.com
Tue Feb 25 05:59:52 PST 2014


Brad, thanks. It could be applied more easily.
I have a question:

- I am afraid the keyword INTERFACE &c. might require (CMP0022 NEW).
  Should I put cmake_policy() conditionally?
  cmake_policy(SET CMP0022 NEW) or (VERSION 2.8.12)


2014-02-24 22:31 GMT+09:00 Brad King <brad.king at kitware.com>:
> On 02/23/2014 08:14 PM, NAKAMURA Takumi wrote:
>>
>>   Argyrios, I'd be happy if this feature worked as optional.
>>
>>   Brad, any good idea?
>>   Could I twiddle cmake_minimum_required and cmake_policy explicitly there?
>
> You can leave
>
>  cmake_minimum_required(VERSION 2.8.8)
>
> alone and make the new keyword arguments conditional with variables:
>
>  if(NOT CMAKE_VERSION VERSION_LESS 2.8.12)
>    set(cmake_2_8_12_INTERFACE INTERFACE)
>    set(cmake_2_8_12_PRIVATE PRIVATE)
>  else()
>    set(cmake_2_8_12_INTERFACE)
>    set(cmake_2_8_12_PRIVATE)
>  endif()
>
> Then use them like this:
>
>  target_link_libraries(${name} ${cmake_2_8_12_INTERFACE} ${ARG_LINK_LIBS})
>
> On older versions the call will turn into
>
>  target_link_libraries(${name} ${ARG_LINK_LIBS})
>
> and on 2.8.12 and above it will become
>
>  target_link_libraries(${name} INTERFACE ${ARG_LINK_LIBS})
>
> The "cmake_2_8_12_" prefix is just to call attention to the code
> to remember to simplify it when 2.8.12 or later becomes required.
> Any variable names could be used, of course.
>
> -Brad
>



More information about the cfe-commits mailing list