[CMake] How to find a work arround with CMP0026 policy

Fabien Spindler Fabien.Spindler at inria.fr
Wed Jul 30 11:41:59 EDT 2014


Hi,

I'm not able to find a good way to modify my cmake files to consider 
CMP0026 policy introduced in cmake 3.0.0.

I have a project that create a library libfoo and FooConfig.cmake file 
that allows to use my library as a 3rd party.
In FooConfig.cmake updated during configuration time, I need to set 
FOO_LIBRARIES with the full path and name of the library in debug and 
release. To get the library names, I use the target location property. 
Since cmake 3.0.0 this seems a bad idea.

CMake Warning (dev) at CMakeLists.txt:8 (get_target_property):
   Policy CMP0026 is not set: Disallow use of the LOCATION target property.
CMake Warning (dev) at CMakeLists.txt:9 (get_target_property):
   Policy CMP0026 is not set: Disallow use of the LOCATION target property.

Here is a small example that reproduces the behavior.

-- Begin CMakeLists.txt --

project(test)

cmake_minimum_required(VERSION  2.6)

add_library(foo  foo.cpp)

get_target_property(FOO_LIBNAME_DBG  foo  LOCATION_Debug)

get_target_property(FOO_LIBNAME_OPT  foo  LOCATION_Release)

get_filename_component(FOO_LIBNAME_DBG  "${FOO_LIBNAME_DBG}"  NAME)

get_filename_component(FOO_LIBNAME_OPT  "${FOO_LIBNAME_OPT}"  NAME)

configure_file(FooConfig.cmake.in  FooConfig.cmake)

-- End CMakeLists.txt --


-- Begin FooConfig.cmake.in --

set(FOO_SOURCE_DIR  @CMAKE_SOURCE_DIR@)

set(FOO_LIBNAME_DBG  "@FOO_LIBNAME_DBG@")

set(FOO_LIBNAME_OPT  "@FOO_LIBNAME_OPT@")

set(FOO_LIBRARIES  debug  @CMAKE_INSTALL_PREFIX@/lib/${FOO_LIBNAME_DBG}  optimized  @CMAKE_INSTALL_PREFIX@/lib/${FOO_LIBNAME_OPT})

-- End FooConfig.cmake.in --

Adding the following lines in my CMakeLists.txt seems not the best way 
to ensure compat with future versions of CMake.


if(POLICY  CMP0026)

   cmake_policy(SET  CMP0026  OLD)

endif()


I tried also to play with add_custom_command() using

$<TARGET_PROPERTY:foo,LOCATION_Debug>

But I cand find any command that set a variable

Any idea ?

Thanks
Fabien



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140730/dff5a776/attachment.html>


More information about the CMake mailing list