CMake build: Create shared lib for shared part of qmlpuppet

Which is used by external plugins.

Change-Id: I2d700c02ff3d4b2d692486bd64ef16449deffc4e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2020-09-30 18:38:14 +02:00
parent c3d461d494
commit 735078cd80
2 changed files with 87 additions and 52 deletions

View File

@@ -65,7 +65,7 @@ endfunction()
function(add_qtc_library name)
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS;UNVERSIONED"
"DESTINATION;COMPONENT"
"DESTINATION;COMPONENT;SOURCES_PREFIX"
"DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES" ${ARGN}
)
@@ -94,6 +94,20 @@ function(add_qtc_library name)
endif()
endif()
# TODO copied from extend_qtc_target.
# Instead require CMake 3.11 and use extend_qtc_target for setting SOURCES.
# Requiring cmake 3.11 is necessary because before that add_library requires
# at least one source file.
if (_arg_SOURCES_PREFIX)
foreach(source IN LISTS _arg_SOURCES)
list(APPEND prefixed_sources "${_arg_SOURCES_PREFIX}/${source}")
endforeach()
if (NOT IS_ABSOLUTE ${_arg_SOURCES_PREFIX})
set(_arg_SOURCES_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/${_arg_SOURCES_PREFIX}")
endif()
set(_arg_SOURCES ${prefixed_sources})
endif()
compare_sources_with_existing_disk_files(${name} "${_arg_SOURCES}")
set(library_type SHARED)
@@ -114,6 +128,11 @@ function(add_qtc_library name)
add_library(${IDE_CASED_ID}::${name} ALIAS ${name})
set_public_headers(${name} "${_arg_SOURCES}")
# TODO remove, see above
if (_arg_SOURCES_PREFIX)
target_include_directories(${name} PRIVATE $<BUILD_INTERFACE:${_arg_SOURCES_PREFIX}>)
endif()
if (${name} MATCHES "^[^0-9-]+$")
string(TOUPPER "${name}_LIBRARY" EXPORT_SYMBOL)
endif()
@@ -134,15 +153,18 @@ function(add_qtc_library name)
EXTRA_TRANSLATIONS ${_arg_EXTRA_TRANSLATIONS}
)
get_filename_component(public_build_interface_dir "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
file(RELATIVE_PATH include_dir_relative_path ${PROJECT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(${name}
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
PUBLIC
"$<BUILD_INTERFACE:${public_build_interface_dir}>"
"$<INSTALL_INTERFACE:include/${include_dir_relative_path}>"
)
# everything is different with SOURCES_PREFIX
if (NOT _arg_SOURCES_PREFIX)
get_filename_component(public_build_interface_dir "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
file(RELATIVE_PATH include_dir_relative_path ${PROJECT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(${name}
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
PUBLIC
"$<BUILD_INTERFACE:${public_build_interface_dir}>"
"$<INSTALL_INTERFACE:include/${include_dir_relative_path}>"
)
endif()
set(skip_translation OFF)
if (_arg_SKIP_TRANSLATION)

View File

@@ -5,19 +5,58 @@ if (APPLE)
string(APPEND DESTDIR "/qmldesigner")
endif()
add_qtc_executable(qml2puppet
add_qtc_library(qml2puppet_static
STATIC
DEPENDS
Qt5::CorePrivate Qt5::Widgets Qt5::QmlPrivate
Qt5::QuickPrivate Qt5::Network Qt5::GuiPrivate
Qt5::CorePrivate Qt5::Gui
PUBLIC_INCLUDES "${SRCDIR}/interfaces"
SOURCES_PREFIX "${SRCDIR}/interfaces"
SOURCES
"${SRCDIR}/qml2puppet/qml2puppetmain.cpp"
"${SRCDIR}/qmlpuppet.qrc"
DESTINATION ${DESTDIR}
commondefines.h
nodeinstanceclientinterface.h
nodeinstanceglobal.h
nodeinstanceserverinterface.cpp nodeinstanceserverinterface.h
)
extend_qtc_executable(qml2puppet
extend_qtc_library(qml2puppet_static
PUBLIC_INCLUDES "${SRCDIR}/types"
SOURCES "${SRCDIR}/types/enumeration.h"
)
extend_qtc_library(qml2puppet_static
PUBLIC_INCLUDES "${SRCDIR}/container"
SOURCES_PREFIX "${SRCDIR}/container"
SOURCES
addimportcontainer.cpp addimportcontainer.h
idcontainer.cpp idcontainer.h
imagecontainer.cpp imagecontainer.h
informationcontainer.cpp informationcontainer.h
instancecontainer.cpp instancecontainer.h
mockuptypecontainer.cpp mockuptypecontainer.h
propertyabstractcontainer.cpp propertyabstractcontainer.h
propertybindingcontainer.cpp propertybindingcontainer.h
propertyvaluecontainer.cpp propertyvaluecontainer.h
reparentcontainer.cpp reparentcontainer.h
sharedmemory.h
)
extend_qtc_library(qml2puppet_static
CONDITION UNIX
SOURCES_PREFIX "${SRCDIR}/container"
SOURCES
sharedmemory_unix.cpp
)
extend_qtc_library(qml2puppet_static
CONDITION NOT UNIX
SOURCES_PREFIX "${SRCDIR}/container"
SOURCES
sharedmemory_qt.cpp
)
extend_qtc_library(qml2puppet_static
PUBLIC_INCLUDES "${SRCDIR}/commands"
SOURCES_PREFIX "${SRCDIR}/commands"
INCLUDES "${PROJECT_SOURCE_DIR}/src/libs"
SOURCES
changeauxiliarycommand.cpp changeauxiliarycommand.h
changebindingscommand.cpp changebindingscommand.h
@@ -57,38 +96,21 @@ extend_qtc_executable(qml2puppet
scenecreatedcommand.h
)
extend_qtc_executable(qml2puppet
SOURCES_PREFIX "${SRCDIR}/container"
add_qtc_executable(qml2puppet
DEPENDS
Qt5::CorePrivate Qt5::Widgets Qt5::QmlPrivate
Qt5::QuickPrivate Qt5::Network Qt5::GuiPrivate
qml2puppet_static
SOURCES
addimportcontainer.cpp addimportcontainer.h
idcontainer.cpp idcontainer.h
imagecontainer.cpp imagecontainer.h
informationcontainer.cpp informationcontainer.h
instancecontainer.cpp instancecontainer.h
mockuptypecontainer.cpp mockuptypecontainer.h
propertyabstractcontainer.cpp propertyabstractcontainer.h
propertybindingcontainer.cpp propertybindingcontainer.h
propertyvaluecontainer.cpp propertyvaluecontainer.h
reparentcontainer.cpp reparentcontainer.h
sharedmemory.h
"${SRCDIR}/qml2puppet/qml2puppetmain.cpp"
"${SRCDIR}/qmlpuppet.qrc"
DESTINATION ${DESTDIR}
)
extend_qtc_executable(qml2puppet
CONDITION UNIX
SOURCES_PREFIX "${SRCDIR}/container"
SOURCES
sharedmemory_unix.cpp
)
extend_qtc_executable(qml2puppet
CONDITION UNIX AND (NOT APPLE)
DEPENDS rt
)
extend_qtc_executable(qml2puppet
CONDITION NOT UNIX
SOURCES_PREFIX "${SRCDIR}/container"
SOURCES
sharedmemory_qt.cpp
)
extend_qtc_executable(qml2puppet
SOURCES_PREFIX "${SRCDIR}/instances"
@@ -115,15 +137,6 @@ extend_qtc_executable(qml2puppet
icongizmoimageprovider.cpp icongizmoimageprovider.h
)
extend_qtc_executable(qml2puppet
SOURCES_PREFIX "${SRCDIR}/interfaces"
SOURCES
commondefines.h
nodeinstanceclientinterface.h
nodeinstanceglobal.h
nodeinstanceserverinterface.cpp nodeinstanceserverinterface.h
)
extend_qtc_executable(qml2puppet
SOURCES_PREFIX "${SRCDIR}/qml2puppet/iconrenderer"
SOURCES