2021-11-01 09:54:58 -04:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2022-02-23 19:00:17 -05:00
|
|
|
project(Astra)
|
2021-11-01 09:54:58 -04:00
|
|
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
2021-11-18 07:30:38 -05:00
|
|
|
find_package(Qt5 COMPONENTS Core Widgets Network CONFIG REQUIRED)
|
2021-11-01 09:54:58 -04:00
|
|
|
|
2022-01-27 09:25:23 -05:00
|
|
|
option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF)
|
2022-03-01 17:21:29 -05:00
|
|
|
option(USE_OWN_LIBRARIES "Build with own libraries" OFF)
|
2022-01-27 09:25:23 -05:00
|
|
|
|
|
|
|
if(ENABLE_WATCHDOG)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_search_module(TESSERACT REQUIRED tesseract)
|
|
|
|
pkg_search_module(LEPTONICA REQUIRED lept)
|
|
|
|
endif()
|
|
|
|
|
2021-12-06 21:15:31 -05:00
|
|
|
set(SRC
|
2021-11-01 09:54:58 -04:00
|
|
|
src/main.cpp
|
2021-11-23 15:34:23 -05:00
|
|
|
src/launchercore.cpp
|
2022-02-25 20:26:12 -05:00
|
|
|
include/launchercore.h
|
|
|
|
include/squarelauncher.h
|
2021-11-01 09:54:58 -04:00
|
|
|
src/sapphirelauncher.cpp
|
|
|
|
src/squareboot.cpp
|
2021-11-01 13:14:00 -04:00
|
|
|
src/squarelauncher.cpp
|
2021-11-09 14:12:41 -05:00
|
|
|
src/settingswindow.cpp
|
2021-11-23 15:34:23 -05:00
|
|
|
src/blowfish.cpp
|
|
|
|
src/assetupdater.cpp
|
2022-02-25 20:26:12 -05:00
|
|
|
include/assetupdater.h
|
2021-11-23 15:34:23 -05:00
|
|
|
src/launcherwindow.cpp
|
2022-02-25 20:26:12 -05:00
|
|
|
include/launcherwindow.h
|
2022-02-23 21:18:53 -05:00
|
|
|
src/gamescopesettingswindow.cpp
|
2022-03-09 09:25:01 -05:00
|
|
|
include/gamescopesettingswindow.h
|
2022-03-10 09:19:52 -05:00
|
|
|
include/headline.h
|
2022-03-10 10:11:31 -05:00
|
|
|
src/headline.cpp
|
2022-03-16 18:39:13 -04:00
|
|
|
include/config.h
|
|
|
|
include/gameinstaller.h
|
2022-03-27 21:08:27 -04:00
|
|
|
src/gameinstaller.cpp
|
|
|
|
src/encryptedarg.cpp)
|
2021-11-01 09:54:58 -04:00
|
|
|
|
2022-03-01 17:21:29 -05:00
|
|
|
include(FetchContent)
|
|
|
|
|
|
|
|
if(NOT USE_OWN_LIBRARIES)
|
2022-03-27 21:08:27 -04:00
|
|
|
find_package(Qt5Keychain QUIET)
|
2022-03-01 17:21:29 -05:00
|
|
|
endif()
|
|
|
|
|
2022-03-01 16:58:47 -05:00
|
|
|
if(TARGET Qt5Keychain::Qt5Keychain)
|
|
|
|
message("Using system library for Qt5 Keychain")
|
|
|
|
|
|
|
|
set(LIBRARIES Qt5Keychain::Qt5Keychain ${LIBRARIES})
|
2022-03-01 17:21:29 -05:00
|
|
|
set(KEYCHAIN_INCLUDE_DIRS ${QTKEYCHAIN_INCLUDE_DIRS}/qt5keychain) # this is to be consistent with the built-in lib?
|
|
|
|
else()
|
|
|
|
message("Using built-in qt keychain")
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
qtkeychain
|
|
|
|
GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git
|
|
|
|
GIT_TAG v0.12.0
|
|
|
|
)
|
|
|
|
|
|
|
|
set(BUILD_WITH_QT6 OFF CACHE BOOL "" FORCE)
|
|
|
|
set(QTKEYCHAIN_STATIC ON CACHE BOOL "" FORCE)
|
|
|
|
|
|
|
|
FetchContent_MakeAvailable(qtkeychain)
|
|
|
|
|
|
|
|
set(LIBRARIES qt5keychain ${LIBRARIES})
|
|
|
|
set(KEYCHAIN_INCLUDE_DIRS
|
|
|
|
${CMAKE_BINARY_DIR}/_deps/qtkeychain-src
|
|
|
|
${CMAKE_BINARY_DIR}/_deps/qtkeychain-build)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT USE_OWN_LIBRARIES)
|
2022-03-27 21:08:27 -04:00
|
|
|
find_package(QuaZip-Qt5 QUIET)
|
2022-03-01 16:58:47 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET QuaZip::QuaZip)
|
|
|
|
message("Using system library for Quazip")
|
|
|
|
|
|
|
|
set(LIBRARIES QuaZip::QuaZip ${LIBRARIES})
|
2022-03-01 17:21:29 -05:00
|
|
|
else()
|
|
|
|
message("Using built-in quazip")
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
quazip
|
|
|
|
GIT_REPOSITORY https://github.com/stachenov/quazip.git
|
|
|
|
GIT_TAG v1.2
|
|
|
|
)
|
2022-03-27 21:08:27 -04:00
|
|
|
|
|
|
|
set(QUAZIP_USE_QT_ZLIB ON CACHE BOOL "" FORCE)
|
|
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
|
|
|
|
2022-03-01 17:21:29 -05:00
|
|
|
FetchContent_MakeAvailable(quazip)
|
|
|
|
|
|
|
|
set(LIBRARIES QuaZip ${LIBRARIES})
|
|
|
|
set(QUAZIP_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/_deps/quazip-src/quazip)
|
2022-03-01 16:58:47 -05:00
|
|
|
endif()
|
|
|
|
|
2022-03-27 21:08:27 -04:00
|
|
|
if(NOT USE_OWN_LIBRARIES)
|
|
|
|
find_package(fmt QUIET)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET fmt::fmt)
|
|
|
|
message("Using system library for fmt")
|
|
|
|
|
|
|
|
set(LIBRARIES fmt::fmt ${LIBRARIES})
|
|
|
|
else()
|
|
|
|
message("Using built-in fmt")
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
fmt
|
|
|
|
GIT_REPOSITORY https://github.com/fmtlib/fmt
|
|
|
|
GIT_TAG master
|
|
|
|
)
|
|
|
|
|
|
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
|
|
|
|
|
|
|
FetchContent_MakeAvailable(fmt)
|
|
|
|
|
|
|
|
set(LIBRARIES fmt::fmt ${LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2022-03-01 16:58:47 -05:00
|
|
|
add_subdirectory(external)
|
|
|
|
|
2021-12-06 21:15:31 -05:00
|
|
|
set(LIBRARIES
|
2022-03-01 17:21:29 -05:00
|
|
|
Qt5::Core Qt5::Widgets Qt5::Network ${LIBRARIES})
|
2021-12-06 21:15:31 -05:00
|
|
|
|
2022-01-27 09:25:23 -05:00
|
|
|
if(ENABLE_WATCHDOG)
|
|
|
|
set(LIBRARIES ${LIBRARIES} ${TESSERACT_LIBRARIES} ${LEPTONICA_LIBRARIES})
|
|
|
|
|
2021-12-06 21:15:31 -05:00
|
|
|
set(SRC ${SRC}
|
2022-03-01 16:43:49 -05:00
|
|
|
include/watchdog.h
|
2022-01-27 09:25:23 -05:00
|
|
|
src/watchdog.cpp
|
2022-03-01 16:43:49 -05:00
|
|
|
include/gameparser.h
|
2022-01-27 09:25:23 -05:00
|
|
|
src/gameparser.cpp)
|
|
|
|
endif()
|
2021-12-06 21:15:31 -05:00
|
|
|
|
2022-03-16 09:51:12 -04:00
|
|
|
if(ENABLE_WATCHDOG)
|
2021-12-06 21:15:31 -05:00
|
|
|
set(LIBRARIES ${LIBRARIES}
|
|
|
|
X11
|
|
|
|
Xcomposite
|
|
|
|
Xrender)
|
|
|
|
endif()
|
|
|
|
|
2022-02-23 19:00:17 -05:00
|
|
|
add_executable(astra ${SRC})
|
2021-12-06 21:15:31 -05:00
|
|
|
|
2022-03-16 18:39:13 -04:00
|
|
|
target_link_libraries(astra PUBLIC ${LIBRARIES} libxiv)
|
2021-11-01 09:54:58 -04:00
|
|
|
|
2022-02-25 20:26:12 -05:00
|
|
|
target_include_directories(astra
|
|
|
|
PUBLIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
PRIVATE
|
2022-03-01 16:43:49 -05:00
|
|
|
${KEYCHAIN_INCLUDE_DIRS}
|
|
|
|
${QUAZIP_INCLUDE_DIRS})
|
2021-11-02 08:16:28 -04:00
|
|
|
|
2022-01-27 09:25:23 -05:00
|
|
|
if(ENABLE_WATCHDOG)
|
2022-02-23 19:00:17 -05:00
|
|
|
target_include_directories(astra PRIVATE ${TESSERACT_INCLUDE_DIRS} ${LEPTONICA_INCLUDE_DIRS})
|
2022-01-27 09:25:23 -05:00
|
|
|
|
2022-02-23 19:00:17 -05:00
|
|
|
target_compile_definitions(astra PRIVATE ENABLE_WATCHDOG)
|
2022-01-27 09:25:23 -05:00
|
|
|
endif()
|
|
|
|
|
2022-02-23 19:00:17 -05:00
|
|
|
install(TARGETS astra
|
2022-03-01 16:43:49 -05:00
|
|
|
DESTINATION "${INSTALL_BIN_PATH}")
|
2021-11-02 08:16:28 -04:00
|
|
|
|
|
|
|
if(WIN32)
|
2022-03-01 16:43:49 -05:00
|
|
|
get_target_property(QMAKE_EXE Qt5::qmake IMPORTED_LOCATION)
|
2021-11-02 08:16:28 -04:00
|
|
|
get_filename_component(QT_BIN_DIR "${QMAKE_EXE}" DIRECTORY)
|
|
|
|
|
|
|
|
find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${QT_BIN_DIR}")
|
|
|
|
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
|
|
|
|
|
|
|
|
# Run windeployqt immediately after build
|
2022-02-23 19:00:17 -05:00
|
|
|
add_custom_command(TARGET astra
|
2021-11-02 08:16:28 -04:00
|
|
|
POST_BUILD
|
2022-02-23 19:00:17 -05:00
|
|
|
COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$<TARGET_FILE:astra>\"
|
2021-11-02 08:16:28 -04:00
|
|
|
)
|
2022-01-27 09:25:23 -05:00
|
|
|
endif()
|