<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-text-html" lang="x-western"> Hi,<br>
<br>
I'm not able to find a good way to modify my cmake files to
consider CMP0026 policy introduced in cmake 3.0.0.<br>
<br>
I have a project that create a library libfoo and FooConfig.cmake
file that allows to use my library as a 3rd party.<br>
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.<br>
<br>
CMake Warning (dev) at CMakeLists.txt:8 (get_target_property):<br>
Policy CMP0026 is not set: Disallow use of the LOCATION target
property.<br>
CMake Warning (dev) at CMakeLists.txt:9 (get_target_property):<br>
Policy CMP0026 is not set: Disallow use of the LOCATION target
property.<br>
<br>
Here is a small example that reproduces the behavior. <br>
<br>
-- Begin CMakeLists.txt --<br>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">project</span>(test)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">cmake_minimum_required</span>(VERSION<span style=" color:#c0c0c0;"> </span>2.6)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">add_library</span>(foo<span style=" color:#c0c0c0;"> </span>foo.cpp)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">get_target_property</span>(FOO_LIBNAME_DBG<span style=" color:#c0c0c0;"> </span>foo<span style=" color:#c0c0c0;"> </span>LOCATION_Debug)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">get_target_property</span>(FOO_LIBNAME_OPT<span style=" color:#c0c0c0;"> </span>foo<span style=" color:#c0c0c0;"> </span>LOCATION_Release)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">get_filename_component</span>(FOO_LIBNAME_DBG<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#800000;">${FOO_LIBNAME_DBG}</span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span>NAME)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">get_filename_component</span>(FOO_LIBNAME_OPT<span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">"</span><span style=" color:#800000;">${FOO_LIBNAME_OPT}</span><span style=" color:#008000;">"</span><span style=" color:#c0c0c0;"> </span>NAME)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">configure_file</span>(FooConfig.cmake.in<span style=" color:#c0c0c0;"> </span>FooConfig.cmake)</pre>
-- End CMakeLists.txt --<br>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;"></span></pre>
<br>
-- Begin FooConfig.cmake.in --<br>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">set(FOO_SOURCE_DIR<span style=" color:#c0c0c0;"> </span>@CMAKE_SOURCE_DIR@)</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">set(FOO_LIBNAME_DBG<span style=" color:#c0c0c0;"> </span>"@FOO_LIBNAME_DBG@")</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">set(FOO_LIBNAME_OPT<span style=" color:#c0c0c0;"> </span>"@FOO_LIBNAME_OPT@")</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">set(FOO_LIBRARIES<span style=" color:#c0c0c0;"> </span>debug<span style=" color:#c0c0c0;"> </span>@CMAKE_INSTALL_PREFIX@/lib/${FOO_LIBNAME_DBG}<span style=" color:#c0c0c0;"> </span>optimized<span style=" color:#c0c0c0;"> </span>@CMAKE_INSTALL_PREFIX@/lib/${FOO_LIBNAME_OPT})</pre>
-- End FooConfig.cmake.in --<br>
<br>
Adding the following lines in my CMakeLists.txt seems not the best
way to ensure compat with future versions of CMake.
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;">
if(POLICY</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">CMP0026)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;"></span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">cmake_policy(SET</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">CMP0026</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">OLD)</span></pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#008000;">endif()
</span></pre>
<br>
I tried also to play with add_custom_command() using <br>
<pre>$<TARGET_PROPERTY:foo,LOCATION_Debug></pre>
But I cand find any command that set a variable<br>
<br>
Any idea ?<br>
<br>
Thanks<br>
Fabien<br>
<br>
<br>
<br>
</div>
</body>
</html>