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



-- 

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

Reply via email to