Monday, 15 March 2010

how to use the cmake functions get_prerequisites and get_filename_component for target dependency installation? -



how to use the cmake functions get_prerequisites and get_filename_component for target dependency installation? -

we have set cmake project external shared library dependencies. want bundle binaries , dependencies of our project using cpack. getting different results on windows , linux systems when trying find dependencies of our targets.

we had @ getprerequisites module of cmake (2.8.12).we have used next cmake code total path of cmake target (binary) dependency (_libfile) on linux, don't total path of dependency on windows. on windows variable dependency_realpath holds ${cmake_source_dir}/dependency_file, not right path 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 question be: why getting different results dependency locations on windows , linux?

the references get_prerequisites returns not absolute total path references, , not resolve-able absolute references via simple get_filename_component call. (on mac, may contain @executable_path, instance.)

however, there function in getprerequisites.cmake module called gp_resolve_item can help 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 total path locations of dlls, assuming in path. if in other directories, may need provide "dirs" arguments get_prerequisites , gp_resolve_item.

the documentation getprerequisites.cmake module here: http://www.cmake.org/cmake/help/v3.0/module/getprerequisites.html

also, perchance dig bundleutilities.cmake module see how uses getprerequisites.

cmake

No comments:

Post a Comment