2022-09-18 02:57:50 +00:00
|
|
|
# CMake modules
|
|
|
|
include(ExternalProject)
|
|
|
|
|
2022-09-15 21:29:53 +00:00
|
|
|
# External dependencies.
|
2022-09-24 09:01:22 +00:00
|
|
|
find_package(Qt6 COMPONENTS Widgets REQUIRED)
|
2022-09-18 07:04:02 +00:00
|
|
|
find_package(Threads REQUIRED)
|
2022-09-15 05:22:22 +00:00
|
|
|
|
2023-02-26 19:22:42 +00:00
|
|
|
# Setup LLVM target.
|
2023-06-25 19:33:29 +00:00
|
|
|
set(LLVM_OPTS -DCMAKE_INSTALL_PREFIX:STRING=<INSTALL_DIR> -DLLVM_ENABLE_ZSTD:BOOL=OFF -DLLVM_APPEND_VC_REV:BOOL=OFF)
|
2023-02-26 19:22:42 +00:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
|
|
|
|
list(APPEND LLVM_OPTS -DLLVM_TARGETS_TO_BUILD:STRING=X86)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Target CPU is not supported")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
|
|
|
list(APPEND LLVM_OPTS -DLLVM_TARGETS_TO_BUILD:STRING=X86)
|
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
|
|
|
|
list(APPEND LLVM_OPTS -DLLVM_TARGETS_TO_BUILD:STRING=AArch64)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Target CPU is not supported")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND LLVM_OPTS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
|
|
|
|
endif()
|
|
|
|
|
2023-09-03 09:39:47 +00:00
|
|
|
if(OB_BUILD_LLVM)
|
|
|
|
ExternalProject_Add(llvm
|
2023-11-16 02:23:10 +00:00
|
|
|
URL https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz
|
|
|
|
URL_HASH SHA256=95d7eff82945cf05c16a1851d7b391fc2da726b87c1138125e3b6e4d300ab834
|
2023-09-03 09:39:47 +00:00
|
|
|
DOWNLOAD_NO_PROGRESS true
|
|
|
|
CMAKE_ARGS -Wno-dev
|
|
|
|
CMAKE_CACHE_ARGS ${LLVM_OPTS}
|
|
|
|
SOURCE_SUBDIR llvm
|
|
|
|
BUILD_ALWAYS ON
|
|
|
|
INSTALL_DIR ${CMAKE_SOURCE_DIR}/lib/llvm)
|
2023-07-28 21:12:36 +00:00
|
|
|
endif()
|
|
|
|
|
2022-09-18 02:57:50 +00:00
|
|
|
# Setup Rust target.
|
2022-10-06 14:49:39 +00:00
|
|
|
set(RUST_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/release>)
|
2023-02-03 06:59:24 +00:00
|
|
|
set(KERNEL ${RUST_OUTPUTS}/obkrnl${CMAKE_EXECUTABLE_SUFFIX})
|
2022-10-06 14:49:39 +00:00
|
|
|
|
2022-09-21 13:19:35 +00:00
|
|
|
if(WIN32)
|
2022-10-06 14:49:39 +00:00
|
|
|
set(LIBCORE ${RUST_OUTPUTS}/core.lib)
|
2022-09-21 13:19:35 +00:00
|
|
|
else()
|
2022-10-06 14:49:39 +00:00
|
|
|
set(LIBCORE ${RUST_OUTPUTS}/libcore.a)
|
2022-09-21 13:19:35 +00:00
|
|
|
endif()
|
|
|
|
|
2022-10-06 14:49:39 +00:00
|
|
|
ExternalProject_Add(core
|
2022-09-18 02:57:50 +00:00
|
|
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
CONFIGURE_COMMAND ""
|
2022-12-03 02:56:47 +00:00
|
|
|
BUILD_COMMAND cargo build $<IF:$<CONFIG:Debug>,--profile=dev,--release>
|
2022-09-18 02:57:50 +00:00
|
|
|
BUILD_IN_SOURCE ON
|
|
|
|
BUILD_ALWAYS ON
|
2022-10-06 14:49:39 +00:00
|
|
|
BUILD_BYPRODUCTS ${KERNEL} ${LIBCORE}
|
2022-09-18 02:57:50 +00:00
|
|
|
INSTALL_COMMAND ""
|
|
|
|
TEST_COMMAND cargo test
|
|
|
|
TEST_EXCLUDE_FROM_MAIN ON)
|
|
|
|
|
2023-09-03 09:39:47 +00:00
|
|
|
if(OB_BUILD_LLVM)
|
|
|
|
add_dependencies(core llvm)
|
|
|
|
endif()
|
2023-02-26 19:22:42 +00:00
|
|
|
|
2022-09-15 21:29:53 +00:00
|
|
|
# Setup application target.
|
2023-07-31 16:40:29 +00:00
|
|
|
add_executable(obliteration WIN32 MACOSX_BUNDLE
|
2023-02-06 16:36:05 +00:00
|
|
|
ansi_escape.cpp
|
2022-10-16 14:07:56 +00:00
|
|
|
app_data.cpp
|
2023-10-09 10:50:29 +00:00
|
|
|
core.cpp
|
2024-01-27 11:08:00 +00:00
|
|
|
game_graphic_settings.cpp
|
2022-09-17 08:03:04 +00:00
|
|
|
game_models.cpp
|
2022-09-18 10:07:45 +00:00
|
|
|
game_settings.cpp
|
2022-09-18 09:31:53 +00:00
|
|
|
game_settings_dialog.cpp
|
2023-02-16 18:47:18 +00:00
|
|
|
initialize_wizard.cpp
|
2023-02-06 16:36:05 +00:00
|
|
|
log_formatter.cpp
|
2022-09-16 02:12:25 +00:00
|
|
|
main.cpp
|
|
|
|
main_window.cpp
|
2022-10-23 12:43:35 +00:00
|
|
|
path.cpp
|
2022-10-02 21:26:37 +00:00
|
|
|
progress_dialog.cpp
|
2022-09-19 07:08:26 +00:00
|
|
|
resources.qrc
|
2022-09-20 14:50:30 +00:00
|
|
|
settings.cpp
|
2022-10-23 12:43:35 +00:00
|
|
|
system.cpp
|
2023-02-22 16:27:31 +00:00
|
|
|
system_downloader.cpp
|
2023-07-31 13:12:47 +00:00
|
|
|
update_firmware.cpp)
|
2022-09-15 21:29:53 +00:00
|
|
|
|
2022-10-01 18:33:26 +00:00
|
|
|
if(WIN32)
|
|
|
|
target_sources(obliteration PRIVATE resources.rc)
|
2023-08-05 12:04:58 +00:00
|
|
|
elseif(APPLE)
|
|
|
|
target_sources(obliteration PRIVATE resources/obliteration.icns)
|
2022-10-01 18:33:26 +00:00
|
|
|
endif()
|
|
|
|
|
2022-10-06 14:49:39 +00:00
|
|
|
add_dependencies(obliteration core)
|
2022-09-18 02:57:50 +00:00
|
|
|
|
2022-10-05 17:02:47 +00:00
|
|
|
set_target_properties(obliteration PROPERTIES AUTOMOC ON AUTORCC ON)
|
|
|
|
|
2023-08-05 12:04:58 +00:00
|
|
|
if(WIN32)
|
2022-10-05 17:02:47 +00:00
|
|
|
set_target_properties(obliteration PROPERTIES OUTPUT_NAME Obliteration)
|
|
|
|
endif()
|
2022-09-15 21:29:53 +00:00
|
|
|
|
2023-07-31 16:40:29 +00:00
|
|
|
if(APPLE)
|
2023-08-05 12:04:58 +00:00
|
|
|
set_target_properties(obliteration PROPERTIES
|
|
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER io.github.obhq.obliteration
|
|
|
|
MACOSX_BUNDLE_BUNDLE_NAME Obliteration
|
|
|
|
MACOSX_BUNDLE_BUNDLE_VERSION 0.1.0
|
|
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING 0.1.0
|
|
|
|
MACOSX_BUNDLE_COPYRIGHT "Copyright © 2023 Obliteration Contributors"
|
|
|
|
MACOSX_BUNDLE_ICON_FILE obliteration
|
|
|
|
RESOURCE resources/obliteration.icns)
|
2023-07-31 16:40:29 +00:00
|
|
|
endif()
|
|
|
|
|
2022-09-15 21:29:53 +00:00
|
|
|
target_compile_features(obliteration PRIVATE cxx_std_17)
|
|
|
|
|
2022-09-24 09:01:22 +00:00
|
|
|
target_link_libraries(obliteration PRIVATE Qt6::Widgets)
|
2022-09-18 07:04:02 +00:00
|
|
|
target_link_libraries(obliteration PRIVATE Threads::Threads)
|
2022-09-27 12:48:37 +00:00
|
|
|
target_link_libraries(obliteration PRIVATE ${LIBCORE})
|
2022-09-15 05:31:45 +00:00
|
|
|
|
2022-09-18 07:04:02 +00:00
|
|
|
if(WIN32)
|
2023-06-10 09:24:26 +00:00
|
|
|
target_link_libraries(obliteration PRIVATE bcrypt imm32 ntdll setupapi userenv version winmm ws2_32)
|
2022-09-18 07:30:25 +00:00
|
|
|
else()
|
|
|
|
target_link_libraries(obliteration PRIVATE ${CMAKE_DL_LIBS})
|
2022-09-18 07:04:02 +00:00
|
|
|
endif()
|
2022-09-24 10:20:29 +00:00
|
|
|
|
|
|
|
# Setup installation.
|
|
|
|
if(WIN32)
|
|
|
|
install(TARGETS obliteration DESTINATION .)
|
|
|
|
else()
|
2023-08-05 12:04:58 +00:00
|
|
|
install(TARGETS obliteration BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
install(SCRIPT deploy-win32.cmake)
|
|
|
|
elseif(APPLE)
|
|
|
|
qt_generate_deploy_app_script(
|
|
|
|
TARGET obliteration
|
|
|
|
OUTPUT_SCRIPT QT_DEPLOY_SCRIPT
|
|
|
|
NO_TRANSLATIONS
|
|
|
|
NO_COMPILER_RUNTIME)
|
|
|
|
|
|
|
|
install(SCRIPT ${QT_DEPLOY_SCRIPT})
|
2022-09-24 10:20:29 +00:00
|
|
|
endif()
|
|
|
|
|
2023-08-05 12:04:58 +00:00
|
|
|
if(APPLE)
|
|
|
|
install(PROGRAMS ${KERNEL} DESTINATION obliteration.app/Contents/MacOS)
|
|
|
|
else()
|
|
|
|
install(PROGRAMS ${KERNEL} TYPE BIN)
|
|
|
|
endif()
|