Prepare build system for OpenVR and QtQuick (QML)

pull/45/head
dsc 3 years ago
parent 5f746999c2
commit e918955210

@ -11,6 +11,8 @@ set(VERSION "beta-1")
option(FETCH_DEPS "Download dependencies if they are not found" ON)
option(XMRIG "Include XMRig module" ON)
option(OPENVR "Include OpenVR support" OFF)
option(QML "Include QtQuick (QML)" OFF)
option(TOR_BIN "Path to Tor binary to embed inside WOWlet" OFF)
option(STATIC "Link libraries statically, requires static Qt")
option(USE_DEVICE_TREZOR "Trezor support compilation" OFF)
@ -24,16 +26,26 @@ include(FindCcache)
include(CheckIncludeFile)
include(CheckSymbolExists)
if(DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
set(WOWNERO_HEAD "f611d5c9e32bc62f1735f6571b0bdb95cc020531")
set(BUILD_GUI_DEPS ON)
set(ARCH "x86-64")
set(BUILD_64 ON)
set(INSTALL_VENDORED_LIBUNBOUND ${STATIC})
set(USE_SINGLE_BUILDDIR ON)
if(OPENVR)
set(QML ON)
endif()
# Are we in debug mode?
set(_CMAKE_BUILD_TYPE "")
string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
if("${_CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
set(DEBUG ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
message(STATUS "OPENVR: ${OPENVR}")
message(STATUS "QML: ${QML}")
endif()
check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL)
@ -87,7 +99,7 @@ if(GIT_FOUND)
if(NOT _WOWNERO_HEAD STREQUAL WOWNERO_HEAD)
message(FATAL_ERROR "[submodule] Monero HEAD was at ${_WOWNERO_HEAD} but should be at ${WOWNERO_HEAD}")
else()
message(STATUS "[submodule] Monero HEAD @ ${WOWNERO_HEAD}")
message(STATUS "[submodule] Wownero HEAD @ ${WOWNERO_HEAD}")
endif()
endif()
@ -365,4 +377,12 @@ if(APPLE)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/contrib/KDMacTouchBar")
endif()
if(OPENVR)
# Add contrib/openvr as library
add_definitions(-DVR_API_PUBLIC)
add_definitions(-DOPENVR_BUILD_STATIC) # is this needed?
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/contrib/openvr")
message(STATUS "yeepp")
endif()
add_subdirectory(src)

@ -30,6 +30,8 @@ CMAKEFLAGS = \
-DARCH=x86_64 \
-DBUILD_64=On \
-DBUILD_TESTS=Off \
-DOPENVR=Off \
-DQML=Off \
-DXMRIG=Off \
-DTOR_BIN=Off \
-DCMAKE_CXX_STANDARD=11 \
@ -50,10 +52,11 @@ release-static:
depends:
mkdir -p build/$(target)/release
cd build/$(target)/release && cmake -D STATIC=ON -DREPRODUCIBLE=$(or ${SOURCE_DATE_EPOCH},OFF) -DTOR_VERSION=$(or ${TOR_VERSION}, OFF) -DTOR_BIN=$(or ${TOR_BIN},OFF) -D DEV_MODE=$(or ${DEV_MODE},OFF) -D BUILD_TAG=$(tag) -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=$(root)/$(target)/share/toolchain.cmake ../../.. && $(MAKE)
cd build/$(target)/release && cmake -D STATIC=ON -DREPRODUCIBLE=$(or ${SOURCE_DATE_EPOCH},OFF) -DTOR_VERSION=$(or ${TOR_VERSION}, OFF) -DOPENVR=ON -DQML=ON -DTOR_BIN=$(or ${TOR_BIN},OFF) -D DEV_MODE=$(or ${DEV_MODE},OFF) -D BUILD_TAG=$(tag) -D CMAKE_BUILD_TYPE=Debug -D CMAKE_TOOLCHAIN_FILE=$(root)/$(target)/share/toolchain.cmake ../../.. && $(MAKE)
windows-mxe-release: CMAKEFLAGS += -DBUILD_TAG="win-x64"
windows-mxe-release: CMAKEFLAGS += -DTOR_BIN=$(or ${TOR_BIN},OFF)
windows-mxe-debug: CMAKEFLAGS += -DOPENVR=On
windows-mxe-release: CMAKEFLAGS += -DCMAKE_BUILD_TYPE=Release
windows-mxe-release:
cmake -Bbuild $(CMAKEFLAGS)
@ -61,6 +64,7 @@ windows-mxe-release:
windows-mxe-debug: CMAKEFLAGS += -DBUILD_TAG="win-x64"
windows-mxe-debug: CMAKEFLAGS += -DTOR_BIN=$(or ${TOR_BIN},OFF)
windows-mxe-debug: CMAKEFLAGS += -DOPENVR=On
windows-mxe-debug: CMAKEFLAGS += -DCMAKE_BUILD_TYPE=Debug
windows-mxe-debug:
cmake -Bbuild $(CMAKEFLAGS)

@ -5,16 +5,7 @@ set(CMAKE_AUTOUIC ON)
# pthread
find_package(Threads REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Network Svg Xml WebSockets)
add_subdirectory(libwalletqt)
add_subdirectory(model)
add_subdirectory(utils)
add_subdirectory(openpgp)
qt5_add_resources(RESOURCES assets.qrc)
# Compile source files (.h/.cpp)
# Compile these source files (.h/.cpp)
file(GLOB SOURCE_FILES
"*.h"
"*.cpp"
@ -42,6 +33,35 @@ file(GLOB SOURCE_FILES
"dialog/*.cpp"
)
if(QML)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Network Svg Xml WebSockets Quick Qml QuickControls2 QmlImportScanner)
else()
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Network Svg Xml WebSockets)
endif()
if(OPENVR)
# include some extra files
qt5_add_resources(RESOURCES vr/qml.qrc)
file(GLOB SOURCE_FILES_QML
"vr/*.h"
"vr/*.cpp"
"vr/utils/*.h"
"vr/utils/*.cpp"
)
list(APPEND SOURCE_FILES ${SOURCE_FILES_QML})
if(MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-deprecated-declarations") # @TODO: removeme
endif()
endif()
add_subdirectory(libwalletqt)
add_subdirectory(model)
add_subdirectory(utils)
add_subdirectory(openpgp)
qt5_add_resources(RESOURCES assets.qrc)
if(TOR_BIN)
if(APPLE)
set(ASSETS_TOR "assets_tor_macos.qrc")
@ -118,6 +138,10 @@ target_include_directories(wowlet PUBLIC
${Qt5WebSockets_INCLUDE_DIRS}
)
if(OPENVR)
target_include_directories(wowlet PUBLIC ${CMAKE_SOURCE_DIR}/contrib/)
endif()
if(DONATE_BEG)
target_compile_definitions(wowlet PRIVATE DONATE_BEG=1)
endif()
@ -130,6 +154,11 @@ if(XMRIG)
target_compile_definitions(wowlet PRIVATE HAS_XMRIG=1)
endif()
if(OPENVR)
target_compile_definitions(wowlet PRIVATE HAS_OPENVR=1)
target_compile_definitions(wowlet PUBLIC VR_API_PUBLIC)
endif()
if(HAVE_SYS_PRCTL_H)
target_compile_definitions(wowlet PRIVATE HAVE_SYS_PRCTL_H=1)
endif()
@ -150,6 +179,17 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(wowlet PRIVATE QT_NO_DEBUG=1)
endif()
add_definitions(${QT_DEFINITIONS})
if(NOT "${CMAKE_BUILD_TYPE}" EQUAL "Debug")
add_definitions(-DQT_NO_DEBUG)
endif()
target_compile_definitions(wowlet PUBLIC VR_API_PUBLIC)
if(QML)
qt5_import_qml_plugins(${PROJECT_NAME})
endif()
target_compile_definitions(wowlet
PUBLIC
${Qt5Core_DEFINITIONS}
@ -166,12 +206,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
if(UNIX AND NOT APPLE)
# https://stackoverflow.com/questions/57766620/cmake-add-library-doesnt-initialize-static-global-variable
# so that contrib/monero-seed/src/gf_elem.cpp properly initializes. A better solution is welcome.
target_link_libraries(wowlet -Wl,--whole-archive monero-seed::monero-seed -Wl,--no-whole-archive)
target_link_libraries(wowlet PUBLIC -Wl,--whole-archive monero-seed::monero-seed -Wl,--no-whole-archive)
else()
target_link_libraries(wowlet monero-seed::monero-seed)
target_link_libraries(wowlet PUBLIC monero-seed::monero-seed)
endif()
target_link_libraries(wowlet
# Link Wownero core libraries
target_link_libraries(wowlet PUBLIC
wallet_merged
${LMDB_LIBRARY}
epee
@ -183,19 +224,51 @@ target_link_libraries(wowlet
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${CMAKE_DL_LIBS}
${EXTRA_LIBRARIES}
${EXTRA_LIBRARIES})
# Link Qt libraries
if(QML)
target_link_libraries(wowlet PUBLIC
Qt5::Core
Qt5::Widgets
Qt5::Gui
Qt5::Network
Qt5::Svg
Qt5::QSvgPlugin
Qt5::QSvgIconPlugin
Qt5::Xml
Qt5::WebSockets
Qt5::Quick
Qt5::Qml
Qt5::QuickControls2)
else()
target_link_libraries(wowlet PUBLIC
Qt5::Core
Qt5::Widgets
Qt5::Gui
Qt5::Network
Qt5::Svg
Qt5::Xml
Qt5::WebSockets)
endif()
# Link random other stuff
target_link_libraries(wowlet PUBLIC
${ICU_LIBRARIES}
openpgp
Threads::Threads
${QRENCODE_LIBRARY}
)
${QRENCODE_LIBRARY})
# Link OpenVR
if(OPENVR)
if(MINGW)
target_link_libraries(wowlet PUBLIC
openvr_api64
gcc stdc++ winpthread ssp glu32 opengl32 glmf32 -dynamic)
else()
target_link_libraries(wowlet PUBLIC openvr_api)
endif()
endif()
if(APPLE)
target_link_libraries(wowlet
@ -206,14 +279,14 @@ if(APPLE)
endif()
if(NOT APPLE)
target_link_libraries(wowlet
target_link_libraries(wowlet PUBLIC
Qt5::QSvgIconPlugin
Qt5::QSvgPlugin
)
endif()
if(STATIC)
target_link_libraries(wowlet
target_link_libraries(wowlet PUBLIC
Qt5::QSvgIconPlugin
Qt5::QSvgPlugin)
if(UNIX AND NOT APPLE)
@ -223,7 +296,7 @@ if(STATIC)
endif()
if(X11_FOUND)
target_link_libraries(wowlet ${X11_LIBRARIES})
target_link_libraries(wowlet PUBLIC ${X11_LIBRARIES})
endif()
if(APPLE)

@ -10,6 +10,10 @@
#include "mainwindow.h"
#include "cli.h"
#ifdef HAS_OPENVR
#include "vr/main.h"
#endif
#if defined(Q_OS_WIN)
#include <windows.h>
#endif
@ -84,6 +88,12 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
QCommandLineOption backgroundPasswordOption(QStringList() << "daemon-password", "Password for connecting to the wowlet websocket service", "backgroundPassword");
parser.addOption(backgroundPasswordOption);
QCommandLineOption openVROption(QStringList() << "openvr", "Start Wowlet OpenVR");
parser.addOption(openVROption);
QCommandLineOption openVRDebugOption(QStringList() << "openvr-debug", "Start the Wowlet VR interface without initializing OpenVR - for debugging purposes.");
parser.addOption(openVRDebugOption);
auto parsed = parser.parse(argv_);
if(!parsed) {
qCritical() << parser.errorText();
@ -99,17 +109,35 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
bool exportContacts = parser.isSet(exportContactsOption);
bool exportTxHistory = parser.isSet(exportTxHistoryOption);
bool backgroundAddressEnabled = parser.isSet(backgroundOption);
bool openVREnabled = parser.isSet(openVROption);
bool cliMode = exportContacts || exportTxHistory || backgroundAddressEnabled;
qRegisterMetaType<QVector<QString>>();
if(openVREnabled) {
#ifdef HAS_OPENVR
QApplication vr_app(argc, argv);
auto *ctx = new AppContext(&parser);
auto *vr = new wowletVR::WowletVR(ctx, &parser, &vr_app);
qDebug() << "Context: " << qgetenv("QMLSCENE_DEVICE");
if(vr->errors.length() > 0)
return 1;
vr->render();
return vr_app.exec();
#else
qCritical() << "Wowlet compiled without OpenVR support.";
exit(1);
#endif
}
if(cliMode) {
auto *ctx = new AppContext(&parser);
QCoreApplication cli_app(argc, argv);
QCoreApplication::setApplicationName("wowlet");
QCoreApplication::setOrganizationDomain("wownero.org");
QCoreApplication::setOrganizationName("wownero.org");
auto *ctx = new AppContext(&parser);
ctx->applicationPath = QString(argv[0]);
ctx->isDebug = debugMode;

Loading…
Cancel
Save