将Qt中的.pro行转换为cmake行

时间:2018-12-16 11:54:56

标签: qt cmake

我需要将Qt中的.pro文件的两行转换为CMake中的相应行:

CONFIG-= staticlib

CONFIG + =共享

我应该在cmakelist文件中写什么才能产生与此相同的效果?

.pro文件:

#-------------------------------------------------
#
# Project created by QtCreator 2017-10-10T11:50:45
#
#-------------------------------------------------

QT       += testlib network concurrent xml
QT       -= gui
QT += xmlpatterns

DEFINES += CID_SDK_LIBRARY
CONFIG -= staticlib
CONFIG += shared

CONFIG(debug,debug|release) {
  message(Compiled in Debug)
  debug:   DESTDIR = debug
} else {
  message( Compiled in Release )
  release: DESTDIR = release
}

OBJECTS_DIR = $$DESTDIR/.obj
MOC_DIR = $$DESTDIR/.moc
RCC_DIR = $$DESTDIR/.qrc

TARGET = lib/cid-sdk
TEMPLATE = lib
#CONFIG += staticlib c++11
CONFIG += sharedlib c++11

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

#TEMPLATE = subdirs
#SUBDIRS += \
#    tests\UnitTests    # an "app" project


#UnitTests.depends = Nl.Aet.Cid.Client.Sdk Nl.Aet.Cid.Client.Sdk.Core Nl.Aet.Cid.Sdk.Desktop.Gateway

include(Nl.Aet.Cid.Client.Deps\Nl.Aet.Cid.Client.Deps.pri)
include(Nl.Aet.Cid.Client.Sdk.Core\Nl.Aet.Cid.Client.Sdk.Core.pri)
include(Nl.Aet.Cid.Client.Sdk\Nl.Aet.Cid.Client.Sdk.pri)
#include(Nl.Aet.Cid.Enabler\Nl.Aet.Cid.Enabler.pri)

##Desktop API
include(Nl.Aet.Cid.Sdk.Desktop.Gateway\Nl.Aet.Cid.Sdk.Desktop.Gateway.pri)
include(Nl.Aet.Cid.Client.Sdk.Desktop\Nl.Aet.Cid.Client.Sdk.Desktop.pri)

#Web API
include(Nl.Aet.Cid.Sdk.Web.Gateway\Nl.Aet.Cid.Sdk.Web.Gateway.pri)
include(Nl.Aet.Cid.Client.Sdk.Web\Nl.Aet.Cid.Client.Sdk.Web.pri)

unix {
    target.path = /usr/lib
    INSTALLS += target
}

注意:我对其进行了编辑,以根据要求添加.pro文件。

谢谢。

1 个答案:

答案 0 :(得分:0)

在qmake中,每个.pro文件在您的项目结构中都会产生一个“模块”。该模块有一个产品。该产品可能是可执行文件/应用程序,静态库或动态/共享库。

另一方面,CMake不会隐式执行此操作。要添加一个模块,通常可以使用add_library函数。

要模仿这种特殊行为,您可以编写

project("my_library")
set(sources <your source files go here>)
add_library("my_library" STATIC ${sources})

project("my_library")
set(sources <your source files go here>)
add_library("my_library" SHARED ${sources})

现在,这里的问题是我们缺少sources的列表。就您而言,它们是在.pri文件中定义的。