Unsolved cmake not working with static compiled qt
-
I have a custom static compiled qt version installing to /opt/qt593.
And I found cmake generate wrong linking flags.
Here is my CMakeLists.txtcmake_minimum_required(VERSION 3.0.0) project(untitled2 VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(Qt5Core_DIR "/opt/qt593/lib/cmake/Qt5Core") find_package(Qt5Core) add_executable(${PROJECT_NAME} "main.cpp") target_link_libraries(${PROJECT_NAME} Qt5::Core)
And the final linking command is
/usr/bin/c++ CMakeFiles/untitled2.dir/main.cpp.o CMakeFiles/untitled2.dir/untitled2_automoc.cpp.o -o untitled2 -rdynamic /opt/qt593/lib/libQt5Core.a
There are a lot of undefined symbols. It seems that cmake forgets low level system libraries such as glib pthread,etc.
Any ideas?
If I switch to qmake, then all is OK.
-
grep pthread /opt/qt593/lib/pkgconfig/ -rn grep pthread /opt/qt593/lib/cmake/ -rn
And I found that there are lots of matches in pkgconfig, but nothing matches in cmake. So maybe this is a installation bug.