[Development] cmake for Qt
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 ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] cmake for Qt
Hi, This should go to qt-interest mail list instead of qt-development. BTW, this error has nothing to do with CMAKE. and I couldn't understand what you are trying to do with following code. #ifndef Q_WS_WIN return ((int*)(Q_WS_WIN))[argc]; ... Regards, Debao On Tue, Mar 12, 2013 at 11:08 AM, pengliang(彭亮) pengli...@founder.comwrote: 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 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
[Development] cmake mingw qt
hello, my qt built by mingw, and now, i want to create makefile use cmake. so, i run : cmake -GMinGW Makefiles, and i get some error messages: CMake Error: Error: generator : MinGW Makefiles Does not match the generator used previously: Visual Studio 10 Either remove the CMakeCache.txt file or choose a different binary directory. anybody could tell me why? [CMakeLists.txt] PROJECT(test) CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(CMAKE_BUILD_TYPE RELEASE) ADD_DEFINITIONS(${QT_DEFINITIONS}) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) INCLUDE(${QT_USE_FILE}) SET(SOURCES main.cpp widget.cpp) SET(HEADERS widget.h) QT4_WRAP_CPP(HEADERS_MOC ${HEADERS}) ADD_EXECUTABLE(test ${SOURCES} ${HEADERS_MOC}) TARGET_LINK_LIBRARIES(test ${QT_LIBRARIES}) thanks ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development