Igor Mironchik
Igor Mironchik

Reputation: 804

Why RPATH_CHECK in CMake deletes executable?

The following CMake's action will delete executable if RPATH is not the same.

file(RPATH_CHECK
    FILE "${CMAKE_CURRENT_SOURCE_DIR}/moc"
    RPATH "\$ORIGIN/../lib")

If RPATH will not be $ORIGIN/../lib then - ops, and no more executable.

Is it correct behavior of CMake, or it is a bug?

What RPATH_CHECK should do?

I caught this problem in Qt 6.2.1 on Linux. Qt builds successfully, but cmake --install . fails because CMake deletes executable in reason of RPATH_CHECK file's action with mismatched RPATH (declared and actual). Actual RPATH is :::::::::::::: at point of execution RPATH_CHECK.

I'm on Kubuntu 20.04. I installed sources of Qt with official Online Installer. To configure Qt I used:

./configure -nomake tests -nomake examples -skip qttest -skip qtwebengine -skip qtwebview -skip qtpositioning -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtnfc -skip qtcharts -skip qt3d -skip qtwayland -skip qtcoap -skip qtdatavis3d -skip qtlottie -skip qtmqtt -skip qtnetworkauth -skip qtopcua -skip qtquick3d -skip qtquicktimeline -skip qtremoteobjects -skip qtvirtualkeyboard -skip qtwebchannel -skip qtwebsockets -release -shared -skip qt5compat -skip qtdoc -skip qtscxml -skip qttranslations -skip qttools

Then

cmake --build . --parallel

CMake version 3.16.3

Upvotes: 1

Views: 314

Answers (1)

KamilCuk
KamilCuk

Reputation: 140880

Why RPATH_CHECK in CMake deletes executable?

Because that's what it does. (?)

Is it correct behavior of CMake, or it is a bug?

Correct.

What RPATH_CHECK should do?

Check if the file has desired RPATH, and if it doesn't, the file should be removed.

If you have any other concerns about RPATH features in CMake, I posted the source code in the last answer - all is there. Search for RPATH_CHECK in CMake source tree, and you'll find the find the function - from function names you can "guess" meaning and the algorithm used.

Upvotes: 1

Related Questions