CMake cannot resolve runtime directory path

After running cmake CMakeLists.txt

I get the following warning

CMake Warning at src/CMakeLists.txt:32 (add_executable): Cannot generate a safe runtime search path for target MMPEditor because files in some directories may conflict with libraries in implicit directories: runtime library [libQt5Widgets.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /home/ch/Qt/5.2.1/gcc_64/lib runtime library [libQt5Core.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /home/ch/Qt/5.2.1/gcc_64/lib runtime library [libQt5Gui.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /home/ch/Qt/5.2.1/gcc_64/lib runtime library [libQt5OpenGL.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /home/ch/Qt/5.2.1/gcc_64/lib 

Some of these libraries may not be found correctly.

What does it mean that one file must be hidden by another, and how can I allow CMake to determine which right folder to connect to?

+7
cmake
source share
2 answers

System libraries conflict with your local Qt libraries. This is a warning, but because of this, you may not expect the expected results in your application. You must tell CMake that it should exclude the system path when searching for libraries in your CMakeModule. From this documentation

If NO_DEFAULT_PATH is specified, then additional paths are not added to the search.

Also in the same documentation is mentioned another flag NO_CMAKE_SYSTEM_PATH , which includes only the default paths defined by default.

+3
source share

If you are dealing with find_library

find_library(LIBRARY_NAME PATHS "/usr/lib/x86_64-linux-gnu" NO_DEFAULT_PATH) where

  • PATHS denotes the exact path to libs
  • NO_DEFAULT_PATH means cmake will not search elsewhere

check lib values ​​and include paths with message(status, ${LIBRARY_NAME})


If you are dealing with find_package :

This is a little more complicated than the previous example, but it is essentially the same.

For each package, you need to run find_package for:

  • Create a file called Find<Packagename>.cmake , e. If you are looking for cppunit, you need to create FindCPPUNIT.cmake .
  • In this file, you will need to run find_path to include the include and find_library files in the lib files, for example, in the section "If you are dealing with find_library ".

    find_path (CPPUNIT_INCLUDE_DIR PATHS) / usr / include / x86_64-linux-gnu "NO_DEFAULT_PATH)
    find_library (CPPUNIT_LIBRARY PATHS) / usr / lib / x86_64-linux-gnu "NO_DEFAULT_PATH)

And then you should add the file path to CMAKE_MODULE_PATH.

0
source share

All Articles