mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 03:37:47 +00:00
Change around CMake options
Now all feature options have a unified naming scheme, make interface options toggleable for the users that care.
This commit is contained in:
parent
d1b4dd37aa
commit
27a167e913
4 changed files with 65 additions and 32 deletions
|
@ -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 ()
|
||||
|
||||
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 ()
|
||||
|
||||
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)
|
|
@ -1,21 +1,43 @@
|
|||
add_subdirectory(core)
|
||||
|
||||
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})
|
||||
|
|
|
@ -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()
|
|
@ -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<CMDInterface>(parser);
|
||||
|
||||
|
@ -74,12 +80,18 @@ int main(int argc, char* argv[]) {
|
|||
std::unique_ptr<TabletInterface> tabletInterface;
|
||||
|
||||
if (parser.isSet(tabletOption)) {
|
||||
#ifdef ENABLE_TABLET
|
||||
tabletInterface = std::make_unique<TabletInterface>(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<DesktopInterface>(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
|
|
Loading…
Add table
Reference in a new issue