obliteration/src/CMakeLists.txt

148 lines
4.3 KiB
CMake
Raw Normal View History

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.
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()
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
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.
set(RUST_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/release>)
set(KERNEL ${RUST_OUTPUTS}/obkrnl${CMAKE_EXECUTABLE_SUFFIX})
if(WIN32)
set(LIBCORE ${RUST_OUTPUTS}/core.lib)
else()
set(LIBCORE ${RUST_OUTPUTS}/libcore.a)
endif()
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
BUILD_BYPRODUCTS ${KERNEL} ${LIBCORE}
2022-09-18 02:57:50 +00:00
INSTALL_COMMAND ""
TEST_COMMAND cargo test
TEST_EXCLUDE_FROM_MAIN ON)
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
ansi_escape.cpp
2022-10-16 14:07:56 +00:00
app_data.cpp
2023-10-09 10:50:29 +00:00
core.cpp
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
initialize_wizard.cpp
log_formatter.cpp
main.cpp
main_window.cpp
path.cpp
progress_dialog.cpp
resources.qrc
2022-09-20 14:50:30 +00:00
settings.cpp
system.cpp
system_downloader.cpp
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)
elseif(APPLE)
target_sources(obliteration PRIVATE resources/obliteration.icns)
2022-10-01 18:33:26 +00:00
endif()
add_dependencies(obliteration core)
2022-09-18 02:57:50 +00:00
set_target_properties(obliteration PROPERTIES AUTOMOC ON AUTORCC ON)
if(WIN32)
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)
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)
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()
# Setup installation.
if(WIN32)
install(TARGETS obliteration DESTINATION .)
else()
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})
endif()
if(APPLE)
install(PROGRAMS ${KERNEL} DESTINATION obliteration.app/Contents/MacOS)
else()
install(PROGRAMS ${KERNEL} TYPE BIN)
endif()