From 27a167e9135ffcb61464971f29eb78acba19a623 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 5 Sep 2022 17:42:13 -0400 Subject: [PATCH] Change around CMake options Now all feature options have a unified naming scheme, make interface options toggleable for the users that care. --- CMakeLists.txt | 39 +++++++++++++++++------------------- launcher/CMakeLists.txt | 36 ++++++++++++++++++++++++++------- launcher/core/CMakeLists.txt | 10 +++++---- launcher/main.cpp | 12 +++++++++++ 4 files changed, 65 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42d6d77..22ccad9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,46 +1,43 @@ cmake_minimum_required(VERSION 3.0) project(Astra) +# build options used for distributors +option(BUILD_FLATPAK "Build for Flatpak." OFF) + +# options for features you may want or need +option(ENABLE_WATCHDOG "Build support for Watchdog, requires an X11 system." OFF) +option(ENABLE_STEAM "Build with Steam support, requires supplying the Steam SDK." OFF) +option(ENABLE_GAMEMODE "Build with Feral GameMode support, requires the daemon to be installed." ON) +option(ENABLE_TABLET "Build support for the tablet interface, meant for devices like the Steam Deck." ON) +option(ENABLE_DESKTOP "Build support for the desktop interface, meant to be used on desktops and laptops." ON) +option(ENABLE_CLI "Build support for the command-line interface, meant for scripting and automation." ON) + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) find_package(Qt5 COMPONENTS Core Widgets Network Quick CONFIG REQUIRED) -option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF) -option(USE_OWN_LIBRARIES "Build with own libraries" OFF) -option(BUILD_FLATPAK "Build with Flatpak support in mind" OFF) -option(USE_STEAM "Build with Steam support" OFF) -option(USE_GAMEMODE "Build with GameMode support" ON) - if (ENABLE_WATCHDOG) find_package(PkgConfig REQUIRED) pkg_search_module(TESSERACT REQUIRED tesseract) pkg_search_module(LEPTONICA REQUIRED lept) endif () -if (USE_GAMEMODE) +if (ENABLE_GAMEMODE) find_package(PkgConfig REQUIRED) pkg_search_module(GAMEMODE REQUIRED gamemode) -endif() +endif () -include(FetchContent) - -if(USE_STEAM) +if (ENABLE_STEAM) add_library(Steamworks IMPORTED STATIC) set_target_properties(Steamworks PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STEAMWORKS_INCLUDE_DIR} IMPORTED_LOCATION ${STEAMWORKS_LIBRARIES}) -endif() +endif () -find_package(Qt5Keychain) -set(LIBRARIES Qt5Keychain::Qt5Keychain ${LIBRARIES}) - -find_package(QuaZip-Qt5) -set(LIBRARIES QuaZip::QuaZip ${LIBRARIES}) - -find_package(fmt) -set(LIBRARIES fmt::fmt ${LIBRARIES}) +find_package(Qt5Keychain REQUIRED) +find_package(QuaZip-Qt5 REQUIRED) +find_package(fmt REQUIRED) add_subdirectory(external) - add_subdirectory(launcher) \ No newline at end of file diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index fb14a89..ee544c7 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1,21 +1,43 @@ add_subdirectory(core) -add_subdirectory(cli) -add_subdirectory(desktop) -add_subdirectory(tablet) + +if(ENABLE_CLI) + add_subdirectory(cli) +endif() + +if(ENABLE_DESKTOP) + add_subdirectory(desktop) +endif() + +if(ENABLE_TABLET) + add_subdirectory(tablet) +endif() add_executable(astra main.cpp tablet/qml/qml.qrc) +if(ENABLE_DESKTOP) + set(INTERFACES ${INTERFACES} astra_desktop) + target_compile_definitions(astra PRIVATE ENABLE_DESKTOP) +endif() + +if(ENABLE_TABLET) + set(INTERFACES ${INTERFACES} astra_tablet) + target_compile_definitions(astra PRIVATE ENABLE_TABLET) +endif() + +if(ENABLE_CLI) + set(INTERFACES ${INTERFACES} astra_cli) + target_compile_definitions(astra PRIVATE ENABLE_CLI) +endif() + target_link_libraries(astra PUBLIC - ${LIBRARIES} astra_core - astra_desktop - astra_cli - astra_tablet) + ${INTERFACES}) target_compile_features(astra PUBLIC cxx_std_17) set_target_properties(astra PROPERTIES CXX_EXTENSIONS OFF) +# meant for including the license text file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE LICENSE_TXT) STRING(REPLACE "\n" " \\n" LICENSE_TXT ${LICENSE_TXT}) STRING(REPLACE "\"" "\"\"" LICENSE_TXT ${LICENSE_TXT}) diff --git a/launcher/core/CMakeLists.txt b/launcher/core/CMakeLists.txt index 8efed27..8901659 100644 --- a/launcher/core/CMakeLists.txt +++ b/launcher/core/CMakeLists.txt @@ -40,12 +40,12 @@ if (ENABLE_WATCHDOG) Xrender) endif () -if(USE_STEAM) +if(ENABLE_STEAM) set(LIBRARIES ${LIBRARIES} Steamworks) endif() -if(USE_GAMEMODE) +if(ENABLE_GAMEMODE) set(LIBRARIES ${LIBRARIES} ${GAMEMODE_LIBRARIES}) endif() @@ -59,6 +59,8 @@ target_include_directories(astra_core PUBLIC target_link_libraries(astra_core PUBLIC physis z # FIXME: remove! + QuaZip::QuaZip + Qt5Keychain::Qt5Keychain ${LIBRARIES} Qt5::Core Qt5::Network @@ -74,10 +76,10 @@ if (ENABLE_WATCHDOG) target_compile_definitions(astra_core PUBLIC ENABLE_WATCHDOG) endif () -if(USE_GAMEMODE) +if(ENABLE_GAMEMODE) target_compile_definitions(astra_core PUBLIC USE_GAMEMODE) endif() -if(USE_STEAM) +if(ENABLE_STEAM) target_compile_definitions(astra_core PUBLIC USE_STEAM) endif() \ No newline at end of file diff --git a/launcher/main.cpp b/launcher/main.cpp index 918e7da..8a91761 100755 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -38,13 +38,19 @@ int main(int argc, char* argv[]) { auto versionOption = parser.addVersionOption(); QCommandLineOption desktopOption("desktop", "Open a desktop interface."); +#ifdef ENABLE_DESKTOP parser.addOption(desktopOption); +#endif QCommandLineOption tabletOption("tablet", "Open a tablet interface."); +#ifdef ENABLE_TABLET parser.addOption(tabletOption); +#endif QCommandLineOption cliOption("cli", "Don't open a main window, and use the cli interface."); +#ifdef ENABLE_CLI parser.addOption(cliOption); +#endif auto cmd = std::make_unique(parser); @@ -74,12 +80,18 @@ int main(int argc, char* argv[]) { std::unique_ptr tabletInterface; if (parser.isSet(tabletOption)) { +#ifdef ENABLE_TABLET tabletInterface = std::make_unique(c); +#endif } else if (parser.isSet(cliOption)) { +#ifdef ENABLE_CLI if (!cmd->parse(parser, c)) return -1; +#endif } else { +#ifdef ENABLE_DESKTOP desktopInterface = std::make_unique(c); +#endif } return app.exec();