file GET_RUNTIME_DEPENDENCIES - cannot access variables

Hello. I am checking out this new feature but it seems like I cannot print out the dependencies. The part of my cmake script is

install(CODE
        "file(GET_RUNTIME_DEPENDENCIES
                RESOLVED_DEPENDENCIES_VAR resolved_deps
                UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
                EXECUTABLES boost_timer_example just_a_thread
                )
        MESSAGE(\"Contents of variables: ${resolved_deps} ${unresolved_deps}\")"
)

Calling cmake .. && make install results in such log:

[100%] Built target boost_timer_example
Install the project...
-- Install configuration: ""
Contents of variables:

Variables are not printed out. I have noticed that just after calling cmake .. alone (without make), cmake_install.cmake is created with contents like that:

if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
  file(GET_RUNTIME_DEPENDENCIES
                RESOLVED_DEPENDENCIES_VAR resolved_deps
                UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
                EXECUTABLES boost_timer_example just_a_thread
                )
        MESSAGE("Contents of variables:  ")
endif()

Which clearly indicates the variables are substituted for nothing at configuration time.
What am I doing wrong?

Hi @tgq,

You need to escape the $ signs in the install command. Right now, the ${resolved_deps} and ${unresolved_deps} will be expanded at configure time, and hence be empty.

Florian

MESSAGE(\"Contents of variables: \${resolved_deps} \${unresolved_deps}\")
Works, thanks you :smiley:

The paths seem to be wrong tho. This is the output of RESOLVED_DEPENDENCIES_VAR:

Resolved deps just_a_thread: /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1;/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2;/lib/aarch64-linux-gnu/libc.so.6;/lib/aarch64-linux-gnu/libgcc_s.so.1;/lib/aarch64-linux-gnu/libm.so.6;/lib/aarch64-linux-gnu/libpthread.so.0;/lib/x86_64-linux-gnu/libstdc++.so.6

Calling ldd to find out dependencies:

tgq@qq:~/qqprojectboost/build$ ldd just_a_thread
        linux-vdso.so.1 (0x00007ffc371f6000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc282b5e000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc282985000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc28296b000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc2827ab000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc282b8c000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc282666000)

I have a crosscompiler installed (aarch64-linux-gnu) somewhere on the system but i never use it. Why did CMake fill the resolved deps with the crosscompiler’s libs? Isn’t that some bug? My arch is x86_64.

@kyle.edwards Seems we’re getting system paths from the wrong place somehow?

I found 15 minutes to reproduce the issue and ran it on ubuntu and debian machines. On ubuntu every crosscompiler pointed me to aarch64 directory, on debian to x86_64. In every case the paths should point to the one associated with the compiler.
Here’s the example I’m talking about:

I just tried it on Ubuntu 16.04 and was not able to reproduce - it got the correct paths. I’m going to try on 18.04 next.

Could not reproduce with 18.04 or the debian:latest Docker image. Please open an issue with a Dockerfile (or some other script) with the exact environment needed to reproduce this.