2017-05-03 1 views
2

Ich habe eine .pro-Datei in meinem Projekt, aber jetzt möchte ich es in eine CMakeLists.txt-Datei portieren, wie kann ich das tun?Wie konvertiert man qmake zu cmake?

QT += core 
QT -= gui 
CONFIG += c++11 
TARGET = test 
CONFIG += console 
CONFIG -= app_bundle 
TEMPLATE = app 
QT += network 
SOURCES += main.cpp \ 
    test_interface.cpp \ 
    motomanlibrary.cpp \ 
    processing.cpp 
SOURCES += main.cpp \ 
    test_interface.h \ 
    motomanlibrary.h \ 
    processing.h 
+0

http://www.executionunit.com/blog/2014/01/22/moving-from-qmake-to-cmake/ – Antonio

+0

@Antonio, seltsam, dass Autor von Blogposts haben nicht den Weg gefunden, Qt Creator zusammen mit cmake zu verwenden –

Antwort

10

QMake: Die erforderlichen Bibliotheken.

QT += core 
QT -= gui 
QT += network 

CMake: nur hinzufügen ist notwendig.

find_package(Qt5Core REQUIRED) 
find_package(Qt5Network REQUIRED) 

QMake: Zusätzliche Compiler-Flags:

CONFIG += c++11 

CMake: Erweitern Sie die Liste der Compiler-Flags nach Bedarf

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") 

QMake: Die Quelldateien

SOURCES += main.cpp \ 
    test_interface.cpp \ 
    motomanlibrary.cpp \ 
    processing.cpp 

CMake : Erstellen Sie eine Liste von sauren ce Dateien

set(SOURCES 
    main.cpp 
    test_interface.cpp 
    motomanlibrary.cpp 
    processing.cpp 
) 

QMake: Der Header enthalten:

SOURCES += main.cpp \ 
    test_interface.h \ 
    motomanlibrary.h \ 
    processing.h 

CMake: Nur zeigen, wo die Header-Dateien sind

include_directory(.) # or include_directory(${CMAKE_CURRENT_SOURCE_DIR}) 

QMake: Das Ziel gebaut:

TARGET = test 

CMake: Legen Sie den Namen fest Fügen Sie die Quellen hinzu, verknüpfen Sie die erforderlichen Bibliotheken.

add_executable(test ${SOURCES}) 
qt5_use_modules(test Core Network) # This macro depends from Qt version 

# Should not be necessary 
#CONFIG += console 
#CONFIG -= app_bundle 
#TEMPLATE = app 

Sehen Sie weitere Details zu Convert qmake to cmake