在函数findQt4.cmake
中:
FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
NAMES QtCore QtCore4
HINTS ${QT_LIBRARY_DIR_TMP}
)
如果我打印:
MESSAGE("HINT PATH " ${QT_LIBRARY_DIR_TMP})
我会得到:
~/dev/Libraries/Qt4.8.0/lib
在此目录中有:~/dev/Libraries/Qt4.8.0/lib$ ls -all libQtCore*
我得到了:
-rw-r--r-- 1 abc abc 950 Nov 30 13:08 libQtCore.la
-rw-r--r-- 1 abc abc 942 Nov 30 13:07 libQtCore.prl
lrwxrwxrwx 1 abc abc 18 Nov 30 13:07 libQtCore.so -> libQtCore.so.4.8.0
lrwxrwxrwx 1 abc abc 18 Nov 30 13:08 libQtCore.so.4 -> libQtCore.so.4.8.0
lrwxrwxrwx 1 abc abc 18 Nov 30 13:08 libQtCore.so.4.8 -> libQtCore.so.4.8.0
-rwxr-xr-x 1 abc abc 2697932 Nov 30 13:08 libQtCore.so.4.8.0
但为什么FIND_LIBRARY
函数返回:QT_QTCORE_LIBRARY_RELEASE = NOT FOUND?
即便如此,如果我这样做也没有结果:
FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
NAMES libQtCore.so
HINTS ${QT_LIBRARY_DIR_TMP}
)
答案 0 :(得分:0)
您可以使用find_package()
代替find_library()
。这是Qt与CMake的common way。
# Find Qt package
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE}) # Add and run Qt CMake modules
add_definitions(${QT_DEFINITIONS}) # Add definitions (if required)
# And later put all together
add_executable( ... )
target_link_libraries( ... ${QT_LIBRARIES}) # Link Qt libraries