Qplatformdefs.h with cmake

I am trying to compile my Qt program with cmake, but I have an arrangement when compiling qzip.cpp :

qzip.cpp: 57: 27: error fatal: qplatformdefs.h: There is no such file or directory

I added these lines to CMakeLists.txt, but this did not work:

IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED)

EXEC_PROGRAM ($ {QT_QMAKE_EXECUTABLE}

ARGS "-query QMAKE_MKSPECS" OUTPUT_VARIABLE qt_mkspecs_dirs ) 

# do not replace: on windows, as it may be a drive letter

# and windows should already use; as a delimiter

IF (UNIX)

 STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") 

ENDIF (UNIX)

SET (QT_MKSPECS_DIR NOTFOUND)

FIND_PATH (QT_MKSPECS_DIR qconfig.pri PATHS $ {qt_mkspecs_dirs}

 DOC "The location of the Qt mkspecs containing qconfig.pri" NO_DEFAULT_PATH ) 

ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED)

SET (QT_INCLUDES $ {QT_QT_INCLUDE_DIR} $ {QT_MKSPECS_DIR} / default $ {QT_INCLUDE_DIR})

So, how can I add a link to qplatformdefs.h in my CMakeLists.cpp?

Thank you very much.

PS: I'm on Ubuntu 12.04 32bits

+4
source share
2 answers

You can try adding this to your CMakeLists.txt:

include_directories(${QT_MKSPECS_DIR}/default)

+2
source

You may have already found the answer, but if you did not find it, here's what:

In my Fedora, this file is located in / usr / lib64 / qt4 / mkspecs / linux-g ++ - 64 . Assuming this is the same location in Ubuntu, you should add this directory to include_directories ();

 include_directories( lots_of_dirs "/usr/lib64/qt4/mkspecs/linux-g++-64/") 

Hope I helped.

+1
source

Source: https://habr.com/ru/post/1439764/


All Articles