From c7fd69a78e51e7a9eca3a842a61ff61b5386f99a Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 30 Apr 2020 20:03:14 +0200 Subject: [PATCH] Add first working cmake version for ScreenPlay Refactor stomt sdk from qmake/github to cmake/gitlab --- .gitignore | 13 ++++ .gitmodules | 4 ++ CMakeLists.txt | 34 +++++++++- Common/stomt-qml | 1 + ScreenPlay/CMakeLists.txt | 102 +++++++++++------------------ ScreenPlay/src/settings.cpp | 2 +- ScreenPlaySDK/CMakeLists.txt | 28 +++++--- ScreenPlaySysInfo/CMakeLists.txt | 24 ++++--- ScreenPlayWallpaper/CMakeLists.txt | 78 +++++++++++++++------- ScreenPlayWallpaper/main.cpp | 2 - ScreenPlayWidget/CMakeLists.txt | 11 +++- install_dependencies_linux_mac.sh | 16 +++++ install_dependencies_windows.bat | 10 +++ stomt-qml | 1 + 14 files changed, 211 insertions(+), 115 deletions(-) create mode 160000 Common/stomt-qml create mode 100644 install_dependencies_linux_mac.sh create mode 100644 install_dependencies_windows.bat create mode 160000 stomt-qml diff --git a/.gitignore b/.gitignore index 761a8255..db185c4e 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,16 @@ Common/vcpkg/** *.DS_Store /Common/vcpkg/ /Docs/html/screemplay.index + +#CMake +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps diff --git a/.gitmodules b/.gitmodules index 433fa4bd..c984af67 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,7 @@ [submodule "Common/qt-breakpad"] path = Common/qt-breakpad url = https://github.com/kelteseth/qt-breakpad +[submodule "Common/stomt-qml"] + path = Common/stomt-qml + url = https://gitlab.com/kelteseth/stomt-qml.git + branch = master diff --git a/CMakeLists.txt b/CMakeLists.txt index a2b51db6..39345fde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,40 @@ -cmake_minimum_required(VERSION 3.0.0 ) +cmake_minimum_required(VERSION 3.17.0 ) + +if(WIN32) + set(VCPKG_TARGET_TRIPLET "x64-windows") +elseif(APPLE) + set(VCPKG_TARGET_TRIPLET "x64-osx") +elseif(UNIX) + set(VCPKG_TARGET_TRIPLET "x64-linux") +endif() + +set(ABSOLUTE_VCPKG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake) + +# If setting the toolchain file fails we can the it inside QtCreator: Extras -> +# Tools -> Kits -> -> CMake Configuration -> Append this: +# CMAKE_TOOLCHAIN_FILE:STRING=%{CurrentProject:Path}/Common/vcpkg/scripts/buildsystems/vcpkg.cmake +if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE ${ABSOLUTE_VCPKG_PATH}) +endif() + +# This sets cmake to compile all dlls into the main directory +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +set(CMAKE_CXX_STANDARD 17) + +set(QT_TELEMTRY_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-google-analytics/) +set(QT_BREAKPAD_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-breakpad/) + project(ScreenPlay) + add_subdirectory(ScreenPlay) add_subdirectory(ScreenPlaySDK) add_subdirectory(ScreenPlayWallpaper) add_subdirectory(ScreenPlayWidget) add_subdirectory(ScreenPlaySysInfo) -add_subdirectory(Common/stomt-qt-sdk/sdk) -add_subdirectory(Common/qt-google-analytics) +add_subdirectory(Common/stomt-qml) add_subdirectory(Common/qt-breakpad) diff --git a/Common/stomt-qml b/Common/stomt-qml new file mode 160000 index 00000000..e7e87151 --- /dev/null +++ b/Common/stomt-qml @@ -0,0 +1 @@ +Subproject commit e7e871512a18d227652a5dd825415e3b59a01de0 diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index cd02db63..d258906f 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -1,77 +1,28 @@ -cmake_minimum_required(VERSION 3.16.0) - -set (DEPENDENCIES "openSSL" - "libzippp" - "nlohmann-json") - - -if(NOT DEFINED ENV{VCPKG_ROOT}) - set(VCPKG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../Common/vcpkg) -endif() - -if(NOT EXISTS ${VCPKG_ROOT}) -message("Cloning vcpkg in ${VCPKG_ROOT}") -execute_process(COMMAND git clone https://github.com/Microsoft/vcpkg.git ${VCPKG_ROOT}) -# execute_process(COMMAND git checkout 745a0aea597771a580d0b0f4886ea1e3a94dbca6 WORKING_DIRECTORY ${VCPKG_ROOT}) -else() -# The following command has no effect if the vcpkg repository is in a detached head state. -message("Auto-updating vcpkg in ${VCPKG_ROOT}") -execute_process(COMMAND git pull WORKING_DIRECTORY ${VCPKG_ROOT}) -endif() - -if(NOT EXISTS ${VCPKG_ROOT}/README.md) -message(FATAL_ERROR "***** FATAL ERROR: Could not clone vcpkg *****") -endif() - -if(WIN32) -set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg.exe) -set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.bat) -else() -set(VCPKG_EXEC ${VCPKG_ROOT}/vcpkg) -set(VCPKG_BOOTSTRAP ${VCPKG_ROOT}/bootstrap-vcpkg.sh) -endif() - -if(NOT EXISTS ${VCPKG_EXEC}) -message("Bootstrapping vcpkg in ${VCPKG_ROOT}") -execute_process(COMMAND ${VCPKG_BOOTSTRAP} WORKING_DIRECTORY ${VCPKG_ROOT}) -endif() - -if(NOT EXISTS ${VCPKG_EXEC}) -message(FATAL_ERROR "***** FATAL ERROR: Could not bootstrap vcpkg *****") -endif() - -set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE STRING "") - -message(STATUS "***** Checking project third party dependencies in ${VCPKG_ROOT} *****") -execute_process(COMMAND ${VCPKG_EXEC} install ${DEPENDENCIES} WORKING_DIRECTORY ${VCPKG_ROOT}) - +cmake_minimum_required(VERSION 3.17) project(ScreenPlay) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOMOC ON) -find_package(Qt5Qml) -find_package(Qt5Quick) -find_package(Qt5Gui) -find_package(Qt5Widgets) -find_package(Qt5Core) +find_package( + Qt5 + COMPONENTS Quick + QML + Widgets + Gui + WebEngine + REQUIRED) +find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) -target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto) - find_package(libzippp CONFIG REQUIRED) -target_link_libraries(main PRIVATE libzippp::libzippp) - find_package(nlohmann_json CONFIG REQUIRED) -target_link_libraries(main PRIVATE nlohmann_json nlohmann_json::nlohmann_json) set(src main.cpp app.cpp + ../Common/qt-google-analytics/ganalytics.cpp src/createimportvideo.cpp src/installedlistmodel.cpp src/monitorlistmodel.cpp @@ -85,7 +36,9 @@ set(src main.cpp src/screenplaymanager.cpp src/util.cpp src/create.cpp) + set(headers app.h + ../Common/qt-google-analytics/ganalytics.h src/globalvariables.h src/createimportvideo.h src/installedlistmodel.h @@ -105,8 +58,29 @@ set(headers app.h src/create.h) set(resources Resources.qrc) -add_executable(ScreenPlay ${src} ${headers} ${resources}) -target_link_libraries(ScreenPlay Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core) -#target_compile_definitions( PRIVATE GIT_VERSION=///"$$GIT_VERSION///") -install(TARGETS DESTINATION Bin) +add_executable(ScreenPlay ${src} ${headers} ${resources}) + +target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") + +target_link_libraries(ScreenPlay PRIVATE + Qt5::Qml + Qt5::Quick + Qt5::Gui + Qt5::Widgets + Qt5::Core + Qt5::WebEngine + nlohmann_json::nlohmann_json + libzippp::libzippp + ScreenPlaySDK + QTBreakpadplugin) + +target_include_directories(${PROJECT_NAME} + PRIVATE + ${QT_TELEMTRY_INCLUDE} + ${QT_BREAKPAD_INCLUDE}) + + +execute_process(COMMAND git log --pretty=format:'%h' -n 1 + OUTPUT_VARIABLE GIT_VERSION + ERROR_QUIET) diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index f7de4cdd..6d217108 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -110,7 +110,7 @@ Settings::Settings(const shared_ptr& globalVariables, } setupWidgetAndWindowPaths(); - setGitBuildHash(GIT_VERSION); + setGitBuildHash("GIT_VERSION"); } /*! diff --git a/ScreenPlaySDK/CMakeLists.txt b/ScreenPlaySDK/CMakeLists.txt index 005851b3..6ab49b4e 100644 --- a/ScreenPlaySDK/CMakeLists.txt +++ b/ScreenPlaySDK/CMakeLists.txt @@ -1,16 +1,24 @@ -cmake_minimum_required(VERSION 3.16.0) project(ScreenPlaySDK) -set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTORCC ON) set(CMAKE_AUTOMOC ON) -find_package(Qt5Core) -find_package(Qt5Quick) -find_package(Qt5Gui) -find_package(Qt5Qml) + + +find_package( + Qt5 + COMPONENTS Quick + QML + Widgets + Gui + Network + Core + REQUIRED) + set(src screenplay-sdk_plugin.cpp screenplaysdk.cpp) set(headers screenplay-sdk_plugin.h screenplaysdk.h) -add_library(screenplaysdk MODULE ${src} ${headers}) -target_link_libraries(screenplaysdk PRIVATE Qt5::Core Qt5::Quick Qt5::Gui Qt5::Qml) -set_target_properties(screenplaysdk PROPERTIES DEBUG_POSTFIX "d") -install(TARGETS screenplaysdk DESTINATION Libs) + +add_library(${PROJECT_NAME} ${src} ${headers}) + +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::Gui Qt5::Qml Qt5::Network) diff --git a/ScreenPlaySysInfo/CMakeLists.txt b/ScreenPlaySysInfo/CMakeLists.txt index 9b2fc604..8de9b6f9 100644 --- a/ScreenPlaySysInfo/CMakeLists.txt +++ b/ScreenPlaySysInfo/CMakeLists.txt @@ -1,11 +1,16 @@ -cmake_minimum_required(VERSION 3.16.0) project(ScreenPlaySysInfo) -set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTORCC ON) set(CMAKE_AUTOMOC ON) -find_package(Qt5Core) -find_package(Qt5Quick) -find_package(Qt5Gui) -find_package(Qt5Qml) + +find_package( + Qt5 + COMPONENTS Quick + QML + Core + REQUIRED) + + set(src screenplaysysinfo_plugin.cpp sysinfo.cpp cpu.cpp @@ -18,6 +23,7 @@ set(headers screenplaysysinfo_plugin.h mathhelper.h storage.h) -add_library(screenplaysysinfo MODULE ${src} ${headers}) -target_link_libraries(screenplaysysinfo PRIVATE Qt5::Core Qt5::Quick Qt5::Gui Qt5::Qml) -install(TARGETS screenplaysysinfo DESTINATION Libs) +add_library(${PROJECT_NAME} ${src} ${headers}) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::Qml) + + diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 3289fb61..e6025457 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -1,30 +1,58 @@ -cmake_minimum_required(VERSION 3.16.0) project(ScreenPlayWallpaper) -set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_AUTORCC ON) set(CMAKE_AUTOMOC ON) -find_package(Qt5Qml) -find_package(Qt5Quick) -find_package(Qt5Gui) -find_package(Qt5Widgets) -find_package(Qt5Core) -set(src main.cpp - src/basewindow.cpp - src/linuxwindow.cpp - src/windowsdesktopproperties.cpp - src/winwindow.cpp - src/macintegration.cpp - src/macwindow.cpp) -set(headers src/basewindow.h - src/linuxwindow.h - src/windowsdesktopproperties.h - src/winwindow.h - src/macintegration.h - src/macbridge.h - src/macwindow.h) + + +find_package( + Qt5 + COMPONENTS Quick + QML + Widgets + Gui + WebEngine + REQUIRED) + + +if(WIN32) + set(src_plattform + src/windowsdesktopproperties.cpp + src/winwindow.cpp) + set(headers_plattform + src/windowsdesktopproperties.h + src/winwindow.h) +elseif(APPLE) + set(src_plattform + src/macintegration.cpp + src/macwindow.cpp) + set(headers_plattform + src/macintegration.h + src/macbridge.h + src/macwindow.h) +elseif(UNIX) + set(src_plattform + main.cpp + src/linuxwindow.cpp) + set(headers_plattform + src/linuxwindow.h) +endif() + +set( src + main.cpp + src/basewindow.cpp) +set( headers + src/basewindow.h) + set(resources SPWResources.qrc) -add_executable(ScreenPlayWallpaper ${src} ${headers} ${resources}) -target_link_libraries( ScreenPlayWallpaper Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core) +add_executable(${PROJECT_NAME} ${src} ${headers} ${src_plattform} ${headers_plattform} ${resources}) - -install(TARGETS DESTINATION Bin) +target_link_libraries(${PROJECT_NAME} + PRIVATE + Qt5::Qml + Qt5::Quick + Qt5::Gui + Qt5::Widgets + Qt5::Core + Qt5::WebEngine + ScreenPlaySDK + ) diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index 136a0917..76d1cc64 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -6,7 +6,6 @@ #include #if defined(Q_OS_WIN) -#include "qt_breakpad.h" #include "src/winwindow.h" #endif @@ -40,7 +39,6 @@ int main(int argc, char* argv[]) //Set the monitor number to test #if defined(Q_OS_WIN) - QtBreakpad::init(QDir::current().absolutePath()); //WinWindow window1({ 0 }, "test", "appid", "1", "fill"); //WinWindow window2({ 1 }, "test", "appid", "1", "fill"); diff --git a/ScreenPlayWidget/CMakeLists.txt b/ScreenPlayWidget/CMakeLists.txt index 7d00b187..239e79fc 100644 --- a/ScreenPlayWidget/CMakeLists.txt +++ b/ScreenPlayWidget/CMakeLists.txt @@ -13,5 +13,14 @@ set(src main.cpp set(headers src/widgetwindow.h) set(resources SPWidgetResources.qrc) add_executable(ScreenPlayWidget ${src} ${headers} ${resources}) -target_link_libraries( ScreenPlayWidget Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core) + +target_link_libraries( ScreenPlayWidget + PRIVATE + Qt5::Qml + Qt5::Quick + Qt5::Gui + Qt5::Widgets + Qt5::Core + ScreenPlaySDK + ) diff --git a/install_dependencies_linux_mac.sh b/install_dependencies_linux_mac.sh new file mode 100644 index 00000000..ed40a876 --- /dev/null +++ b/install_dependencies_linux_mac.sh @@ -0,0 +1,16 @@ +git submodule update --init +git submodule update --recursive +cd Common +git clone https://github.com/microsoft/vcpkg.git +cd vcpkg +git pull +git checkout origin/master +chmod +x bootstrap-vcpkg.sh +./bootstrap-vcpkg.sh +chmod +x vcpkg + +if [[ "$OSTYPE" == "darwin"* ]]; then +./vcpkg install libzippp:x64-osx nlohmann-json:x64-osx openssl-unix:x64-osx libzip:x64-osx +else +./vcpkg install libzippp:x64-linux nlohmann-json:x64-linux openssl-unix:x64-linux libzip:x64-linux +fi \ No newline at end of file diff --git a/install_dependencies_windows.bat b/install_dependencies_windows.bat new file mode 100644 index 00000000..fd7c5b32 --- /dev/null +++ b/install_dependencies_windows.bat @@ -0,0 +1,10 @@ +git submodule update --init +git submodule update --recursive +cd Common +git clone https://github.com/microsoft/vcpkg.git +cd vcpkg +git pull +git checkout 2bc6cd714 +call bootstrap-vcpkg.bat +vcpkg.exe install zlib libzip libzippp nlohmann-json openssl breakpad --triplet x64-windows --recurse +pause \ No newline at end of file diff --git a/stomt-qml b/stomt-qml new file mode 160000 index 00000000..e7e87151 --- /dev/null +++ b/stomt-qml @@ -0,0 +1 @@ +Subproject commit e7e871512a18d227652a5dd825415e3b59a01de0