Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static linking (#24) #25

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-wasm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
id-token: write
with:
qtModules: 'qtwebsockets qtshadertools'
qtVersion: '6.6.0'
emsdkVersion: '3.1.37'
deploy_page: ${{ ((github.event.pull_request.merged == true) && (startsWith(github.base_ref, 'main'))) }}
release:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
204 changes: 102 additions & 102 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.24)

include(local_conf.cmake OPTIONAL)
include(${CMAKE_CURRENT_BINARY_DIR}/local_conf.cmake OPTIONAL)

option(USE_QtQr "add qrcode image providers" ON)
option(USE_OMClient "add open-meteo element" ON)
Expand All @@ -9,15 +9,15 @@ option(USE_IOTA "add IOTA object types [not mantained right now]" OFF)

include(FetchContent)
FetchContent_Declare(
ccommon
GIT_REPOSITORY https://github.com/EddyTheCo/Common.git
GIT_TAG main
)
ccommon
GIT_REPOSITORY https://github.com/EddyTheCo/Common.git
GIT_TAG main
)
FetchContent_MakeAvailable(ccommon)
version_from_git(
LOG OFF
TIMESTAMP "%Y%m%d%H%M%S"
)
LOG OFF
TIMESTAMP "%Y%m%d%H%M%S"
)
project(qmlonline VERSION ${VERSION} LANGUAGES CXX)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand All @@ -29,109 +29,109 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Qml )
qt_standard_project_setup()

