MantisBT - CMake | |||||
| View Issue Details | |||||
| ID | Project | Category | View Status | Date Submitted | Last Update |
| 0015963 | CMake | CMake | public | 2016-02-09 16:52 | 2016-06-10 14:21 |
| Reporter | Bruce Adams | ||||
| Assigned To | |||||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | no change required | ||
| Platform | Linux | OS | RedHat | OS Version | 5, 6 & 7 |
| Product Version | CMake 3.4.3 | ||||
| Target Version | Fixed in Version | ||||
| Summary | 0015963: strange behaviour running readlink via execute_process | ||||
| Description | I'm trying to use readlink -f to get the absolute path to a shared library following all symlinks. >readlink -f /opt/gcc4.9.3/lib64/libstdc++.so.6 /opt/gcc4.9.3/lib64/libstdc++.so.6.0.20 but when I do this in cmake it doesn't expand the full path E.g. set(CPP11_PATH ${CMAKE_CURRENT_BINARY_DIR}/) execute_process(COMMAND ldd ${CPP11_PATH} COMMAND grep libstdc++ COMMAND awk "{ print $3; }" OUTPUT_VARIABLE LIBSTDCPP_PATH) message("LIBSTDCPP_PATH=${LIBSTDCPP_PATH}") execute_process(COMMAND readlink -f ${LIBSTDCPP_PATH} OUTPUT_VARIABLE LIBSTDCPP_ABSPATH) message("LIBSTDCPP_ABSPATH=${LIBSTDCPP_ABSPATH}") prints: LIBSTDCPP_PATH=/opt/gcc4.9.3/lib64/libstdc++.so.6 LIBSTDCPP_ABSPATH=/opt/gcc4.9.3/lib64/libstdc++.so.6 This also happens if I wrap it in a shell script: execute_process(COMMAND doreadlink.sh ${LIBSTDCPP_PATH} OUTPUT_VARIABLE LIBSTDCPP_ABSPATH2) message("LIBSTDCPP_ABSPATH2=${LIBSTDCPP_ABSPATH2}") >LIBSTDCPP_ABSPATH2=/opt/gcc4.9.3/lib64/libstdc++.so.6 | ||||
| Steps To Reproduce | cmake_minimum_required(VERSION 2.8) project(TEST CXX) CMake script as below set(CPP11_PATH ${CMAKE_CURRENT_BINARY_DIR}/cpp11) execute_process(COMMAND g++ ${CMAKE_CURRENT_SOURCE_DIR}/cpp11.cpp -o${CPP11_PATH}) execute_process(COMMAND ldd ${CPP11_PATH} COMMAND grep libstdc++ COMMAND awk "{ print $3; }" OUTPUT_VARIABLE LIBSTDCPP_PATH) message("LIBSTDCPP_PATH=${LIBSTDCPP_PATH}") execute_process(COMMAND readlink -f ${LIBSTDCPP_PATH} OUTPUT_VARIABLE LIBSTDCPP_ABSPATH) message("LIBSTDCPP_ABSPATH=${LIBSTDCPP_ABSPATH}") | ||||
| Additional Information | The following is an effective work around execute_process(COMMAND ldd ${CPP11_PATH} COMMAND grep libstdc++ COMMAND awk "{ print $3; }" COMMAND xargs readlink -f OUTPUT_VARIABLE LIBSTDCPP_PATH) Originally raised on stackoverflow: http://stackoverflow.com/questions/35299970/strange-behaviour-with-readlink-under-cmake [^] | ||||
| Tags | No tags attached. | ||||
| Relationships | |||||
| Attached Files | |||||
| Issue History | |||||
| Date Modified | Username | Field | Change | ||
| 2016-02-09 16:52 | Bruce Adams | New Issue | |||
| 2016-02-09 16:56 | Bruce Adams | Note Added: 0040456 | |||
| 2016-02-09 17:52 | Bruce Adams | Note Added: 0040457 | |||
| 2016-02-10 08:55 | Brad King | Status | new => resolved | ||
| 2016-02-10 08:55 | Brad King | Resolution | open => no change required | ||
| 2016-06-10 14:21 | Kitware Robot | Note Added: 0041259 | |||
| 2016-06-10 14:21 | Kitware Robot | Status | resolved => closed | ||
| Notes | |||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||