CMake: Port the snippet project setup to CMake

Change-Id: I411e58e94752f3b2d0a3e8aac0ab7c4c2272db89
Fixes: QTBUG-89826
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Venugopal Shivashankar 2021-02-09 13:15:58 +01:00
parent 1549dff04c
commit 746393545f
20 changed files with 200 additions and 16 deletions

View File

@ -432,3 +432,8 @@ qt_internal_add_docs(Network
qt_internal_extend_target(Network CONDITION WIN32 PUBLIC_LIBRARIES ws2_32) # special case: mkspecs/common/msvc-desktop.conf
qt_internal_extend_target(Network CONDITION QNX PUBLIC_LIBRARIES socket) # special case: mkspecs/common/qcc-base-qnx.conf
# include the snippet projects for developer-builds
if(QT_FEATURE_private_tests)
add_subdirectory(doc/snippets/network)
endif()

View File

@ -0,0 +1,5 @@
add_library(network_cppsnippets OBJECT tcpwait.cpp)
target_link_libraries(network_cppsnippets PRIVATE
Qt::Network
)

View File

@ -48,13 +48,10 @@
**
****************************************************************************/
#include <QCoreApplication>
#include <QTcpSocket>
int main(int argv, char **args)
void test_tcpwait()
{
QCoreApplication app(argv, args);
QTcpSocket socket;
socket.connectToHost("localhost", 1025);
@ -72,6 +69,4 @@ int main(int argv, char **args)
break;
}
//! [0]
return app.exec();
}

View File

@ -55,3 +55,8 @@ qt_internal_add_docs(Sql
doc/qtsql.qdocconf
)
# include the snippet projects for developer-builds
if(QT_FEATURE_private_tests)
add_subdirectory(doc/snippets/code)
add_subdirectory(doc/snippets/sqldatabase)
endif()

View File

@ -0,0 +1,13 @@
add_library(code_snippets OBJECT
doc_src_sql-driver.cpp
src_sql_kernel_qsqldatabase.cpp
src_sql_kernel_qsqlerror.cpp
src_sql_kernel_qsqlresult.cpp
src_sql_kernel_qsqldriver.cpp
src_sql_models_qsqlquerymodel.cpp
)
target_link_libraries(code_snippets PRIVATE
Qt::Core
Qt::Sql
)

View File

@ -0,0 +1,8 @@
add_library(sqldatabase_snippets OBJECT
sqldatabase.cpp
)
target_link_libraries(sqldatabase_snippets PRIVATE
Qt::Core
Qt::Sql
)

View File

@ -133,3 +133,8 @@ qt_internal_add_docs(Test
# special case begin
qt_internal_apply_testlib_coverage_options(Test)
# special case end
# include the snippet projects for developer-builds
if(QT_FEATURE_private_tests)
add_subdirectory(doc/snippets/code)
endif()

View File

@ -0,0 +1,26 @@
add_library(testlib_code_snippets OBJECT
doc_src_qtqskip.cpp
doc_src_qttest.cpp
src_corelib_kernel_qtestsupport_core.cpp
)
target_link_libraries(testlib_code_snippets PRIVATE
Qt::Core
Qt::Test
)
qt_internal_extend_target(testlib_code_snippets CONDITION QT_FEATURE_gui AND QT_FEATURE_sql
SOURCES
doc_src_qtestlib.cpp
PUBLIC_LIBRARIES
Qt::Gui
Qt::Sql
)
qt_internal_extend_target(testlib_code_snippets CONDITION QT_FEATURE_widgets
SOURCES
doc_src_qtestevent.cpp
doc_src_qtestevent.h
PUBLIC_LIBRARIES
Qt::Widgets
)

View File

@ -51,13 +51,7 @@
#include <QTest>
#include <QLineEdit>
// dummy
class TestGui: public QObject
{
Q_OBJECT
public:
void testGui_data();
};
#include "doc_src_qtestevent.h"
void TestGui::testGui_data()
{

View File

@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QObject>
// dummy
class TestGui: public QObject
{
Q_OBJECT
public:
void testGui_data();
};

View File

@ -49,7 +49,7 @@
****************************************************************************/
#include <QTest>
#include <QSqlDatabase>
#include <QtGui/qfontdatabase.h>
#include <QFontDatabase>
#include <initializer_list>

View File

@ -824,3 +824,14 @@ qt_internal_add_docs(Widgets
doc/qtwidgets.qdocconf
)
# include the snippet projects for developer-builds
if(QT_FEATURE_private_tests)
add_subdirectory(doc/snippets/customviewstyle)
add_subdirectory(doc/snippets/filedialogurls)
add_subdirectory(doc/snippets/graphicssceneadditem)
if(QT_FEATURE_opengl AND QT_FEATURE_printsupport)
add_subdirectory(doc/snippets/graphicsview)
endif()
add_subdirectory(doc/snippets/mdiarea)
add_subdirectory(doc/snippets/myscrollarea)
endif()

View File

@ -52,7 +52,7 @@
#include "customstyle.h"
CustomStyle::CustomStyle()
CustomStyle::CustomStyle(const QWidget *widget)
{
//! [0]
const QSpinBox *spinBox = qobject_cast<const QSpinBox *>(widget);

View File

@ -59,7 +59,7 @@ class CustomStyle : public QProxyStyle
Q_OBJECT
public:
CustomStyle();
CustomStyle(const QWidget *widget);
~CustomStyle() {}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,

View File

@ -0,0 +1,11 @@
add_library(widgets_customviewstyle_snippets OBJECT
../customstyle/customstyle.h
../customstyle/customstyle.cpp
customviewstyle.cpp
)
target_link_libraries(widgets_customviewstyle_snippets PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
)

View File

@ -0,0 +1,9 @@
add_library(widgets_filedialogurl_snippets OBJECT
filedialogurls.cpp
)
target_link_libraries(widgets_filedialogurl_snippets PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
)

View File

@ -0,0 +1,9 @@
add_library(widgets_graphicssceneadditem_snippets OBJECT
graphicssceneadditemsnippet.cpp
)
target_link_libraries(widgets_graphicssceneadditem_snippets PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
)

View File

@ -0,0 +1,12 @@
add_library(widgets_graphicsview_snippets OBJECT
graphicsview.cpp
)
target_link_libraries(widgets_graphicsview_snippets PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
Qt::OpenGL
Qt::OpenGLWidgets
Qt::PrintSupport
)

View File

@ -0,0 +1,9 @@
add_library(widgets_mdiarea_snippets OBJECT
mdiareasnippets.cpp
)
target_link_libraries(widgets_mdiarea_snippets PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
)

View File

@ -0,0 +1,9 @@
add_library(widgets_myscrollarea_snippets OBJECT
myscrollarea.cpp
)
target_link_libraries(widgets_myscrollarea_snippets PRIVATE
Qt::Core
Qt::Gui
Qt::Widgets
)