qt6_add_executable(appqmlonline
main.cpp
)
main.cpp
)
if(USE_OMClient)
FetchContent_Declare(
OMQml
GIT_REPOSITORY https://github.com/EddyTheCo/OMClient.git
GIT_TAG main
FIND_PACKAGE_ARGS 0.0 CONFIG
)
FetchContent_MakeAvailable(OMQml)
list(APPEND qmlimport OMQml)
target_link_libraries(appqmlonline PRIVATE OMQml)
endif(USE_OMClient)
FetchContent_Declare(
OMQml
GIT_REPOSITORY https://github.com/EddyTheCo/OMClient.git
GIT_TAG v0.1.2
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(OMQml)
target_link_libraries(appqmlonline PRIVATE OMQml
$<$<STREQUAL:$<TARGET_PROPERTY:OMQml,TYPE>,STATIC_LIBRARY>:OMQmlplugin>)
endif(USE_OMClient)
if(USE_QtQr)
FetchContent_Declare(
qrCode
GIT_REPOSITORY https://github.com/EddyTheCo/qrCode.git
GIT_TAG v0.1.2
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(qrCode)
target_link_libraries(appqmlonline PRIVATE QtQrGen QtQrDec)

target_compile_definitions(appqmlonline PRIVATE USE_QtQr)
list(APPEND qmlimport QtQrGen QtQrDec)
FetchContent_Declare(
qrCode
GIT_REPOSITORY https://github.com/EddyTheCo/qrCode.git
GIT_TAG v0.4.1
FIND_PACKAGE_ARGS 0.4 CONFIG
)
FetchContent_MakeAvailable(qrCode)
target_link_libraries(appqmlonline PRIVATE QtQrGen QtQrDec
$<$<STREQUAL:$<TARGET_PROPERTY:QtQrGen,TYPE>,STATIC_LIBRARY>:QtQrGenplugin>
$<$<STREQUAL:$<TARGET_PROPERTY:QtQrDec,TYPE>,STATIC_LIBRARY>:QtQrDecplugin>
)
target_compile_definitions(appqmlonline PRIVATE USE_QtQr)
endif(USE_QtQr)
FetchContent_Declare(
MyDesigns
GIT_REPOSITORY https://github.com/EddyTheCo/MyDesigns.git
GIT_TAG v0.2.3
FIND_PACKAGE_ARGS 0.2 CONFIG
)
MyDesigns
GIT_REPOSITORY https://github.com/EddyTheCo/MyDesigns.git
GIT_TAG v0.4.1
FIND_PACKAGE_ARGS 0.4 CONFIG
)
FetchContent_MakeAvailable(MyDesigns)
list(APPEND qmlimport MyDesigns)
if(USE_IOTA)
FetchContent_Declare(
outMonitor
GIT_REPOSITORY https://github.com/EddyTheCo/outMonitor.git
GIT_TAG v0.1.5
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(outMonitor)
FetchContent_Declare(
outCreator
GIT_REPOSITORY https://github.com/EddyTheCo/outCreator.git
GIT_TAG v0.1.1
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(outCreator)
FetchContent_Declare(
outConsumer
GIT_REPOSITORY https://github.com/EddyTheCo/outConsumer.git
GIT_TAG v0.1.1
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(outConsumer)
FetchContent_Declare(
blockSender
GIT_REPOSITORY https://github.com/EddyTheCo/BlockSender.git
GIT_TAG v0.1.1
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(blockSender)
FetchContent_Declare(
account
GIT_REPOSITORY https://github.com/EddyTheCo/account.git
GIT_TAG v0.2.2
FIND_PACKAGE_ARGS 0.2 CONFIG
)
FetchContent_MakeAvailable(account)
FetchContent_Declare(
nodeConection
GIT_REPOSITORY https://github.com/EddyTheCo/ConectionSettings.git
GIT_TAG v0.2.3
FIND_PACKAGE_ARGS 0.2 CONFIG
)
FetchContent_MakeAvailable(nodeConection)
target_link_libraries(appqmlonline
PRIVATE outMonitor outCreator outConsumer blockSender account nodeConection )
list(APPEND qmlimport outMonitor outCreator outConsumer blockSender nodeConection account)
FetchContent_Declare(
outMonitor
GIT_REPOSITORY https://github.com/EddyTheCo/outMonitor.git
GIT_TAG v0.1.5
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(outMonitor)
FetchContent_Declare(
outCreator
GIT_REPOSITORY https://github.com/EddyTheCo/outCreator.git
GIT_TAG v0.1.1
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(outCreator)
FetchContent_Declare(
outConsumer
GIT_REPOSITORY https://github.com/EddyTheCo/outConsumer.git
GIT_TAG v0.1.1
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(outConsumer)
FetchContent_Declare(
blockSender
GIT_REPOSITORY https://github.com/EddyTheCo/BlockSender.git
GIT_TAG v0.1.1
FIND_PACKAGE_ARGS 0.1 CONFIG
)
FetchContent_MakeAvailable(blockSender)
FetchContent_Declare(
account
GIT_REPOSITORY https://github.com/EddyTheCo/account.git
GIT_TAG v0.2.2
FIND_PACKAGE_ARGS 0.2 CONFIG
)
FetchContent_MakeAvailable(account)
FetchContent_Declare(
nodeConection
GIT_REPOSITORY https://github.com/EddyTheCo/ConectionSettings.git
GIT_TAG v0.2.3
FIND_PACKAGE_ARGS 0.2 CONFIG
)
FetchContent_MakeAvailable(nodeConection)
target_link_libraries(appqmlonline
PRIVATE outMonitor outCreator outConsumer blockSender account nodeConection )
list(APPEND qmlimport outMonitor outCreator outConsumer blockSender nodeConection account)
endif(USE_IOTA)
target_link_libraries(appqmlonline
PRIVATE MyDesigns Qt::Core Qt::Gui Qt::Qml Qt::Quick)
target_link_libraries(appqmlonline PRIVATE MyDesigns Qt::Core Qt::Gui Qt::Qml Qt::Quick
$<$<STREQUAL:$<TARGET_PROPERTY:MyDesigns,TYPE>,STATIC_LIBRARY>:MyDesignsplugin>
)

qt6_add_qml_module(appqmlonline
URI qmlonline
VERSION 1.0
RESOURCE_PREFIX
"/esterVtech.com/imports"
QML_FILES
"main.qml"
SOURCES
"qmltextcode.cpp" "qmltextcode.h"
IMPORTS ${qmlimport}
IMPORT_PATH ${QML_IMPORT_PATH}
)
URI qmlonline
VERSION 1.0
RESOURCE_PREFIX
"/esterVtech.com/imports"
QML_FILES
"main.qml"
SOURCES
"qmltextcode.cpp" "qmltextcode.h"
IMPORT_PATH ${CMAKE_BINARY_DIR}
)
if(EMSCRIPTEN)
target_compile_definitions(appqmlonline PRIVATE USE_EMSCRIPTEN)
add_custom_command(
TARGET appqmlonline
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy "${CMAKE_CURRENT_BINARY_DIR}/appqmlonline.js" "${CMAKE_CURRENT_BINARY_DIR}/appqmlonline.wasm" "${CMAKE_CURRENT_BINARY_DIR}/qtloader.js" "${CMAKE_CURRENT_SOURCE_DIR}/wasm"
)
target_compile_definitions(appqmlonline PRIVATE USE_EMSCRIPTEN)
add_custom_command(
TARGET appqmlonline
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy "${CMAKE_CURRENT_BINARY_DIR}/appqmlonline.js" "${CMAKE_CURRENT_BINARY_DIR}/appqmlonline.wasm" "${CMAKE_CURRENT_BINARY_DIR}/qtloader.js" "${CMAKE_CURRENT_SOURCE_DIR}/wasm"
)
endif()

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This repo produce a Qt application that allows to run Qml code interactively.
The resulting application can access QML types defined in C++.
The purpose of this repo is to show online some C++/Qt/Qml projects.
For doing that the repo contains a wasm folder that produce a [web page](https://eddytheco.github.io/qmlonline/wasm/),
For doing that the repo contains a wasm folder that produce a [web page](https://eddytheco.github.io/qmlonline/),
integrating a JavaScript code editor to the compiled Qt application of this repo. The integration is made by compiling the Qt application to Webassembly.


Expand All @@ -17,7 +17,7 @@ Create build directory and build from there.
```
mkdir build
cd build
./Qt../wasm_32/bin/qt-cmake -DCMAKE_BUILD_TYPE=Release ../qmlonline/
./Qt../wasm_../bin/qt-cmake -DCMAKE_BUILD_TYPE=Release ../qmlonline/
cmake --build .
```

Expand Down
23 changes: 9 additions & 14 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#ifdef USE_QtQr
#include "Qrimageprovider.hpp"
#include"Qrimagedecoder.hpp"
#include "Qrimagedecoder.hpp"
#endif


Expand All @@ -14,23 +14,18 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.addImportPath("qrc:/esterVtech.com/imports");
engine.addImportPath("qrc:/esterVtech.com/imports");

#ifdef USE_QtQr
engine.addImageProvider(QLatin1String("qrCodedarkred"), new QRImageProvider("darkred",1));
engine.addImageProvider(QLatin1String("qrCodeBlue"), new QRImageProvider("blue",1));
engine.addImageProvider(QLatin1String("qrCodeBlack"), new QRImageProvider("black",1));
engine.addImageProvider(QLatin1String("qrCodemaroon"), new QRImageProvider("maroon",1));
engine.addImageProvider(QLatin1String("wasm"), new WasmImageProvider());
engine.addImageProvider(QLatin1String("qrCodedarkred"), new QRImageProvider("darkred",1));
engine.addImageProvider(QLatin1String("qrCodeBlue"), new QRImageProvider("blue",1));
engine.addImageProvider(QLatin1String("qrCodeBlack"), new QRImageProvider("black",1));
engine.addImageProvider(QLatin1String("qrCodemaroon"), new QRImageProvider("maroon",1));
engine.addImageProvider(QLatin1String("wasm"), new WasmImageProvider());
#endif
qDebug()<<engine.importPathList();
qmlRegisterSingletonType(QUrl(u"qrc:/esterVtech.com/imports/MyDesigns/qml/CustomStyle.qml"_qs), "CustomStyle", 1, 0, "CustomStyle");
qDebug()<<engine.importPathList();
qmlRegisterSingletonType(QUrl(u"qrc:/esterVtech.com/imports/MyDesigns/qml/CustomStyle.qml"_qs), "CustomStyle", 1, 0, "CustomStyle");
const QUrl url(u"qrc:/esterVtech.com/imports/qmlonline/main.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);

return app.exec();
Expand Down
10 changes: 7 additions & 3 deletions wasm/examples/omclient
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import QtQuick 2.0
/*
* Shows the use of a custom QML type that shows the wheatear conditions ant time..
* The library is found at https://github.com/EddyTheCo/OMClient
*
*/

import QtQuick 2.0
import OMQml

Item
Expand All @@ -8,8 +13,7 @@ Item

CurrentWeather
{
width:250
height:250
anchors.fill:parent
anchors.centerIn:parent
latitude:41.902916
longitude:12.453389
Expand Down
11 changes: 5 additions & 6 deletions wasm/examples/qt_qr_dec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Shows the use of a QRCODE decoder provider that produce QR Codes.
* Shows the use of a QRCODE decoder.
* The library is found on https://github.com/EddyTheCo/qrCode
*
*/
Expand All @@ -9,14 +9,13 @@ import QtQuick 2.0
import QtQrDec
Item {
anchors.fill:parent
QrTextArea
QrTextCamPop
{
id: butt
width: 350
closePolicy: Popup.NoAutoClose
width: 300
height:500
anchors.centerIn: Overlay.overlay
visible:true
closePolicy: Popup.NoAutoClose
anchors.centerIn: parent
}

}
Expand Down
4 changes: 2 additions & 2 deletions wasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.15.2/theme-chaos.js" integrity="sha512-BN2eayUXPBYNBybquX/ZkPQnIGrD5dRdcOpniptyLUodluoNwT9mySdFzJD64y0vrOxWF6paAk3t4j61LXWyAA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdn.korzh.com/metroui/v4.5.1/css/metro-all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
<script src="https://cdn.korzh.com/metroui/v4.5.1/js/metro.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="text/javascript" src="qtloader.js"></script>
<script type="text/javascript" src="js/initQTwasm.js"></script>
<script src="appqmlonline.js"></script>
<script type="text/javascript" src="qtloader.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
<link rel="stylesheet" href="style.css">
<title>QML Online</title>
Expand Down
Loading