如何将qmake转换为cmake? [英] How to convert qmake to cmake?
问题描述
我的项目中有一个 .pro
文件,但是现在我想将其移植到 CMakeLists.txt
文件。我怎样才能做到这一点?
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
推荐答案
QMake:所需的库。
QMake: The required libraries.
QT += core
QT -= gui
QT += network
CMake:仅需添加。
CMake: only the add is necessary. An exclude (QT -= gui) is not required.
find_package(Qt5Core REQUIRED)
find_package(Qt5Network REQUIRED)
QMake:其他编译器标志:
QMake: Additional Compiler flags:
CONFIG += c++11
CMake:扩展列表所需的编译器标志集。
CMake: Extend the list of compiler flags as required.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
QMake:源文件
SOURCES += main.cpp \
test_interface.cpp \
motomanlibrary.cpp \
processing.cpp
CMake:创建源文件列表
CMake: Create a list of source files
set(SOURCES
main.cpp
test_interface.cpp
motomanlibrary.cpp
processing.cpp
)
QMake:要包含的标头:
QMake: The header to be included:
SOURCES += main.cpp \
test_interface.h \
motomanlibrary.h \
processing.h
CMake:只显示头文件在哪里。
CMake: Just show where the header files are.
include_directory(.) # or include_directory(${CMAKE_CURRENT_SOURCE_DIR})
include_directory(some/where/else)
QMake:要建立的目标:
QMake: The target to be built:
TARGET = test
CMake:设置目标名称,添加源,链接所需的库。
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 the Qt version
# Should not be necessary
#CONFIG += console
#CONFIG -= app_bundle
#TEMPLATE = app
这篇关于如何将qmake转换为cmake?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!