[SOLVED] Qt SDK 1.1.3 and CMake on Mac OS X 10.7.1 / Lion
-
Hi, I have installed Qt SDK 1.1.3 on my Mac (running Mac OS X 10.7.1 / Lion) and rather than installing it under my home directory as suggested by the Qt SDK installer (why does it suggest that in fact?! -- I can't remember whether I installed it using sudo or not, so could it be the issue?), I installed the Qt SDK under /Developer/QtSDK.
Now, my project uses CMake (rather than QMake) and whenever I open my CMakeLists.txt file in Qt Creator 2.3.0 and then run CMake, I get told that Qt can't be found. Note that I have added /Developer/QtSDK/Desktop/Qt/474/gcc/bin to my PATH in my ~/.profile. Still, if in my CMakeLists.txt, I ask CMake to tell me about the contents of my PATH, then it tells me that it contains /usr/bin:/usr/sbin:/sbin, i.e. no /Developer/QtSDK at all. I therefore thought I would update /etc/profile, but to no avail. Same with adding /Developer/QtSDK to /etc/paths or under /etc/paths.d.
So... any idea how I could use Qt SDK 1.1.3 and CMake on Mac OS X 10.7.1 / Lion? Note that if I was to install Qt 4.7.4 and Qt Creator 2.3.0 individually (i.e. as individual packages as opposed to as part of Qt SDK 1.13), then everything works since, since qmake (among others) will be available under /usr/bin (if I recall correctly) which actually begs the question of why Qt SDK 1.1.3 doesn't do the same...?!
-
I think this is the new behavior... Qt SDK does not add its path to system environmental variable PATH. Neither does it put its libs in the system search path. All things are now in the SDK's own directory. Therefore, the libraries in the SDK only works with Qt Creator, unless you configure the environment manually.
If you want to use CMake with the official installer, you'll need to tell it where to find your Qt frameworks. It should be somewhere inside /Developer/QtSDK. Look for QtCore.framework, QtGui.framework and names like that. Include the directory that contains these framework into CMake's search path.
I found all these settings a bit annoying, so I use the Homebrew version of Qt now. :-p
-
My concern is that you are using Lion instead of Snow Leopard. Did you notice that this problem happens only when you updated your OS ?
-
@uranusjr: how do you setup that CMake's search path exactly? I thought I would do this through the call to FIND_PACKAGE(Qt4 ${QT_VERSION_REQUIRED} REQUIRED PATHS ${SOME_QT_PATHS}), but to no avail so far. Maybe I am missing something...?
@Alicemirror: I can't imagine this being the case. I mean, everything works fine if I install Qt and Qt Creator 'by hand' (i.e. without using Qt SDK).
-
Thank you for the information, but there is a meaningful difference to do all by hand or with the SDK Installer.
Take in account that not rarely I should work with more than one Qt version at the same moment, that developing with mobile devices is frequent theed of updates etc... This means that doing all by hand maybe a not indifferent time lost.
-
I'm not very familiar with CMake myself, but I think adding paths to CMAKE_MODULE_PATH might do the job...?
"This page":http://cmake.org/Wiki/CMake_Useful_Variables gives some usable CMake settings.
-
Ok, I have tried with CMAKE_MODULE_PATH, but that didn't work (from within Qt Creator, at least). However, by setting QT_QMAKE_EXECUTABLE to qmake's path, i.e.
SET(QT_QMAKE_EXECUTABLE /Developer/QtSDK/Desktop/Qt/474/gcc/bin/qmake)
then everything is fine. I just wish I didn't have to hard-code qmake's path in my CMake file and, instead, be able to do something like
EXECUTE_PROCESS(COMMAND which qmake OUTPUT_VARIABLE QT_QMAKE_EXECUTABLE)
but though this worked fine from the command line, it didn't from within Qt Creator...?! Oh well, at least, I now have a working solution...
-
FWIW, I have revisited this issue since I really didn't like having to hard set QT_QMAKE_EXECUTABLE. So, instead, I rely on the fact that I, personally at least, set Qt's path in /etc/profile:
@EXECUTE_PROCESS(
COMMAND sh -c ". /etc/profile && which qmake"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE QT_QMAKE_EXECUTABLE
)@