[CMake] FindQt4 stubbornly finding Qt3

Zach Laine whatwasthataddress at gmail.com
Mon May 18 17:31:15 EDT 2009


I'm having a problem with FindQt*.  I have numerous versions of Qt4 installed:

usr/local/Trolltech/Qt-4.1.1
/usr/local/Trolltech/Qt-4.1.5
/usr/local/Trolltech/Qt-4.2.3
/usr/local/Trolltech/Qt-4.3.5
/usr/local/Trolltech/Qt-4.4.3
/usr/local/Trolltech/Qt-4.5.0-rc1

As well as the stock versions of Qt3 and Qt4 that came with my distro
in /usr/lib.

I've written a simple CMakeLists.txt for one of the Qt examples, based
on recommendations about a seemingly related problem in this thread:
http://www.cmake.org/pipermail/cmake/2009-March/027702.html

Here is the file:
=========================================================
cmake_minimum_required(VERSION 2.4)
set(CMAKE_VERBOSE_MAKEFILE "YES")

set(DESIRED_QT_VERSION 4)
set(QT_QT_LIBRARY "")
set(QT_QMAKE_EXECUTABLE /usr/local/Trolltech/Qt-4.3.5/bin/qmake)
find_package(Qt4)
include(${QT_USE_FILE})

message(${QT_LIBRARY_DIR}) # prints "/usr/lib"
message(${QT_INCLUDE_DIR}) # prints "/usr/lib/qt3/include"

qt_wrap_cpp(DUMMY_LIB_NAME MOC_FILES slidersgroup.h window.h)
add_executable(myexe main.cpp slidersgroup.cpp window.cpp ${MOC_FILES})
target_link_libraries(myexe ${QT_LIBRARIES})
=========================================================

The result of running "cmake CMakeLists.txt ; make" for CMake versions
2.6.4, 2.6.3, 2.6.2, 2.6.0, and 2.4.8 all produce the output in lines
(1) and (2).  CMake 2.4.8 additionally reports "-- Found Qt-Version
4.3.5"(!).

I've renamed the qmake that comes installed on my system, and changed
PATH and QTDIR env variables in an effort to get CMake to find the
right version of Qt.  Any idea how I can fix my CMakeLists.txt and/or
system to fix this problem?

Thanks in advance.

Zach Laine


More information about the CMake mailing list