### Installation of binaries and resources Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Installs the main binary targets and optionally the crashpad handler, along with resources on non-macOS systems. ```cmake list(APPEND BINARY_TARGETS dusklight) set(EXTRA_TARGETS "") if (TARGET crashpad_handler) list(APPEND EXTRA_TARGETS crashpad_handler) endif () install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}) aurora_install_runtime_dlls(dusklight ${CMAKE_INSTALL_PREFIX}) if (NOT APPLE) install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX}) endif () ``` -------------------------------- ### macOS CMake and Python Installation Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Installs CMake and Python 3 on macOS using Homebrew. ```sh brew install cmake brew install python@3 ``` -------------------------------- ### Ubuntu Dependencies Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Installs required dependencies for Dusklight on Ubuntu 24.04+. ```sh sudo apt update && sudo apt install -y \ build-essential \ clang \ cmake \ curl \ git \ libasound2-dev \ libclang-dev \ libcurl4-openssl-dev \ libdbus-1-dev \ libfreetype-dev \ libglu1-mesa-dev \ libgtk-3-dev \ libncurses5-dev \ libpng-dev \ libpulse-dev \ libudev-dev \ libvulkan-dev \ libx11-xcb-dev \ libxcursor-dev \ libxi-dev \ libxinerama-dev \ libxrandr-dev \ libxss-dev \ libxtst-dev \ lld \ ninja-build \ python-is-python3 \ python3 \ python3-markupsafe \ zlib1g-dev ``` -------------------------------- ### Fedora Dependencies Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Installs required dependencies for Dusklight on Fedora. ```sh sudo dnf install -y \ clang-devel \ cmake \ libpng-devel \ llvm-devel \ ninja-build \ vulkan-headers sudo dnf groupinstall \ "Development Libraries" "Development Tools" ``` -------------------------------- ### Arch Linux Dependencies Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Installs required dependencies for Dusklight on Arch Linux. ```sh sudo pacman -S --needed \ alsa-lib \ base-devel \ clang \ cmake \ freetype2 \ libpulse \ libxrandr \ lld \ llvm \ ninja \ python \ python-markupsafe \ vulkan-headers ``` -------------------------------- ### Debug symbol installation Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Installs debug symbols (PDB, dSYM, or .dbg files) and creates archives for them in Debug or RelWithDebInfo build types. ```cmake if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) set(DEBUG_FILES_LIST "") foreach (target IN LISTS BINARY_TARGETS EXTRA_TARGETS) get_target_output_name(${target} output_name) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX} OPTIONAL) elseif (APPLE) get_target_prefix(${target} target_prefix) install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND rm -fr \"$.dSYM\")") install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND dsymutil \"${target_prefix}$\")") install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND strip -S \"${target_prefix}$\")") if (NOT target_prefix STREQUAL "") install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND mv \"${target_prefix}$.dSYM\" .)") endif () elseif (UNIX) get_target_prefix(${target} target_prefix) install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND objcopy --only-keep-debug \"${target_prefix}$\" \"${target_prefix}$.dbg\")") install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND objcopy --strip-debug --add-gnu-debuglink=$.dbg \"${target_prefix}$\")") endif () list(APPEND DEBUG_FILES_LIST "${output_name}") endforeach () # This is a terrible hack to only run this on CI # until I turn this into a script or something if(DEFINED ENV{GITHUB_ENV}) if (WIN32) list(TRANSFORM DEBUG_FILES_LIST APPEND ".pdb") list(JOIN DEBUG_FILES_LIST " " DEBUG_FILES) install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND 7z a -t7z \"${CMAKE_INSTALL_PREFIX}/debug.7z\" ${DEBUG_FILES})") elseif (APPLE) list(TRANSFORM DEBUG_FILES_LIST APPEND ".dSYM") list(JOIN DEBUG_FILES_LIST " " DEBUG_FILES) install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND tar acfv \"${CMAKE_INSTALL_PREFIX}/debug.tar.xz\" ${DEBUG_FILES})") elseif (UNIX) list(TRANSFORM DEBUG_FILES_LIST APPEND ".dbg") list(JOIN DEBUG_FILES_LIST " " DEBUG_FILES) install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND tar -I \"xz -9 -T0\" -cvf \"${CMAKE_INSTALL_PREFIX}/debug.tar.xz\" ${DEBUG_FILES})") endif () endif () endif () ``` -------------------------------- ### get_target_prefix function Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt A CMake function to determine the installation prefix for a target, with special handling for macOS bundles. ```cmake function(get_target_prefix target result_var) set(${result_var} "" PARENT_SCOPE) if (APPLE) # Have to recreate some bundle logic here, since CMake can't tell us get_target_property(is_bundle ${target} MACOSX_BUNDLE) if (is_bundle) get_target_output_name(${target} output_name) if (CMAKE_SYSTEM_NAME STREQUAL Darwin) set(${result_var} "${output_name}.app/Contents/MacOS/" PARENT_SCOPE) else () set(${result_var} "${output_name}.app/" PARENT_SCOPE) endif () endif () endif () endfunction() ``` -------------------------------- ### Dusk-specific code indication Source: https://github.com/twilitrealm/dusklight/blob/main/docs/code-conventions.md Example of how to indicate code that is specific to Dusk's purposes using preprocessor directives. ```c++ #if TARGET_PC // Dusk-specific code here #endif #if AVOID_UB // Undefined Behavior fixes here #endif ``` -------------------------------- ### Clone and Initialize Dusklight Repository Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Clones the Dusklight repository and its submodules. ```sh git clone --recursive https://github.com/TwilitRealm/dusklight.git git pull cd dusklight git submodule update --init --recursive ``` -------------------------------- ### Build with ninja on Linux Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Builds the Dusklight project using CMake presets on Linux. ```sh cmake --preset linux-default-relwithdebinfo cmake --build --preset linux-default-relwithdebinfo ``` -------------------------------- ### Running Dusklight on Windows/Linux Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Command to run Dusklight on Windows and Linux, passing the disc image. ```sh build/{preset}/dusklight --dvd /path/to/game.iso ``` -------------------------------- ### libjpeg-turbo Fetching and Configuration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Fetches and configures libjpeg-turbo if DUSK_MOVIE_SUPPORT is enabled and the system package is not found. ```cmake if (DUSK_MOVIE_SUPPORT) find_package(libjpeg-turbo 3.0 CONFIG QUIET) if (libjpeg-turbo_FOUND) message(STATUS "dusklight: Using system libjpeg-turbo") else () message(STATUS "dusklight: Fetching libjpeg-turbo") include(ExternalProject) set(_jpeg_install_dir ${CMAKE_BINARY_DIR}/libjpeg-turbo-install) if (WIN32) set(_jpeg_lib ${_jpeg_install_dir}/lib/turbojpeg-static.lib) else () set(_jpeg_lib ${_jpeg_install_dir}/lib/libturbojpeg.a) endif () set(_jpeg_cmake_args -DCMAKE_INSTALL_PREFIX=${_jpeg_install_dir} -DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsTargetProcessor.cmake -DENABLE_SHARED=OFF -DWITH_TURBOJPEG=ON -DWITH_JAVA=OFF ) if (CMAKE_TOOLCHAIN_FILE) get_filename_component(_jpeg_toolchain_file "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}") list(APPEND _jpeg_cmake_args -DCMAKE_TOOLCHAIN_FILE=${_jpeg_toolchain_file}) endif () set(_jpeg_passthrough_vars ANDROID_ABI ANDROID_PLATFORM CMAKE_BUILD_TYPE CMAKE_C_COMPILER CMAKE_C_COMPILER_LAUNCHER CMAKE_MAKE_PROGRAM CMAKE_MSVC_RUNTIME_LIBRARY CMAKE_MSVC_DEBUG_INFORMATION_FORMAT CMAKE_OSX_ARCHITECTURES DEPLOYMENT_TARGET ENABLE_ARC ENABLE_BITCODE PLATFORM ) foreach(_var IN LISTS _jpeg_passthrough_vars) if (DEFINED ${_var}) list(APPEND _jpeg_cmake_args -D${_var}=${${_var}}) endif () endforeach () ExternalProject_Add(libjpeg-turbo-ext URL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/3.1.0.tar.gz URL_HASH SHA256=35fec2e1ddfb05ecf6d93e50bc57c1e54bc81c16d611ddf6eff73fff266d8285 CMAKE_ARGS ${_jpeg_cmake_args} BUILD_BYPRODUCTS ${_jpeg_lib} ) file(MAKE_DIRECTORY ${_jpeg_install_dir}/include) add_library(libjpeg-turbo::turbojpeg-static STATIC IMPORTED GLOBAL) set_target_properties(libjpeg-turbo::turbojpeg-static PROPERTIES IMPORTED_LOCATION ${_jpeg_lib} INTERFACE_INCLUDE_DIRECTORIES ${_jpeg_install_dir}/include ) add_dependencies(libjpeg-turbo::turbojpeg-static libjpeg-turbo-ext) endif () endif () ``` -------------------------------- ### Basic CMake Settings Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets standard C and C++ versions, requires C++20, enables position-independent code, and sets Windows export symbols. ```cmake set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) ``` -------------------------------- ### Set Project and Version Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets the project name to 'dusklight' and defines the version string. ```cmake project(dusklight LANGUAGES C CXX VERSION ${DUSK_VERSION_STRING}) ``` -------------------------------- ### Build with ninja on Windows (MSVC) Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Builds the Dusklight project using CMake presets on Windows with MSVC. ```sh cmake --preset windows-msvc-relwithdebinfo cmake --build --preset windows-msvc-relwithdebinfo ``` -------------------------------- ### Version Header Configuration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Configures the version.h file from a template. ```cmake configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h) ``` -------------------------------- ### Build with ninja on macOS Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Builds the Dusklight project using CMake presets on macOS. ```sh cmake --preset macos-default-relwithdebinfo cmake --build --preset macos-default-relwithdebinfo ``` -------------------------------- ### Project Version and Bundle Information Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets basic project metadata including name, identifier, company, and copyright. ```cmake set(DUSK_BUNDLE_NAME Dusklight) set(DUSK_BUNDLE_IDENTIFIER dev.twilitrealm.dusk) set(DUSK_COMPANY_NAME "Twilit Realm") set(DUSK_FILE_DESCRIPTION "Dusklight") set(DUSK_PRODUCT_NAME "Dusklight") set(DUSK_COPYRIGHT "Copyright (C) Twilit Realm contributors") ``` -------------------------------- ### Running Dusklight on macOS Source: https://github.com/twilitrealm/dusklight/blob/main/docs/building.md Command to run Dusklight on macOS, passing the disc image. ```sh build/{preset}/Dusklight.app/Contents/MacOS/Dusklight --dvd /path/to/game.iso ``` -------------------------------- ### Copying Resources on Non-Apple Platforms Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets up a post-build command to copy the 'res' directory to the output directory for non-Apple platforms. ```cmake if (NOT APPLE) add_custom_command(TARGET dusklight POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/res" "$/res" COMMENT "Copying resources" ) endif () ``` -------------------------------- ### Fetch and Make Available Dependencies Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Declares and fetches external dependencies like cxxopts and nlohmann/json, then makes them available for use. ```cmake message(STATUS "dusklight: Fetching cxxopts") FetchContent_Declare(cxxopts URL https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.3.1.tar.gz URL_HASH SHA256=3bfc70542c521d4b55a46429d808178916a579b28d048bd8c727ee76c39e2072 DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) message(STATUS "dusklight: Fetching nlohmann/json") FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz URL_HASH SHA256=42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) FetchContent_MakeAvailable(cxxopts json) ``` -------------------------------- ### Launch With Runtime Args (adb) Source: https://github.com/twilitrealm/dusklight/blob/main/platforms/android/README.md Launch the DuskActivity using adb and pass runtime arguments through intent extras. ```bash adb shell am start -n dev.twilitrealm.dusk/.DuskActivity \ --es dusk_args "--backend vulkan" ``` -------------------------------- ### Build APK Source: https://github.com/twilitrealm/dusklight/blob/main/platforms/android/README.md Navigate to the android directory and build the debug APK using Gradle. ```bash cd android ./gradlew :app:assembleDebug ``` -------------------------------- ### Precompiling Headers for Dusklight Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Configures dusklight to precompile specific headers for C++ compilation. ```cmake target_precompile_headers(dusklight PRIVATE "<$:${CMAKE_SOURCE_DIR}/include/dusk_pch.hpp>") ``` -------------------------------- ### Apple Platform Resource Handling Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets resource directories and files for Apple platforms (iOS, tvOS, macOS) and adds them as sources. ```cmake if (APPLE) if (IOS) set(DUSK_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios) elseif (TVOS) set(DUSK_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/tvos) else () set(DUSK_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/macos) endif () set(DUSK_INFO_PLIST ${DUSK_RESOURCE_DIR}/Info.plist.in) file(GLOB_RECURSE DUSK_RESOURCE_FILES "${DUSK_RESOURCE_DIR}/Assets.car" "${DUSK_RESOURCE_DIR}/Base.lproj/*" "${DUSK_RESOURCE_DIR}/Dusklight.icns") file(GLOB_RECURSE DUSK_APP_RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/res/*") target_sources(dusklight PRIVATE ${DUSK_RESOURCE_FILES}) target_sources(dusklight PRIVATE ${DUSK_APP_RESOURCE_FILES}) foreach (FILE ${DUSK_RESOURCE_FILES}) file(RELATIVE_PATH NEW_FILE "${DUSK_RESOURCE_DIR}" ${FILE}) get_filename_component(NEW_FILE_PATH ${FILE} DIRECTORY) ``` -------------------------------- ### Finding Required Packages and Libraries Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Finds and links necessary external libraries and packages for the project. ```cmake find_package(Threads REQUIRED) set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd aurora::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt Threads::Threads) list(APPEND GAME_LIBS libzstd_static) ``` -------------------------------- ### Linking Dusklight Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets compile definitions, include directories, and link libraries for the dusklight target. ```cmake target_compile_definitions(dusklight PRIVATE ${GAME_COMPILE_DEFS}) target_include_directories(dusklight PRIVATE ${GAME_INCLUDE_DIRS}) target_link_libraries(dusklight PRIVATE aurora::main ${GAME_LIBS} ${JSYSTEM_LINK_LIBRARIES}) ``` -------------------------------- ### macOS Bundle Properties Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets macOS bundle properties for the dusklight target. ```cmake set_target_properties( dusklight PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_BUNDLE_NAME ${DUSK_BUNDLE_NAME} MACOSX_BUNDLE_GUI_IDENTIFIER ${DUSK_BUNDLE_IDENTIFIER} MACOSX_BUNDLE_BUNDLE_VERSION ${DUSK_VERSION_STRING} MACOSX_BUNDLE_SHORT_VERSION_STRING ${DUSK_SHORT_VERSION_STRING} MACOSX_BUNDLE_INFO_PLIST ${DUSK_INFO_PLIST} OUTPUT_NAME Dusklight XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "YES" XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES" ) ``` -------------------------------- ### Build Native Libraries Source: https://github.com/twilitrealm/dusklight/blob/main/platforms/android/README.md Build native libraries for arm64-v8a and x86_64 architectures using CMake presets. ```bash cmake --preset android-arm64 cmake --build --preset android-arm64 cmake --preset android-x86_64 cmake --build --preset android-x86_64 ``` -------------------------------- ### Edit & Continue Configuration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Configures MSVC specific settings for Edit and Continue debugging. ```cmake if (MSVC) if ("${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}" STREQUAL "" AND CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue") endif () if (CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "EditAndContinue") add_link_options("/INCREMENTAL") endif () endif () ``` -------------------------------- ### freeverb CMakeLists.txt Source: https://github.com/twilitrealm/dusklight/blob/main/libs/freeverb/CMakeLists.txt CMakeLists.txt file to build the freeverb library. ```cmake cmake_minimum_required(VERSION 3.10) project(freeverb LANGUAGES CXX) add_library(freeverb comb.cpp allpass.cpp revmodel.cpp ) ``` -------------------------------- ### Sentry Configuration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets the Sentry Data Source Name (DSN) and environment. ```cmake set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN") set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment") ``` -------------------------------- ### Adding Crashpad Handler Dependency and Copy Command Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Adds a dependency on the 'crashpad_handler' target and sets up a post-build command to copy the handler if it exists. ```cmake if (TARGET crashpad_handler) add_dependencies(dusklight crashpad_handler) add_custom_command(TARGET dusklight POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" COMMENT "Copying crashpad handler" ) endif () ``` -------------------------------- ### Setting Game Base Files Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Defines the list of source files for the game base, including various sub-modules. ```cmake set(GAME_BASE_FILES ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${REL_FILES} ${DUSK_FILES} ${DOLPHIN_FILES} ) set_source_files_properties( ${GAME_BASE_FILES} PROPERTIES COMPILE_DEFINITIONS "NDEBUG=1;NDEBUG_DEFINED=1;DEBUG_DEFINED=0;$<$:PARTIAL_DEBUG=1>" ) ``` -------------------------------- ### HTTP Backend Configuration for Update Checker Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Selects and configures the HTTP backend for the update checker based on the platform. ```cmake set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/no_backend.cpp) if (DUSK_ENABLE_UPDATE_CHECKER) list(APPEND GAME_COMPILE_DEFS DUSK_ENABLE_UPDATE_CHECKER=1) if (WIN32) set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/winhttp.cpp) list(APPEND GAME_LIBS winhttp) list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_WINHTTP=1) message(STATUS "dusklight: Enabled update checker (WinHTTP)") elseif (ANDROID) set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/android.cpp) list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_ANDROID=1) message(STATUS "dusklight: Enabled update checker (Android)") elseif (APPLE) find_library(FOUNDATION_FRAMEWORK Foundation REQUIRED) set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/url_session.mm) set_source_files_properties(src/dusk/http/url_session.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) list(APPEND GAME_LIBS ${FOUNDATION_FRAMEWORK}) list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_URLSESSION=1) message(STATUS "dusklight: Enabled update checker (NSURLSession)") elseif (CMAKE_SYSTEM_NAME STREQUAL Linux) find_package(CURL QUIET OPTIONAL_COMPONENTS HTTPS SSL) if (CURL_FOUND AND CURL_HTTPS_FOUND AND CURL_SSL_FOUND) set(DUSK_HTTP_BACKEND_SOURCE src/dusk/http/curl.cpp) list(APPEND GAME_LIBS CURL::libcurl) list(APPEND GAME_COMPILE_DEFS DUSK_HTTP_BACKEND_LIBCURL=1) message(STATUS "dusklight: Enabled update checker (libcurl)") else () message(STATUS "dusklight: Disabled update checker (libcurl + HTTPS/SSL not found)") endif () else () message(STATUS "dusklight: Disabled update checker (unsupported platform)") endif () endif () list(APPEND DUSK_FILES ${DUSK_HTTP_BACKEND_SOURCE}) ``` -------------------------------- ### Discord Rich Presence Configuration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Configures Discord Rich Presence support, defaulting to ON and enabling compile definitions if supported platforms. ```cmake set(DUSK_ENABLE_DISCORD_DEFAULT ON) if (DEFINED DUSK_ENABLE_DISCORD_RPC AND NOT DEFINED DUSK_ENABLE_DISCORD) set(DUSK_ENABLE_DISCORD_DEFAULT ${DUSK_ENABLE_DISCORD_RPC}) endif () option(DUSK_ENABLE_DISCORD "Enable Discord Rich Presence support" ${DUSK_ENABLE_DISCORD_DEFAULT}) if (DUSK_ENABLE_DISCORD AND NOT ANDROID AND NOT IOS AND NOT TVOS) list(APPEND GAME_COMPILE_DEFS DUSK_DISCORD=1) endif () ``` -------------------------------- ### iOS UIKit and UniformTypeIdentifiers Framework Linking Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Finds and links UIKit and UniformTypeIdentifiers frameworks for iOS targets. ```cmake if (IOS) find_library(UIKIT_FRAMEWORK UIKit REQUIRED) find_library(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK UniformTypeIdentifiers REQUIRED) target_sources(dusklight PRIVATE src/dusk/ios/FileSelectDialog.m) set_source_files_properties(src/dusk/ios/FileSelectDialog.m PROPERTIES COMPILE_FLAGS -fobjc-arc) target_link_libraries(dusklight PRIVATE ${UIKIT_FRAMEWORK} ${UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK}) endif () ``` -------------------------------- ### Platform Name Configuration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets the PLATFORM_NAME variable based on the detected CMAKE_SYSTEM_NAME. ```cmake if (CMAKE_SYSTEM_NAME STREQUAL Windows) set(PLATFORM_NAME win32) elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin) if (IOS) set(PLATFORM_NAME ios) elseif (TVOS) set(PLATFORM_NAME tvos) else () set(PLATFORM_NAME macos) endif () else () string(TOLOWER CMAKE_SYSTEM_NAME PLATFORM_NAME) endif () ``` -------------------------------- ### Stage Libraries Into APK Project Source: https://github.com/twilitrealm/dusklight/blob/main/platforms/android/README.md Copy the built native libraries into the APK project's jniLibs directory. ```bash ./android/scripts/stage-jni-libs.sh ``` -------------------------------- ### Environment Variables Source: https://github.com/twilitrealm/dusklight/blob/main/platforms/android/README.md Set environment variables for Android SDK, NDK, and JDK. ```bash export ANDROID_HOME="$HOME/Android/Sdk" export ANDROID_NDK_VERSION="29.0.14206865" export JAVA_HOME="/usr/lib/jvm/java-17-openjdk" ``` -------------------------------- ### Game Include Directories Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Lists directories to be searched for include files during compilation. ```cmake set(GAME_INCLUDE_DIRS include src assets/GZ2E01 # TODO: make this dynamic if needed? libs/JSystem/include libs extern/aurora/include/dolphin extern ${CMAKE_BINARY_DIR}) ``` -------------------------------- ### Defining Dusklight Executable/Library Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Defines the DUSK_FILES and adds either a shared library for Android or an executable for other platforms named 'dusklight'. ```cmake set(DUSK_FILES src/dusk/main.cpp ${GAME_BASE_FILES} ${GAME_DEBUG_FILES}) if(ANDROID) add_library(dusklight SHARED ${DUSK_FILES}) set_target_properties(dusklight PROPERTIES OUTPUT_NAME main) else () add_executable(dusklight ${DUSK_FILES}) endif () ``` -------------------------------- ### Configuring JSystem Libraries Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Iterates through JSYSTEM_LIBRARIES to set compile definitions, include directories, and link libraries, and sets the folder property. ```cmake foreach(jsystem_lib IN LISTS JSYSTEM_LIBRARIES) target_compile_definitions(${jsystem_lib} PRIVATE ${GAME_COMPILE_DEFS} $<$:DEBUG=1> $<$:PARTIAL_DEBUG=1> ) target_include_directories(${jsystem_lib} PRIVATE ${GAME_INCLUDE_DIRS}) target_link_libraries(${jsystem_lib} PRIVATE ${GAME_LIBS}) set_target_properties(${jsystem_lib} PROPERTIES FOLDER "JSystem") endforeach() ``` -------------------------------- ### macOS AppKit Framework Linking Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Finds and links the AppKit framework for macOS targets. ```cmake if (APPLE AND NOT IOS AND NOT TVOS) find_library(APPKIT_FRAMEWORK AppKit REQUIRED) target_sources(dusklight PRIVATE src/dusk/file_select_macos.mm) set_source_files_properties(src/dusk/file_select_macos.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) target_link_libraries(dusklight PRIVATE ${APPKIT_FRAMEWORK}) endif () ``` -------------------------------- ### Android Specific Link Option Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Adds a linker option '-Wl,-u,SDL_main' for Android builds to force the inclusion of the SDL_main object. ```cmake if (ANDROID) # SDLActivity loads SDL_main via dlsym on Android. Since aurora::main is a static # archive, force an undefined reference so the linker keeps the SDL_main object. target_link_options(dusklight PRIVATE "-Wl,-u,SDL_main") endif () ``` -------------------------------- ### Game Compile Definitions Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Defines preprocessor macros for game compilation, including target platform and versioning. ```cmake set(GAME_COMPILE_DEFS TARGET_PC WIDESCREEN_SUPPORT=1 AVOID_UB=1 VERSION=0 MTX_USE_PS=1) ``` -------------------------------- ### Windows Specific Resource Generation Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Defines variables and custom commands for generating Windows-specific resources like icons and manifests. ```cmake if (WIN32) set(DUSK_WINDOWS_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/windows) set(DUSK_WINDOWS_ICON_PNG ${CMAKE_CURRENT_SOURCE_DIR}/res/icon.png) set(DUSK_WINDOWS_ICON_ICO ${CMAKE_CURRENT_BINARY_DIR}/dusklight.ico) set(DUSK_WINDOWS_RC ${CMAKE_CURRENT_BINARY_DIR}/dusklight.rc) set(DUSK_WINDOWS_MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/dusklight.manifest) add_custom_command( OUTPUT ${DUSK_WINDOWS_ICON_ICO} COMMAND powershell -ExecutionPolicy Bypass -File ${DUSK_WINDOWS_RESOURCE_DIR}/Create-IcoFromPng.ps1 -InputPng ${DUSK_WINDOWS_ICON_PNG} -OutputIco ${DUSK_WINDOWS_ICON_ICO} DEPENDS ${DUSK_WINDOWS_ICON_PNG} ${DUSK_WINDOWS_RESOURCE_DIR}/Create-IcoFromPng.ps1 VERBATIM COMMENT "Generating Windows icon" ) configure_file(${DUSK_WINDOWS_RESOURCE_DIR}/dusklight.manifest.in ${DUSK_WINDOWS_MANIFEST} @ONLY) configure_file(${DUSK_WINDOWS_RESOURCE_DIR}/dusklight.rc.in ${DUSK_WINDOWS_RC} @ONLY) target_sources(dusklight PRIVATE ${DUSK_WINDOWS_ICON_ICO} ${DUSK_WINDOWS_RC}) set_target_properties(dusklight PROPERTIES WIN32_EXECUTABLE TRUE) if (MSVC) target_link_options(dusklight PRIVATE /MANIFEST:NO) endif () endif () ``` -------------------------------- ### Feature Options Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Defines boolean options for various project features like Wayland support, DVD API, CARD API, RmlUi, compiler warnings, selected optimizations, movie support, update checker, and Sentry integration. ```cmake option(DUSK_BUILD_WARNINGS "Enable compiler warnings (off by default)") option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled with optimizations on Debug, intending to make the game run at 30 FPS. Note for MSVC: you will need to remove '/RTC1' from your debug flags in CMake.") option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) option(DUSK_ENABLE_UPDATE_CHECKER "Enable update checking support" ON) option(DUSK_ENABLE_SENTRY_NATIVE "Enable sentry-native crash reporting support" OFF) ``` -------------------------------- ### Conditional Fetch for Sentry Native Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Conditionally fetches and configures the sentry-native dependency if DUSK_ENABLE_SENTRY_NATIVE is enabled. Sets various build options for sentry-native. ```cmake if (DUSK_ENABLE_SENTRY_NATIVE) message(STATUS "dusklight: Fetching sentry-native") set(SENTRY_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) set(SENTRY_BACKEND crashpad CACHE STRING "" FORCE) if (WIN32) set(SENTRY_TRANSPORT winhttp CACHE STRING "" FORCE) endif () set(SENTRY_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(SENTRY_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(SENTRY_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) FetchContent_Declare(sentry_native GIT_REPOSITORY https://github.com/getsentry/sentry-native.git GIT_TAG 0.13.6 GIT_SHALLOW TRUE GIT_PROGRESS TRUE GIT_SUBMODULES_RECURSE TRUE ) if (NOT sentry_native_POPULATED) FetchContent_Populate(sentry_native) set(_dusk_skip_install_rules ${CMAKE_SKIP_INSTALL_RULES}) set(CMAKE_SKIP_INSTALL_RULES ON) add_subdirectory(${sentry_native_SOURCE_DIR} ${sentry_native_BINARY_DIR} EXCLUDE_FROM_ALL) set(CMAKE_SKIP_INSTALL_RULES ${_dusk_skip_install_rules}) endif () endif () ``` -------------------------------- ### Movie Support Integration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Conditionally adds JPEG library for movie support and sets a compile definition. ```cmake if (DUSK_MOVIE_SUPPORT) if (TARGET libjpeg-turbo::turbojpeg-static) list(APPEND GAME_LIBS libjpeg-turbo::turbojpeg-static) else () list(APPEND GAME_LIBS libjpeg-turbo::turbojpeg) endif () list(APPEND GAME_COMPILE_DEFS MOVIE_SUPPORT=1) endif () ``` -------------------------------- ### Aurora Copy Runtime DLLs Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Copies runtime DLLs using the Aurora CMake module. ```cmake include(extern/aurora/cmake/AuroraCopyRuntimeDLLs.cmake) aurora_copy_runtime_dlls(dusklight) ``` -------------------------------- ### Set Build Type Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets the default build type if not already defined, allowing options like Debug, Release, RelWithDebInfo, and MinSizeRel. ```cmake if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type options: Debug Release RelWithDebInfo MinSizeRel" FORCE) endif () ``` -------------------------------- ### Ensuring consistent prefixes for extra targets Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Copies extra targets to the prefix of the main binary targets if their prefixes differ. ```cmake foreach (target IN LISTS BINARY_TARGETS) get_target_prefix(${target} target_prefix) foreach (extra_target IN LISTS EXTRA_TARGETS) get_target_prefix(${extra_target} extra_prefix) if (NOT "${target_prefix}" STREQUAL "${extra_prefix}") # Copy extra target to target prefix install(CODE "execute_process(WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" COMMAND cp \"${extra_prefix}$\" \"${target_prefix}$\")") endif () endforeach () endforeach () ``` -------------------------------- ### Generator Properties Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Configures Visual Studio and Xcode generators for folder-based organization of targets. ```cmake set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_cmake") ``` -------------------------------- ### Linux Compiler Flags Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets specific C and C++ compiler flags for Linux builds. ```cmake if (CMAKE_SYSTEM_NAME STREQUAL Linux) # -Wno-multichar: Multi-character constants ('ABCD') are implementation-defined but all compilers # (CW, GCC, Clang, MSVC) encode them identically in big-endian order. # For >4-char literals (which GCC/Clang truncate to int), use the MULTI_CHAR() macro. # -Wwrite-strings: Game code relies on implicit const char* -> char* conversions # -Wdeprecated-declarations: JSystem uses std::iterator, deprecated in C++17 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar -Wno-write-strings") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar -Wno-write-strings -Wno-trigraphs -Wno-deprecated-declarations") set(CMAKE_INSTALL_RPATH "$ORIGIN") set(CMAKE_BUILD_RPATH "$ORIGIN") elseif (APPLE) add_compile_options(-Wno-declaration-after-statement -Wno-non-pod-varargs) set(CMAKE_INSTALL_RPATH "$ORIGIN") set(CMAKE_BUILD_RPATH "$ORIGIN") elseif (MSVC) add_compile_options( $<$:/bigobj> $<$:/Zc:strictStrings-> $<$:/MP> $<$:/FS> ) if (NOT DUSK_BUILD_WARNINGS) add_compile_options($<$:/W0>) else () # Disable warnings add_compile_options($<$:/wd4068>) add_compile_options($<$:/wd4291>) # Only show warnings once add_compile_options($<$:/wo4244>) endif () add_compile_options($<$:/utf-8>) endif () ``` -------------------------------- ### Refresh SDL Java Shim Source: https://github.com/twilitrealm/dusklight/blob/main/platforms/android/README.md Optional script to refresh embedded Java shim files if SDL is updated. ```bash ./android/scripts/sync-sdl-java.sh ``` -------------------------------- ### Signed Char Option for ARM Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Adds the -fsigned-char compile option for ARM architectures when using the GNU compiler frontend to match original game behavior. ```cmake string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _arch) if(_arch MATCHES "^(arm|aarch64)" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") add_compile_options(-fsigned-char) endif() ``` -------------------------------- ### Version Override Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Allows overriding the version string, bypassing git detection and format validation. ```cmake set(DUSK_VERSION_OVERRIDE "" CACHE STRING "Override version string (skips git detection and format validation)") if (DUSK_VERSION_OVERRIDE) set(DUSK_WC_DESCRIBE "${DUSK_VERSION_OVERRIDE}") set(DUSK_VERSION_STRING "0.0.0.0") set(DUSK_SHORT_VERSION_STRING "0.0.0") set(DUSK_VERSION_CODE "1") set(DUSK_WC_REVISION "") set(DUSK_WC_BRANCH "") set(DUSK_WC_DATE "") message(STATUS "Dusklight version overridden to ${DUSK_WC_DESCRIBE}") else () # obtain revision info from git find_package(Git) if (GIT_FOUND) # make sure version information gets re-run when the current Git HEAD changes execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD OUTPUT_VARIABLE dusk_git_head_filename OUTPUT_STRIP_TRAILING_WHITESPACE) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dusk_git_head_filename}") execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD OUTPUT_VARIABLE dusk_git_head_symbolic OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${dusk_git_head_symbolic} OUTPUT_VARIABLE dusk_git_head_symbolic_filename OUTPUT_STRIP_TRAILING_WHITESPACE) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dusk_git_head_symbolic_filename}") # defines DUSK_WC_REVISION execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE DUSK_WC_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE) # defines DUSK_WC_DESCRIBE execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty --match "v*" OUTPUT_VARIABLE DUSK_WC_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE) # remove the git hash, then collapse a clean "-0" suffix only string(REGEX REPLACE "-[^-]+(-dirty|)$" "\1" DUSK_WC_DESCRIBE "${DUSK_WC_DESCRIBE}") string(REGEX REPLACE "-0$" "" DUSK_WC_DESCRIBE "${DUSK_WC_DESCRIBE}") # defines DUSK_WC_BRANCH execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE DUSK_WC_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE) # defines DUSK_WC_DATE execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad OUTPUT_VARIABLE DUSK_WC_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) else () message(STATUS "Unable to find git, commit information will not be available") endif () if (DUSK_WC_DESCRIBE MATCHES "^v([0-9]+)\.([0-9]+)\.([0-9]+)([-+].*)?$") set(DUSK_SHORT_VERSION_STRING "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") set(_ver_major ${CMAKE_MATCH_1}) set(_ver_minor ${CMAKE_MATCH_2}) set(_ver_patch ${CMAKE_MATCH_3}) set(DUSK_VERSION_TWEAK "0") if (DUSK_WC_DESCRIBE MATCHES "^v[0-9]+\.[0-9]+\.[0-9]+-([0-9]+)(-dirty)?$") set(DUSK_VERSION_TWEAK "${CMAKE_MATCH_1}") elseif (DUSK_WC_DESCRIBE MATCHES "^v[0-9]+\.[0-9]+\.[0-9]+-[0-9A-Za-z.-]+-([0-9]+)(-dirty)?$") set(DUSK_VERSION_TWEAK "${CMAKE_MATCH_1}") endif () set(DUSK_VERSION_STRING "${DUSK_SHORT_VERSION_STRING}.${DUSK_VERSION_TWEAK}") if(DUSK_VERSION_TWEAK GREATER 999) set(_tweak 999) else() set(_tweak ${DUSK_VERSION_TWEAK}) endif() # encoding: major*1e7 + minor*1e5 + patch*1e3 + tweak; collision-free for major<210, minor<100, patch<100, tweak<=999 math(EXPR DUSK_VERSION_CODE "${_ver_major} * 10000000 + ${_ver_minor} * 100000 + ${_ver_patch} * 1000 + ${_tweak}") else () set(DUSK_WC_DESCRIBE "UNKNOWN-VERSION") set(DUSK_VERSION_STRING "0.0.0.0") set(DUSK_SHORT_VERSION_STRING "0.0.0") set(DUSK_VERSION_CODE "1") endif () endif () ``` -------------------------------- ### Linux Specific Link Option Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Adds a linker option '--build-id=sha1' for Linux builds. ```cmake if (CMAKE_SYSTEM_NAME STREQUAL Linux) target_link_options(dusklight PRIVATE "-Wl,--build-id=sha1") endif () ``` -------------------------------- ### Optimization Flags Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets optimization flags based on the compiler variant. ```cmake if (DUSK_SELECTED_OPT) if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") set(_opt_flags /O2 /Ob2) elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") set(_opt_flags -O2) endif () target_compile_options(xxhash PRIVATE ${_opt_flags}) target_compile_options(aurora_gx PRIVATE ${_opt_flags}) target_compile_options(freeverb PRIVATE ${_opt_flags}) endif () ``` -------------------------------- ### Setting JSYSTEM Link Libraries with RESCAN Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets the JSYSTEM_LINK_LIBRARIES and conditionally wraps them in a RESCAN group if supported by the linker. ```cmake set(JSYSTEM_LINK_LIBRARIES ${JSYSTEM_LIBRARIES}) if (CMAKE_CXX_LINK_GROUP_USING_RESCAN_SUPPORTED OR CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED) # GNU ld resolves static archives in a single left-to-right pass. The split # JSystem libraries reference each other, so they need a RESCAN group there. set(JSYSTEM_LINK_LIBRARIES "$") endif () ``` -------------------------------- ### Android Target Definition Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Sets a compile definition if the target platform is Android. ```cmake if(ANDROID) list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1) endif () ``` -------------------------------- ### Sentry Native Integration Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Conditionally enables Sentry native error reporting and sets corresponding compile definitions. ```cmake if (DUSK_ENABLE_SENTRY_NATIVE) list(APPEND GAME_LIBS sentry) list(APPEND GAME_COMPILE_DEFS DUSK_ENABLE_SENTRY_NATIVE=1 SENTRY_BUILD_STATIC=1) endif () ``` -------------------------------- ### Source Group Definitions Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Organizes source files into logical groups for better project management in IDEs. ```cmake source_group("dolzel" FILES ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${REL_FILES}) source_group("dusklight" FILES ${DUSK_FILES} ${DUSK_HTTP_BACKEND_FILES}) ``` -------------------------------- ### Windows Specific Libraries and Debugging Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Adds Windows-specific libraries (like Ws2_32, dbghelp) and defines for debug builds. ```cmake if (WIN32) list(APPEND GAME_LIBS Ws2_32) if (CMAKE_BUILD_TYPE STREQUAL Debug) list(APPEND GAME_LIBS dbghelp) list(APPEND GAME_COMPILE_DEFS DUSK_CRASH_DBGHELP=1) endif () endif () ``` -------------------------------- ### Debug-Specific Source Files Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt Defines source files that are specifically compiled with DEBUG and PARTIAL_DEBUG definitions. ```cmake set(GAME_DEBUG_FILES ${SSYSTEM_FILES} src/dusk/audio/DuskAudioSystem.cpp src/dusk/audio/JASCriticalSection.cpp src/dusk/audio/DuskDsp.cpp src/dusk/audio/Adpcm.cpp src/dusk/audio/DspStub.cpp src/dusk/imgui/ImGuiAudio.cpp ) set_source_files_properties( ${GAME_DEBUG_FILES} PROPERTIES COMPILE_DEFINITIONS "$<$:DEBUG=1>;$<$:PARTIAL_DEBUG=1>" ) ``` -------------------------------- ### get_target_output_name function Source: https://github.com/twilitrealm/dusklight/blob/main/CMakeLists.txt A CMake function to retrieve the output name of a target, falling back to the target name if not explicitly set. ```cmake function(get_target_output_name target result_var) get_target_property(output_name ${target} OUTPUT_NAME) if (NOT output_name) set(${result_var} "${target}" PARENT_SCOPE) else () set(${result_var} "${output_name}" PARENT_SCOPE) endif () endfunction() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.