[Development] cmake for Qt
pengliang(彭亮)
pengliang at founder.com
Tue Mar 12 04:08:46 CET 2013
Hello
This is my first to compile qt project use cmake.
I written CmakeLists.txt:
PROJECT(test)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET(test_HEADERS widget.h comparefilethread.h)
SET(test_SOURCES main.cpp widget.cpp comparefilethread.cpp)
QT4_WRAP_CPP(test_HEADERS_MOC ${test_HEADERS})
ADD_EXECUTABLE(test ${test_HEADERS_MOC} ${test_SOURCES})
TARGET_LINK_LIBRARIES(test ${QT_LIBRARIES})
When I run Cmake
Maybe everything perfect. Makefile has been created.
------------ output ------------------
-- The C compiler identification is GNU 4.1.2
-- The CXX compiler identification is GNU 4.1.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
-- Found Qt4: /usr/local/Trolltech/Qt-4.7.1/bin/qmake (found version "4.7.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/incam/test/wps/build
-------------------------------------------------------------------
But when I run make, some errors occurred.
-------------------------- CmakeError.log ---------------------------
Determining if the Q_WS_WIN exist failed with the following output:
Change Dir: /home/incam/test/wps/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec1901404822/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1901404822.dir/build.make CMakeFiles/cmTryCompileExec1901404822.dir/build
gmake[1]: Entering directory `/home/incam/test/wps/build/CMakeFiles/CMakeTmp'
/usr/local/bin/cmake -E cmake_progress_report /home/incam/test/wps/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec1901404822.dir/CheckSymbolExists.cxx.o
/usr/bin/c++ -I/usr/local/Trolltech/Qt-4.7.1/include -o CMakeFiles/cmTryCompileExec1901404822.dir/CheckSymbolExists.cxx.o -c /home/incam/test/wps/build/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx
/home/incam/test/wps/build/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx: In function ‘int main(int, char**)’:
/home/incam/test/wps/build/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:8: 错误:‘Q_WS_WIN’ 在此作用域中尚未声明
gmake[1]: *** [CMakeFiles/cmTryCompileExec1901404822.dir/CheckSymbolExists.cxx.o] 错误 1
gmake[1]: Leaving directory `/home/incam/test/wps/build/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec1901404822/fast] 错误 2
File /home/incam/test/wps/build/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:
/* */
#include <QtCore/qglobal.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef Q_WS_WIN
return ((int*)(&Q_WS_WIN))[argc];
#else
(void)argc;
return 0;
#endif
}
……………
-----------------------------------------------------------------------------------
Could anybody tell me why?
Thanks
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130312/707e46a8/attachment.html>
More information about the Development
mailing list