[CMake] Resolving CMP0026 warnings
Knox, Kent
Kent.Knox at amd.com
Thu Feb 5 14:29:24 EST 2015
Hi all~
I have a question similar to one recently asked by NoRulez about CMP0026. I've been working on updating my legacy cmake code to compile without warnings with the 3.x series.
When I install my projects, I want to copy my 'non-system' target dependencies to help debug on non-development machines. A while back, I stumbled on the get_prerequisites( ) cmake function, which helps me enumerate target dependencies. http://www.cmake.org/cmake/help/v3.1/module/GetPrerequisites.html
My code is based on the solution posted by a Timothy M. Shead here:
http://www.cmake.org/pipermail/cmake/2009-June/029975.html
The problem is that get_prerequisites( ) needs a path to the target. How do I now get this path without calling the LOCATION property? I don't know where I can use a generator expression.
=====================================
CMakeLists.txt
====================================
get_target_property( libraryLocation myHumbleLibrary LOCATION )
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/copyLibraryDependencies.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/copyLibraryDependencies.cmake"
@ONLY
)
# Register script at run at install time to analyze the executable and copy dependencies into package
install( SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/copyLibraryDependencies.cmake" )
=====================================
copyLibraryDependencies.cmake.in
=====================================
# The Microsoft IDE presents a challenge because the full configuration is not known at cmake time
# This logic allows us to 'substitute' the proper configuration at install time
if( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "Debug" )
string( REPLACE "\$(Configuration)" "Debug" fixedLibraryLocation "@libraryLocation@" )
endif( )
...
# This retrieves a list of shared library dependencies from the target; they are not full path names
# Skip system dependencies and skip recursion
get_prerequisites( ${fixedLibraryLocation} libraryDependencies 1 0 "" "" )
# Loop on queried library dependencies and copy them into package
foreach( dep ${libraryDependencies} )
...
endforeach( )
Thanks for any help,
Kent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150205/73126ede/attachment-0001.html>
More information about the CMake
mailing list