[CMake] how to use the cmake functions get_prerequisites and get_filename_component for target dependency installation?

David Cole dlrdave at aol.com
Tue Jun 24 10:24:53 EDT 2014


Answered on stack overflow. Copied/pasted here for mailing list 
archives:

The references that get_prerequisites returns are not absolute full 
path references, and they are also not resolve-able to absolute 
references via a simple get_filename_component call. (On Mac, they may 
contain @executable_path, for instance.)

However, there is another function in the GetPrerequisites.cmake module 
called gp_resolve_item that can help you here.

Try this:

get_prerequisites(${MY_BINARY_LOCATION} DEPENDENCIES 0 0 "" "")

foreach(DEPENDENCY_FILE ${DEPENDENCIES})
   gp_resolve_item("${MY_BINARY_LOCATION}" "${DEPENDENCY_FILE}" "" "" 
resolved_file)
  message("resolved_file='${resolved_file}'")
endforeach()

That should convert DLL names into full path locations of the DLLs, 
assuming they are in your PATH. If they are in some other directories, 
you may need to provide those as the "dirs" arguments to 
get_prerequisites and gp_resolve_item.

The documentation for the GetPrerequisites.cmake module is here: 
http://www.cmake.org/cmake/help/v3.0/module/GetPrerequisites.html

Also, possibly dig into the BundleUtilities.cmake module to see how it 
uses GetPrerequisites.


HTH,
David C.



-----Original Message-----
From: Stefan Dänzer <stefan.daenzer at gmail.com>
To: cmake <cmake at cmake.org>
Sent: Tue, Jun 24, 2014 4:43 am
Subject: [CMake] how to use the cmake functions get_prerequisites and 
get_filename_component for target dependency installation?



Dear list members,

we have set up a cmake project with external shared library 
dependencies. We want to package the binaries and dependencies of our 
project using CPack. However we are getting different results on 
windows and linux systems when trying to find dependencies of our 
targets.

We had a look at the GetPrerequisites Module of CMake (2.8.12).We have 
successfully used the following CMake code to get the full path of a 
CMake target (BINARY) dependency (_libFile) on linux, however we don't 
get a the full path of the dependency on windows. On Windows the 
variable dependency_realpath holds something like 
${CMAKE_SOURCE_DIR}/DEPENDENCY_FILE, which is not the correct path to 
the dependency.

string(TOUPPER "${CMAKE_BUILD_TYPE}" CONFIG)
GET_TARGET_PROPERTY(MY_BINARY_LOCATION ${BINARY} LOCATION_${CONFIG} )
GET_PREREQUISITES(${MY_BINARY_LOCATION} DEPENDENCIES 0 0 "" "")

foreach( DEPENDENCY_FILE ${DEPENDENCIES})
    get_filename_component( dependency_realpath ${DEPENDENCY_FILE} 
REALPATH)

So the question would be: Why are we getting different results for the 
dependency locations on windows and linux?

Disclaimer: this is a clone question also asked 
on http://stackoverflow.com/questions/24367033/how-to-use-the-cmake-funct
ions-get-prerequisites-and-get-filename-component-for
Regards,
Stefan



--

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

  


More information about the CMake mailing list