mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 11:47:46 +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)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(Astra)
|
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_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Core Widgets Network Quick CONFIG REQUIRED)
|
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)
|
if (ENABLE_WATCHDOG)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(TESSERACT REQUIRED tesseract)
|
pkg_search_module(TESSERACT REQUIRED tesseract)
|
||||||
pkg_search_module(LEPTONICA REQUIRED lept)
|
pkg_search_module(LEPTONICA REQUIRED lept)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (USE_GAMEMODE)
|
if (ENABLE_GAMEMODE)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(GAMEMODE REQUIRED gamemode)
|
pkg_search_module(GAMEMODE REQUIRED gamemode)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
include(FetchContent)
|
if (ENABLE_STEAM)
|
||||||
|
|
||||||
if(USE_STEAM)
|
|
||||||
add_library(Steamworks IMPORTED STATIC)
|
add_library(Steamworks IMPORTED STATIC)
|
||||||
set_target_properties(Steamworks PROPERTIES
|
set_target_properties(Steamworks PROPERTIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${STEAMWORKS_INCLUDE_DIR}
|
INTERFACE_INCLUDE_DIRECTORIES ${STEAMWORKS_INCLUDE_DIR}
|
||||||
IMPORTED_LOCATION ${STEAMWORKS_LIBRARIES})
|
IMPORTED_LOCATION ${STEAMWORKS_LIBRARIES})
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
find_package(Qt5Keychain)
|
find_package(Qt5Keychain REQUIRED)
|
||||||
set(LIBRARIES Qt5Keychain::Qt5Keychain ${LIBRARIES})
|
find_package(QuaZip-Qt5 REQUIRED)
|
||||||
|
find_package(fmt REQUIRED)
|
||||||
find_package(QuaZip-Qt5)
|
|
||||||
set(LIBRARIES QuaZip::QuaZip ${LIBRARIES})
|
|
||||||
|
|
||||||
find_package(fmt)
|
|
||||||
set(LIBRARIES fmt::fmt ${LIBRARIES})
|
|
||||||
|
|
||||||
add_subdirectory(external)
|
add_subdirectory(external)
|
||||||
|
|
||||||
add_subdirectory(launcher)
|
add_subdirectory(launcher)
|
|
@ -1,21 +1,43 @@
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(cli)
|
|
||||||
add_subdirectory(desktop)
|
if(ENABLE_CLI)
|
||||||
add_subdirectory(tablet)
|
add_subdirectory(cli)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_DESKTOP)
|
||||||
|
add_subdirectory(desktop)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_TABLET)
|
||||||
|
add_subdirectory(tablet)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(astra
|
add_executable(astra
|
||||||
main.cpp
|
main.cpp
|
||||||
tablet/qml/qml.qrc)
|
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
|
target_link_libraries(astra PUBLIC
|
||||||
${LIBRARIES}
|
|
||||||
astra_core
|
astra_core
|
||||||
astra_desktop
|
${INTERFACES})
|
||||||
astra_cli
|
|
||||||
astra_tablet)
|
|
||||||
target_compile_features(astra PUBLIC cxx_std_17)
|
target_compile_features(astra PUBLIC cxx_std_17)
|
||||||
set_target_properties(astra PROPERTIES CXX_EXTENSIONS OFF)
|
set_target_properties(astra PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# meant for including the license text
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE LICENSE_TXT)
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE LICENSE_TXT)
|
||||||
STRING(REPLACE "\n" " \\n" LICENSE_TXT ${LICENSE_TXT})
|
STRING(REPLACE "\n" " \\n" LICENSE_TXT ${LICENSE_TXT})
|
||||||
STRING(REPLACE "\"" "\"\"" LICENSE_TXT ${LICENSE_TXT})
|
STRING(REPLACE "\"" "\"\"" LICENSE_TXT ${LICENSE_TXT})
|
||||||
|
|
|
@ -40,12 +40,12 @@ if (ENABLE_WATCHDOG)
|
||||||
Xrender)
|
Xrender)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(USE_STEAM)
|
if(ENABLE_STEAM)
|
||||||
set(LIBRARIES ${LIBRARIES}
|
set(LIBRARIES ${LIBRARIES}
|
||||||
Steamworks)
|
Steamworks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_GAMEMODE)
|
if(ENABLE_GAMEMODE)
|
||||||
set(LIBRARIES ${LIBRARIES}
|
set(LIBRARIES ${LIBRARIES}
|
||||||
${GAMEMODE_LIBRARIES})
|
${GAMEMODE_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
@ -59,6 +59,8 @@ target_include_directories(astra_core PUBLIC
|
||||||
target_link_libraries(astra_core PUBLIC
|
target_link_libraries(astra_core PUBLIC
|
||||||
physis
|
physis
|
||||||
z # FIXME: remove!
|
z # FIXME: remove!
|
||||||
|
QuaZip::QuaZip
|
||||||
|
Qt5Keychain::Qt5Keychain
|
||||||
${LIBRARIES}
|
${LIBRARIES}
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Network
|
Qt5::Network
|
||||||
|
@ -74,10 +76,10 @@ if (ENABLE_WATCHDOG)
|
||||||
target_compile_definitions(astra_core PUBLIC ENABLE_WATCHDOG)
|
target_compile_definitions(astra_core PUBLIC ENABLE_WATCHDOG)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(USE_GAMEMODE)
|
if(ENABLE_GAMEMODE)
|
||||||
target_compile_definitions(astra_core PUBLIC USE_GAMEMODE)
|
target_compile_definitions(astra_core PUBLIC USE_GAMEMODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_STEAM)
|
if(ENABLE_STEAM)
|
||||||
target_compile_definitions(astra_core PUBLIC USE_STEAM)
|
target_compile_definitions(astra_core PUBLIC USE_STEAM)
|
||||||
endif()
|
endif()
|
|
@ -38,13 +38,19 @@ int main(int argc, char* argv[]) {
|
||||||
auto versionOption = parser.addVersionOption();
|
auto versionOption = parser.addVersionOption();
|
||||||
|
|
||||||
QCommandLineOption desktopOption("desktop", "Open a desktop interface.");
|
QCommandLineOption desktopOption("desktop", "Open a desktop interface.");
|
||||||
|
#ifdef ENABLE_DESKTOP
|
||||||
parser.addOption(desktopOption);
|
parser.addOption(desktopOption);
|
||||||
|
#endif
|
||||||
|
|
||||||
QCommandLineOption tabletOption("tablet", "Open a tablet interface.");
|
QCommandLineOption tabletOption("tablet", "Open a tablet interface.");
|
||||||
|
#ifdef ENABLE_TABLET
|
||||||
parser.addOption(tabletOption);
|
parser.addOption(tabletOption);
|
||||||
|
#endif
|
||||||
|
|
||||||
QCommandLineOption cliOption("cli", "Don't open a main window, and use the cli interface.");
|
QCommandLineOption cliOption("cli", "Don't open a main window, and use the cli interface.");
|
||||||
|
#ifdef ENABLE_CLI
|
||||||
parser.addOption(cliOption);
|
parser.addOption(cliOption);
|
||||||
|
#endif
|
||||||
|
|
||||||
auto cmd = std::make_unique<CMDInterface>(parser);
|
auto cmd = std::make_unique<CMDInterface>(parser);
|
||||||
|
|
||||||
|
@ -74,12 +80,18 @@ int main(int argc, char* argv[]) {
|
||||||
std::unique_ptr<TabletInterface> tabletInterface;
|
std::unique_ptr<TabletInterface> tabletInterface;
|
||||||
|
|
||||||
if (parser.isSet(tabletOption)) {
|
if (parser.isSet(tabletOption)) {
|
||||||
|
#ifdef ENABLE_TABLET
|
||||||
tabletInterface = std::make_unique<TabletInterface>(c);
|
tabletInterface = std::make_unique<TabletInterface>(c);
|
||||||
|
#endif
|
||||||
} else if (parser.isSet(cliOption)) {
|
} else if (parser.isSet(cliOption)) {
|
||||||
|
#ifdef ENABLE_CLI
|
||||||
if (!cmd->parse(parser, c))
|
if (!cmd->parse(parser, c))
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef ENABLE_DESKTOP
|
||||||
desktopInterface = std::make_unique<DesktopInterface>(c);
|
desktopInterface = std::make_unique<DesktopInterface>(c);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Add table
Reference in a new issue