How to convert qmake to cmake?

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

I have a .pro file on my project, but now I want to port it to a CMakeLists.txt file, how can I do this ?

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

回答1:

QMake: The required libraries.

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

CMake: only add is necessary.

find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED)

QMake: Additional Compiler flags:

CONFIG += c++11

CMake: Extend the list of compiler flags as required

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

QMake: The source files

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

CMake: Create a list of source files

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

QMake: The header to include:

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

CMake: Just show where the header files are

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

QMake: The target to built:

TARGET = test

CMake: Set the name of the target, add the sources, link the required libs.

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

See further details on Convert qmake to cmake



转载请标明出处:How to convert qmake to cmake?
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!