From 0f5fbfabaca5be2302e3ab16e25a8dd7247f4eb5 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 10:20:27 +0100 Subject: [PATCH 01/14] cmake: remove unsupported platform thing, they're now considered unknown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already renamed “unsupported” as “unknown” so it was just by luck we didn't stop the build (what we wanted when changing that). --- cmake/DaemonArchitecture.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/DaemonArchitecture.cmake b/cmake/DaemonArchitecture.cmake index 73962ac408..9485fecd90 100644 --- a/cmake/DaemonArchitecture.cmake +++ b/cmake/DaemonArchitecture.cmake @@ -40,7 +40,7 @@ try_compile(BUILD_RESULT # Setting -Werror in CXXFLAGS would produce errors instead of warning # but that should not break the architecture detection, # so we only print a CMake warning there and use BUILD_LOG content to -# detect unsupported platforms. +# detect unknown platforms. # Catching compilation error is still useful, for example to detect # undefined types, missing header or things like that. # Setting USE_WERROR to ON doesn't print this warning. @@ -60,8 +60,6 @@ if (NOT ARCH) "Missing DAEMON_ARCH, there is a mistake in DaemonArchitecture.cpp\n" "${BUILD_LOG}" ) -elseif(ARCH STREQUAL "unsupported") - message(FATAL_ERROR "Architecture not supported") endif() message(STATUS "Detected architecture: ${ARCH}") From f02d80a9960b0816058caf1a0ec2e09342aa2f32 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Mon, 7 Apr 2025 18:09:46 +0200 Subject: [PATCH 02/14] cmake: make DaemonPlatform, Architecture, Compiler, etc. autonomous and reusable --- CMakeLists.txt | 3 +- cmake/DaemonCompiler/DaemonCompiler.cpp | 1 - cmake/DaemonGame.cmake | 3 +- .../Architecture.cmake} | 10 ++--- .../Architecture/Architecture.cpp} | 11 ----- .../Architecture}/qprocessordetection.h | 0 .../Compiler.cmake} | 6 +-- .../Compiler/Compiler.c} | 0 cmake/DaemonPlatform/Compiler/Compiler.cpp | 1 + .../Compiler/Compiler.sh} | 4 +- .../FileEmbedder.cmake} | 0 cmake/DaemonPlatform/Platform.cmake | 40 +++++++++++++++++++ .../SourceGenerator.cmake} | 6 ++- .../System.cmake} | 5 +-- 14 files changed, 59 insertions(+), 31 deletions(-) delete mode 100644 cmake/DaemonCompiler/DaemonCompiler.cpp rename cmake/{DaemonArchitecture.cmake => DaemonPlatform/Architecture.cmake} (94%) rename cmake/{DaemonArchitecture/DaemonArchitecture.cpp => DaemonPlatform/Architecture/Architecture.cpp} (92%) rename cmake/{DaemonArchitecture => DaemonPlatform/Architecture}/qprocessordetection.h (100%) rename cmake/{DaemonCompiler.cmake => DaemonPlatform/Compiler.cmake} (97%) rename cmake/{DaemonCompiler/DaemonCompiler.c => DaemonPlatform/Compiler/Compiler.c} (100%) create mode 100644 cmake/DaemonPlatform/Compiler/Compiler.cpp rename cmake/{DaemonCompiler/DaemonCompiler.sh => DaemonPlatform/Compiler/Compiler.sh} (97%) rename cmake/{DaemonFileEmbedder.cmake => DaemonPlatform/FileEmbedder.cmake} (100%) create mode 100644 cmake/DaemonPlatform/Platform.cmake rename cmake/{DaemonSourceGenerator.cmake => DaemonPlatform/SourceGenerator.cmake} (95%) rename cmake/{DaemonPlatform.cmake => DaemonPlatform/System.cmake} (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbe9286d94..643aa94d44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,8 +75,7 @@ if (Daemon_OUT) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Daemon_OUT}) endif() -include(DaemonSourceGenerator) -include(DaemonPlatform) +include(DaemonPlatform/Platform) ################################################################################ # Configuration options diff --git a/cmake/DaemonCompiler/DaemonCompiler.cpp b/cmake/DaemonCompiler/DaemonCompiler.cpp deleted file mode 100644 index 4b3d5f846a..0000000000 --- a/cmake/DaemonCompiler/DaemonCompiler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "DaemonCompiler.c" diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index 9cf9ee95cc..487db85420 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -39,8 +39,7 @@ option(BUILD_GAME_NATIVE_DLL "Build the shared library files, mostly useful for option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for better performances by server owners" OFF) include(ExternalProject) -include(DaemonSourceGenerator) -include(DaemonPlatform) +include(DaemonPlatform/Platform) # Do not report unused native compiler if native vms are not built. # If only NACL vms are built, this will be reported in chainloaded build. diff --git a/cmake/DaemonArchitecture.cmake b/cmake/DaemonPlatform/Architecture.cmake similarity index 94% rename from cmake/DaemonArchitecture.cmake rename to cmake/DaemonPlatform/Architecture.cmake index 9485fecd90..ce3cfb7513 100644 --- a/cmake/DaemonArchitecture.cmake +++ b/cmake/DaemonPlatform/Architecture.cmake @@ -25,14 +25,14 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ################################################################################ -# Determine architecture +# Architecture detection. ################################################################################ # When adding a new architecture, look at all the places ARCH is used try_compile(BUILD_RESULT "${CMAKE_BINARY_DIR}" - "${DAEMON_DIR}/cmake/DaemonArchitecture/DaemonArchitecture.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Architecture/Architecture.cpp" CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} OUTPUT_VARIABLE BUILD_LOG ) @@ -46,7 +46,7 @@ try_compile(BUILD_RESULT # Setting USE_WERROR to ON doesn't print this warning. if (NOT BUILD_RESULT) message(WARNING - "Failed to build DaemonArchitecture.cpp\n" + "Failed to build Architecture.cpp\n" "Setting -Werror in CXXFLAGS can produce false positive errors\n" "${BUILD_LOG}" ) @@ -57,12 +57,12 @@ string(REPLACE "DAEMON_ARCH_" "" ARCH "${ARCH_DEFINE}") if (NOT ARCH) message(FATAL_ERROR - "Missing DAEMON_ARCH, there is a mistake in DaemonArchitecture.cpp\n" + "Missing DAEMON_ARCH, there is a mistake in Architecture.cpp\n" "${BUILD_LOG}" ) endif() -message(STATUS "Detected architecture: ${ARCH}") +message(STATUS "Detected target architecture: ${ARCH}") add_definitions(-D${ARCH_DEFINE}) diff --git a/cmake/DaemonArchitecture/DaemonArchitecture.cpp b/cmake/DaemonPlatform/Architecture/Architecture.cpp similarity index 92% rename from cmake/DaemonArchitecture/DaemonArchitecture.cpp rename to cmake/DaemonPlatform/Architecture/Architecture.cpp index b201f4a6be..fc595fb2e5 100644 --- a/cmake/DaemonArchitecture/DaemonArchitecture.cpp +++ b/cmake/DaemonPlatform/Architecture/Architecture.cpp @@ -32,17 +32,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. platforms including ppc64, but we know how to do it for them. */ #include -#include "../../src/common/Endian.h" - -/* qprocessordetection.h will print an error if it fails to detect -endianness and while it is not already set, so the else clause is -outsourced to that qprocessordetection.h file instead. */ - -#if defined(Q3_BIG_ENDIAN) - #define Q_BYTE_ORDER Q_BIG_ENDIAN -#elif defined(Q3_LITTLE_ENDIAN) - #define Q_BYTE_ORDER Q_LITTLE_ENDIAN -#endif /* This source file includes qprocessordetection.h from Qt: diff --git a/cmake/DaemonArchitecture/qprocessordetection.h b/cmake/DaemonPlatform/Architecture/qprocessordetection.h similarity index 100% rename from cmake/DaemonArchitecture/qprocessordetection.h rename to cmake/DaemonPlatform/Architecture/qprocessordetection.h diff --git a/cmake/DaemonCompiler.cmake b/cmake/DaemonPlatform/Compiler.cmake similarity index 97% rename from cmake/DaemonCompiler.cmake rename to cmake/DaemonPlatform/Compiler.cmake index e00480cd24..6fab3a4604 100644 --- a/cmake/DaemonCompiler.cmake +++ b/cmake/DaemonPlatform/Compiler.cmake @@ -25,7 +25,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ################################################################################ -# Determine compiler +# Compiler detection. ################################################################################ # FIXME: Force -W#pragma-messages and -Wno-error @@ -39,7 +39,7 @@ function(detect_daemon_compiler lang) try_compile(BUILD_RESULT "${CMAKE_BINARY_DIR}" - "${DAEMON_DIR}/cmake/DaemonCompiler/DaemonCompiler${${lang}_EXT}" + "${CMAKE_CURRENT_LIST_DIR}/Compiler/Compiler${${lang}_EXT}" CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} OUTPUT_VARIABLE BUILD_LOG ) @@ -47,7 +47,7 @@ function(detect_daemon_compiler lang) get_filename_component(compiler_basename "${CMAKE_${lang}_COMPILER}" NAME) if (NOT BUILD_RESULT) - message(WARNING "Failed to build DaemonCompiler${${lang}_EXT}, relying on CMake builtin detection.") + message(WARNING "Failed to build Compiler${${lang}_EXT}, relying on CMake builtin detection.") set(compiler_name "Unknown") else() set(BUILD_LOG "\n${BUILD_LOG}\n") diff --git a/cmake/DaemonCompiler/DaemonCompiler.c b/cmake/DaemonPlatform/Compiler/Compiler.c similarity index 100% rename from cmake/DaemonCompiler/DaemonCompiler.c rename to cmake/DaemonPlatform/Compiler/Compiler.c diff --git a/cmake/DaemonPlatform/Compiler/Compiler.cpp b/cmake/DaemonPlatform/Compiler/Compiler.cpp new file mode 100644 index 0000000000..41c3f576b6 --- /dev/null +++ b/cmake/DaemonPlatform/Compiler/Compiler.cpp @@ -0,0 +1 @@ +#include "Compiler.c" diff --git a/cmake/DaemonCompiler/DaemonCompiler.sh b/cmake/DaemonPlatform/Compiler/Compiler.sh similarity index 97% rename from cmake/DaemonCompiler/DaemonCompiler.sh rename to cmake/DaemonPlatform/Compiler/Compiler.sh index d93cae3c44..03ad794cc6 100755 --- a/cmake/DaemonCompiler/DaemonCompiler.sh +++ b/cmake/DaemonPlatform/Compiler/Compiler.sh @@ -27,12 +27,12 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Test script not used by the CMake build system. Usage example: -# ./DaemonCompiler.sh gcc +# ./Compiler.sh gcc set -ueo pipefail script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -file_path="${script_dir}/DaemonCompiler.c" +file_path="${script_dir}/Compiler.c" # PNaCl doesn't work with “-o /dev/null” as it uses the output path as a # pattern for temporary files and then the parent folder should be writable. diff --git a/cmake/DaemonFileEmbedder.cmake b/cmake/DaemonPlatform/FileEmbedder.cmake similarity index 100% rename from cmake/DaemonFileEmbedder.cmake rename to cmake/DaemonPlatform/FileEmbedder.cmake diff --git a/cmake/DaemonPlatform/Platform.cmake b/cmake/DaemonPlatform/Platform.cmake new file mode 100644 index 0000000000..58a691f446 --- /dev/null +++ b/cmake/DaemonPlatform/Platform.cmake @@ -0,0 +1,40 @@ +# Daemon BSD Source Code +# Copyright (c) 2025, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +################################################################################ +# Collection of reusable CMake helpers written for the Dæmon engine and related +# projects. +################################################################################ + +# Source generation. +include(${CMAKE_CURRENT_LIST_DIR}/SourceGenerator.cmake) + +# Target detection. +include(${CMAKE_CURRENT_LIST_DIR}/System.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/Architecture.cmake) + +# Compiler detection. +include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake) diff --git a/cmake/DaemonSourceGenerator.cmake b/cmake/DaemonPlatform/SourceGenerator.cmake similarity index 95% rename from cmake/DaemonSourceGenerator.cmake rename to cmake/DaemonPlatform/SourceGenerator.cmake index 3086830d22..7fc6d71090 100644 --- a/cmake/DaemonSourceGenerator.cmake +++ b/cmake/DaemonPlatform/SourceGenerator.cmake @@ -24,9 +24,13 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +################################################################################ +# Source generation and file embedding. +################################################################################ + set(DAEMON_SOURCE_GENERATOR "${CMAKE_CURRENT_LIST_FILE}") get_filename_component(current_list_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(DAEMON_FILE_EMBEDDER "${current_list_dir}/DaemonFileEmbedder.cmake") +set(DAEMON_FILE_EMBEDDER "${current_list_dir}/FileEmbedder.cmake") set(DAEMON_GENERATED_SUBDIR "GeneratedSource") set(DAEMON_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DAEMON_GENERATED_SUBDIR}") diff --git a/cmake/DaemonPlatform.cmake b/cmake/DaemonPlatform/System.cmake similarity index 96% rename from cmake/DaemonPlatform.cmake rename to cmake/DaemonPlatform/System.cmake index a951f2ad47..749fb5a811 100644 --- a/cmake/DaemonPlatform.cmake +++ b/cmake/DaemonPlatform/System.cmake @@ -25,7 +25,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ################################################################################ -# Determine platform +# System detection. ################################################################################ # When adding a new platform, look at all the places WIN32, APPLE and LINUX are used @@ -39,6 +39,3 @@ elseif( NACL ) else() message( FATAL_ERROR "Platform not supported" ) endif() - -include(DaemonArchitecture) -include(DaemonCompiler) From 5326baf6fd8c0ae681d50ecde0f6526844c54316 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 10:13:56 +0100 Subject: [PATCH 03/14] cmake: prefix ARCH and NACL_ARCH with DAEMON --- CMakeLists.txt | 18 ++++++------- cmake/DaemonFlags.cmake | 30 ++++++++++----------- cmake/DaemonGame.cmake | 4 +-- cmake/DaemonNacl.cmake | 10 +++---- cmake/DaemonPlatform/Architecture.cmake | 36 ++++++++++++++----------- 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 643aa94d44..5835efae64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ if (USE_EXTERNAL_DEPS AND NOT NACL) set(DEPS_EXT ".tar.xz") - set(DEPS_ARCH "${ARCH}") + set(DEPS_ARCH "${DAEMON_ARCH}") if (MSVC) set(DEPS_COMPILER msvc) @@ -221,7 +221,7 @@ if (USE_EXTERNAL_DEPS AND NOT NACL) set(DEPS_SYSTEM macos) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64) - if (ARCH STREQUAL arm64) + if (DAEMON_ARCH_arm64) set(DEPS_ARCH amd64) set_deps_dir() @@ -681,10 +681,10 @@ if (BUILD_CLIENT OR WIN32) set(sdlvar_amd64 SDL_CPU_X64) set(sdlvar_armhf SDL_CPU_ARM32) set(sdlvar_arm64 SDL_CPU_ARM64) - if (sdlvar_${ARCH}) - set(${sdlvar_${ARCH}} 1) + if (sdlvar_${DAEMON_ARCH}) + set(${sdlvar_${DAEMON_ARCH}} 1) else() - message("Developer TODO: translate architecture ${ARCH} for SDL") + message("Developer TODO: translate architecture ${DAEMON_ARCH} for SDL") endif() find_package(SDL3 REQUIRED CONFIG) @@ -978,13 +978,13 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/irt_core-${NACL_ARCH}.nexe - ${FULL_OUTPUT_DIR}/irt_core-${NACL_ARCH}.nexe + ${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH}.nexe + ${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH}.nexe ) # Linux uses a bootstrap program to reserve address space if (LINUX OR FREEBSD) - if (ARCH STREQUAL "arm64") + if (DAEMON_ARCH_arm64) add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp) add_dependencies(runtime_deps nacl_helper_bootstrap-armhf) @@ -1008,7 +1008,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Win32 requires nacl_loader_amd64.exe in order to run on Win64 - if (WIN32 AND ARCH STREQUAL i686) + if (WIN32 AND DAEMON_ARCH_i686) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPS_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX} diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index 53c733b555..e10a77e3f1 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -382,7 +382,7 @@ else() endif() endif() - if (NACL AND USE_NACL_SAIGO AND SAIGO_ARCH STREQUAL "arm") + if (NACL AND USE_NACL_SAIGO AND SAIGO_DAEMON_ARCH_arm) # Saigo produces broken arm builds when optimizing them. # See: https://github.com/Unvanquished/Unvanquished/issues/3297 # When setting this clang-specific option, we don't have to care @@ -530,12 +530,12 @@ else() if ("${FLAG_LINKER_PIE}" AND MINGW) # https://github.com/msys2/MINGW-packages/issues/4100 - if (ARCH STREQUAL "i686") + if (DAEMON_ARCH_i686) set_linker_flag("-Wl,-e,_mainCRTStartup") - elseif(ARCH STREQUAL "amd64") + elseif(DAEMON_ARCH_amd64) set_linker_flag("-Wl,-e,mainCRTStartup") else() - message(FATAL_ERROR "Unsupported architecture ${ARCH}") + message(FATAL_ERROR "Unsupported architecture ${DAEMON_ARCH}") endif() endif() endif() @@ -605,7 +605,7 @@ option(USE_CPU_RECOMMENDED_FEATURES "Use some common hardware features like SSE2 # Target options. if (MSVC) - if (ARCH STREQUAL "i686") + if (DAEMON_ARCH_i686) if (USE_CPU_RECOMMENDED_FEATURES) set_c_cxx_flag("/arch:SSE2") # This is the default else() @@ -625,7 +625,7 @@ elseif (NOT NACL) # Running a server with a native executable game is also a valid usage # not requiring the NX bit. - if (ARCH STREQUAL "amd64") + if (DAEMON_ARCH_amd64) # K8 or EM64T minimum: AMD Athlon 64 ClawHammer, Intel Xeon Nocona, Intel Pentium 4 model F (Prescott revision EO), VIA Nano. if (DAEMON_CXX_COMPILER_ICC) set(GCC_GENERIC_ARCH "pentium4") @@ -635,15 +635,15 @@ elseif (NOT NACL) set(GCC_GENERIC_ARCH "x86-64") endif() set(GCC_GENERIC_TUNE "generic") - elseif (ARCH STREQUAL "i686") + elseif (DAEMON_ARCH_i686) # P6 or K6 minimum: Intel Pentium Pro, AMD K6, Via Cyrix III, Via C3. set(GCC_GENERIC_ARCH "i686") set(GCC_GENERIC_TUNE "generic") - elseif (ARCH STREQUAL "arm64") + elseif (DAEMON_ARCH_arm64) # Armv8-A minimum: Cortex-A50. set(GCC_GENERIC_ARCH "armv8-a") set(GCC_GENERIC_TUNE "generic") - elseif (ARCH STREQUAL "armhf") + elseif (DAEMON_ARCH_armhf) # Armv7-A minimum with VFPv3 and optional NEONv1: Cortex-A5. # Hard float ABI (mainstream 32-bit ARM Linux distributions). # An FPU should be explicitly set on recent compilers or this @@ -652,7 +652,7 @@ elseif (NOT NACL) # lacks an FPU set(GCC_GENERIC_ARCH "armv7-a+fp") set(GCC_GENERIC_TUNE "generic-armv7-a") - elseif (ARCH STREQUAL "armel") + elseif (DAEMON_ARCH_armel) # Armv6 minimum with optional VFP: ARM11. # Soft float ABI (previous mainstream 32-bit ARM Linux # distributions, mainstream 32-bit ARM Android distributions). @@ -672,7 +672,7 @@ elseif (NOT NACL) unset(GCC_GENERIC_TUNE) set(GCC_GENERIC_CPU "power5") else() - message(WARNING "Unknown architecture ${ARCH}") + message(WARNING "Unknown architecture ${DAEMON_ARCH}") endif() if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig") @@ -696,18 +696,18 @@ elseif (NOT NACL) endif() if (USE_CPU_RECOMMENDED_FEATURES) - if (ARCH STREQUAL "amd64") + if (DAEMON_ARCH_amd64) # CMPXCHG16B minimum (x86-64-v2): AMD64 revision F. try_c_cxx_flag_werror(MCX16 "-mcx16") - elseif (ARCH STREQUAL "i686") + elseif (DAEMON_ARCH_i686) # SSE2 minimum: Intel Pentium 4 (Prescott), # Intel Pentium M (Banias), AMD K8, Via C7. try_c_cxx_flag_werror(MSSE2 "-msse2") try_c_cxx_flag_werror(MFPMATH_SSE "-mfpmath=sse") - elseif (ARCH STREQUAL "armhf") + elseif (DAEMON_ARCH_armhf) # NEONv1 minimum. try_c_cxx_flag_werror(MFPU_NEON "-mfpu=neon") - elseif (ARCH STREQUAL "armel") + elseif (DAEMON_ARCH_armel) # VFP minimum, hard float with soft float ABI. try_c_cxx_flag_werror(MFPU_VFP "-mfpu=vfp") try_c_cxx_flag_werror(MFLOAT_ABI_SOFTFP "-mfloat-abi=softfp") diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index 487db85420..b5b37fd580 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -70,7 +70,7 @@ include(CMakeParseArguments) # The NaCl SDK only runs on amd64 or i686. if (NOT FORK EQUAL 2) if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME - AND (ARCH STREQUAL "amd64" OR ARCH STREQUAL "i686")) + AND (DAEMON_ARCH_amd64 OR DAEMON_ARCH_i686)) # can be loaded by daemon with vm.[sc]game.type 0 or 1 option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF) @@ -81,7 +81,7 @@ if (NOT FORK EQUAL 2) if (BUILD_GAME_NACL_TARGETS STREQUAL "all") set(NACL_TARGETS "${NACL_ALL_TARGETS}") elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native") - set(NACL_TARGETS "${ARCH}") + set(NACL_TARGETS "${DAEMON_ARCH}") elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none") set(NACL_TARGETS "") else() diff --git a/cmake/DaemonNacl.cmake b/cmake/DaemonNacl.cmake index a763cddb82..abd09e83fc 100644 --- a/cmake/DaemonNacl.cmake +++ b/cmake/DaemonNacl.cmake @@ -31,7 +31,7 @@ option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF) if( NACL ) # Build nexe binary. if(USE_NACL_SAIGO) - # NACL_ARCH is "pnacl" here, NACL_TARGET carries the architecture. + # DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET carries the architecture. if (NACL_TARGET STREQUAL "amd64") add_definitions(-DNACL_BUILD_ARCH=x86) add_definitions(-DNACL_BUILD_SUBARCH=64) @@ -47,7 +47,7 @@ if( NACL ) # Those defines looks to be meaningless to produce arch-independent pexe # with PNaCl but they must be set to anything supported by native builds. # This requirement looks to be a PNaCl bug. - # NACL_ARCH is "pnacl" here, NACL_TARGET is not set. + # DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET is not set. add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=64 ) endif() @@ -63,13 +63,13 @@ else() add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) endif() - if( NACL_ARCH STREQUAL "amd64" ) + if (DAEMON_NACL_ARCH_amd64) add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=64 ) - elseif( NACL_ARCH STREQUAL "i686" ) + elseif (DAEMON_NACL_ARCH_i686) add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=32 ) - elseif( NACL_ARCH STREQUAL "armhf" ) + elseif (DAEMON_NACL_ARCH_armhf) add_definitions( -DNACL_BUILD_ARCH=arm ) else() # NaCl does not support this architecture natively, but these defines must diff --git a/cmake/DaemonPlatform/Architecture.cmake b/cmake/DaemonPlatform/Architecture.cmake index ce3cfb7513..39b401e6f2 100644 --- a/cmake/DaemonPlatform/Architecture.cmake +++ b/cmake/DaemonPlatform/Architecture.cmake @@ -28,7 +28,7 @@ # Architecture detection. ################################################################################ -# When adding a new architecture, look at all the places ARCH is used +# When adding a new architecture, look at all the places DAEMON_ARCH is used. try_compile(BUILD_RESULT "${CMAKE_BINARY_DIR}" @@ -52,32 +52,34 @@ if (NOT BUILD_RESULT) ) endif() -string(REGEX MATCH "DAEMON_ARCH_([a-zA-Z0-9_]+)" ARCH_DEFINE "${BUILD_LOG}") -string(REPLACE "DAEMON_ARCH_" "" ARCH "${ARCH_DEFINE}") +string(REGEX MATCH "DAEMON_ARCH_([a-zA-Z0-9_]+)" DAEMON_ARCH_DEFINE "${BUILD_LOG}") +string(REPLACE "DAEMON_ARCH_" "" DAEMON_ARCH "${DAEMON_ARCH_DEFINE}") -if (NOT ARCH) +set("DAEMON_ARCH_${DAEMON_ARCH}" ON) + +if (NOT DAEMON_ARCH) message(FATAL_ERROR "Missing DAEMON_ARCH, there is a mistake in Architecture.cpp\n" "${BUILD_LOG}" ) endif() -message(STATUS "Detected target architecture: ${ARCH}") +message(STATUS "Detected target architecture: ${DAEMON_ARCH}") -add_definitions(-D${ARCH_DEFINE}) +add_definitions(-D${DAEMON_ARCH_DEFINE}) # This string can be modified without breaking compatibility. -daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${ARCH}\"") +daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") # Modifying NACL_ARCH breaks engine compatibility with nexe game binaries # since NACL_ARCH contributes to the nexe file name. -set(NACL_ARCH "${ARCH}") +set(DAEMON_NACL_ARCH "${DAEMON_ARCH}") if (LINUX OR FREEBSD) set(ARMHF_USAGE arm64 armel) - if (ARCH IN_LIST ARMHF_USAGE) + if (DAEMON_ARCH IN_LIST ARMHF_USAGE) # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. # The nexe is system agnostic so there should be no difference with armel. - set(NACL_ARCH "armhf") + set(DAEMON_NACL_ARCH "armhf") endif() set(BOX64_USAGE ppc64el riscv64) @@ -91,14 +93,16 @@ if (LINUX OR FREEBSD) endif() endif() elseif(APPLE) - if ("${ARCH}" STREQUAL arm64) + if ("${DAEMON_ARCH}" STREQUAL arm64) # You can get emulated NaCl going like this: # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ - set(NACL_ARCH "amd64") + set(DAEMON_NACL_ARCH "amd64") endif() endif() -daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${NACL_ARCH}\"") +set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH}" ON) + +daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"") # NaCl runtime is only available on architectures that have a NaCl loader. set(NACL_RUNTIME_ARCH amd64 i686 armhf) @@ -122,12 +126,12 @@ if (USE_ARCH_INTRINSICS) add_definitions(-DDAEMON_USE_ARCH_INTRINSICS=1) endif() -set_arch_intrinsics(${ARCH}) +set_arch_intrinsics(${DAEMON_ARCH}) set(amd64_PARENT "i686") set(arm64_PARENT "armhf") set(ppc64el_PARENT "ppc64") -if (${ARCH}_PARENT) - set_arch_intrinsics(${${ARCH}_PARENT}) +if (${DAEMON_ARCH}_PARENT) + set_arch_intrinsics(${${DAEMON_ARCH}_PARENT}) endif() From e7b1f4e6022e2548ddadbb6dadc2fa44fd162eb5 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 9 Dec 2025 10:02:19 +0100 Subject: [PATCH 04/14] cmake: extend DaemonPlatform/System to detect host system and target system --- CMakeLists.txt | 54 +++++----- cmake/DaemonFlags.cmake | 26 ++--- cmake/DaemonNacl.cmake | 10 +- cmake/DaemonPlatform/Architecture.cmake | 4 +- cmake/DaemonPlatform/System.cmake | 134 ++++++++++++++++++++++-- cmake/DaemonPlatform/System/System.c | 79 ++++++++++++++ cmake/DaemonPlatform/System/System.sh | 49 +++++++++ freetype.cmake | 2 +- src.cmake | 4 +- srclibs.cmake | 14 +-- 10 files changed, 309 insertions(+), 67 deletions(-) create mode 100644 cmake/DaemonPlatform/System/System.c create mode 100755 cmake/DaemonPlatform/System/System.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 5835efae64..f7ef4faffc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,11 +90,11 @@ if(NOT DAEMON_EXTERNAL_APP) set(NACL_RUNTIME_PATH "" CACHE STRING "Directory containing the NaCl binaries") - if (WIN32) + if (DAEMON_SYSTEM_Windows) # The alternative code is based on non-curses unix terminal functions. set(USE_CURSES ON) else() - if (NOT APPLE) + if (NOT DAEMON_SYSTEM_macOS) # Not supported on macOS because the included version is too old. option(USE_CURSES_NCURSES "Use ncurses instead of PDCursesMod" ON) endif() @@ -199,7 +199,7 @@ endmacro() set(DEFAULT_USE_EXTERNAL_DEPS_LIBS ON) -if (USE_EXTERNAL_DEPS AND NOT NACL) +if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) set(EXTERNAL_DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external_deps" CACHE STRING "Directory in which to store the downloaded dependencies.") set(DEPS_EXT ".tar.xz") @@ -214,10 +214,10 @@ if (USE_EXTERNAL_DEPS AND NOT NACL) set(DEPS_COMPILER default) endif() - if (WIN32) + if (DAEMON_SYSTEM_Windows) set(DEPS_SYSTEM windows) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686) - elseif (APPLE) + elseif (DAEMON_SYSTEM_macOS) set(DEPS_SYSTEM macos) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64) @@ -230,10 +230,10 @@ if (USE_EXTERNAL_DEPS AND NOT NACL) set(DEFAULT_USE_EXTERNAL_DEPS_LIBS OFF) endif() endif() - elseif (LINUX) + elseif (DAEMON_SYSTEM_Linux) set(DEPS_SYSTEM linux) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686 arm64 armhf) - elseif (FREEBSD) + elseif (DAEMON_SYSTEM_FreeBSD) set(DEPS_SYSTEM freebsd) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686) @@ -264,7 +264,7 @@ endif() option(USE_EXTERNAL_DEPS_LIBS "Build and link against libraries from the EXTERNAL_DEPS_DIR" ${DEFAULT_USE_EXTERNAL_DEPS_LIBS}) -if (USE_EXTERNAL_DEPS AND NOT NACL) +if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) if (DEPS_DIR) message(STATUS "Using external deps dir: ${DEPS_DIR}") @@ -462,13 +462,13 @@ endif() # Native client include(DaemonNacl) -if (NACL) +if (DAEMON_SYSTEM_NaCl) add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE}) set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module) else() add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE}) set_target_properties(srclibs-nacl-native PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs") - if (APPLE) + if (DAEMON_SYSTEM_macOS) # Do not error for OSAtomic* deprecation notices target_compile_options(srclibs-nacl-native PRIVATE "-Wno-error=deprecated-declarations") endif() @@ -476,9 +476,9 @@ else() endif() # Base OS libs -if (WIN32) +if (DAEMON_SYSTEM_Windows) set(LIBS_BASE ${LIBS_BASE} winmm ws2_32) -elseif (NACL) +elseif (DAEMON_SYSTEM_NaCl) find_library(NACL_EXCEPTION nacl_exception) find_library(NACL_MINIDUMP minidump_generator) @@ -510,7 +510,7 @@ else() set(LIBS_BASE ${LIBS_BASE} ${CMAKE_DL_LIBS}) find_package(Threads REQUIRED) set(LIBS_BASE ${LIBS_BASE} ${CMAKE_THREAD_LIBS_INIT}) - if (APPLE) + if (DAEMON_SYSTEM_macOS) set(LIBS_CLIENT ${LIBS_CLIENT} "-framework Carbon" "-framework IOKit" "-framework Cocoa") endif() endif() @@ -533,7 +533,7 @@ else() # Look for OpenGL here before we potentially switch to looking for static libs. if (BUILD_CLIENT) - if (LINUX OR FREEBSD) + if (DAEMON_SYSTEM_Linux_COMPATIBILITY) # Set LEGACY OpenGL ABI if the variable is not explictly set. # The backward-incompatible GLVND OpenGL ABI should only be used # by developers who have a good reason to require it. @@ -549,7 +549,7 @@ else() # This code is unreachable since it already errored out at find_package time. # This code only executes if OpenGL is supported, either because the GLVND ABI # is available, either because the LEGACY ABI is available. - if (LINUX OR FREEBSD) + if (DAEMON_SYSTEM_Linux_COMPATIBILITY) if (NOT OPENGL_gl_LIBRARY) # When OpenGL_GL_PREFERENCE is supported and GLVND is available # OPENGL_gl_LIBRARY is expected to be empty. So we can use the @@ -596,7 +596,7 @@ endif() # Prefer static libs if ( USE_STATIC_LIBS ) - if (LINUX OR FREEBSD) + if (DAEMON_SYSTEM_Linux_COMPATIBILITY) set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif() endif() @@ -624,7 +624,7 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} ${CURSESW_LIBRARIES}) include_directories(${CURSESW_INCLUDE_DIR}) else () - if (WIN32) + if (DAEMON_SYSTEM_Windows) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} gdi32 comdlg32) endif() @@ -674,7 +674,7 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT) endif() # SDL, required for all targets on win32 because of iconv and SDL_SetHint(SDL_TIMER_RESOLUTION, 0) -if (BUILD_CLIENT OR WIN32) +if (BUILD_CLIENT OR DAEMON_SYSTEM_Windows) # Use our detected architecture instead of letting SDL do it again # Note that sdlcpu.cmake is only included on a random subset of platforms set(sdlvar_i686 SDL_CPU_X86) @@ -690,7 +690,7 @@ if (BUILD_CLIENT OR WIN32) find_package(SDL3 REQUIRED CONFIG) message("Found SDL3 ${SDL3_VERSION}: ${SDL3_DIR}") - if (WIN32) + if (DAEMON_SYSTEM_Windows) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} SDL3::SDL3) else() set(LIBS_CLIENT ${LIBS_CLIENT} SDL3::SDL3) @@ -702,7 +702,7 @@ if (USE_BREAKPAD) add_definitions(-DUSE_BREAKPAD) include_directories(${LIB_DIR}/breakpad/src) - if (WIN32) + if (DAEMON_SYSTEM_Windows) add_library(srclibs-breakpad-common EXCLUDE_FROM_ALL ${BREAKPAD_COMMON_LIST}) add_library(srclibs-breakpad-crash_generation_server EXCLUDE_FROM_ALL ${BREAKPAD_CRASHGENERATIONSERVER_LIST}) add_library(srclibs-breakpad-exception_handler EXCLUDE_FROM_ALL ${BREAKPAD_EXCEPTIONHANDLER_LIST}) @@ -732,7 +732,7 @@ if (USE_BREAKPAD) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} srclibs-breakpad-exception_handler srclibs-breakpad-crash_generation_client srclibs-breakpad-common) - elseif (LINUX) + elseif (DAEMON_SYSTEM_Linux_COMPATIBILITY) add_library(srclibs-breakpad EXCLUDE_FROM_ALL ${BREAKPAD_LIST}) set_target_properties(srclibs-breakpad PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs") target_compile_definitions(srclibs-breakpad PUBLIC HAVE_GETCONTEXT=1) @@ -747,7 +747,7 @@ option(PREFER_EXTERNAL_LIBS "Tries to use system libs where possible." ON) macro(prefer_package LIB_NAME LIB_CMAKE) if (NOT ${LIB_NAME}_FOUND) - if (PREFER_EXTERNAL_LIBS AND NOT NACL) + if (PREFER_EXTERNAL_LIBS AND NOT DAEMON_SYSTEM_NaCl) find_package(${LIB_NAME}) if (NOT ${LIB_NAME}_FOUND) @@ -879,7 +879,7 @@ endfunction() daemon_write_buildinfo("Engine") -if (NOT NACL) +if (NOT DAEMON_SYSTEM_NaCl) add_library(engine-lib EXCLUDE_FROM_ALL ${PCH_FILE} ${BUILDINFOLIST} ${COMMONLIST} ${ENGINELIST}) target_link_libraries(engine-lib ${LIBS_BASE} ${LIBS_ENGINE_BASE} ${CPP23SupportLibrary}) set_property(TARGET engine-lib APPEND PROPERTY COMPILE_DEFINITIONS BUILD_ENGINE) @@ -983,7 +983,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER ) # Linux uses a bootstrap program to reserve address space - if (LINUX OR FREEBSD) + if (DAEMON_SYSTEM_Linux_COMPATIBILITY) if (DAEMON_ARCH_arm64) add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp) add_dependencies(runtime_deps nacl_helper_bootstrap-armhf) @@ -1008,7 +1008,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Win32 requires nacl_loader_amd64.exe in order to run on Win64 - if (WIN32 AND DAEMON_ARCH_i686) + if (DAEMON_SYSTEM_Windows AND DAEMON_ARCH_i686) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPS_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX} @@ -1022,7 +1022,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Mac requires some libraries from external_deps - if (APPLE) + if (DAEMON_SYSTEM_macOS) file(GLOB RUNTIME_FRAMEWORKS ${DEPS_DIR}/lib/*.framework) foreach(RUNTIME_FRAMEWORK ${RUNTIME_FRAMEWORKS}) get_filename_component(RUNTIME_FRAMEWORK_NAME ${RUNTIME_FRAMEWORK} NAME) @@ -1044,7 +1044,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Windows requires some libraries from external_deps - if (WIN32) + if (DAEMON_SYSTEM_Windows) file(GLOB RUNTIME_LIBS ${DEPS_DIR}/bin/*.dll ${DEPS_DIR}/SDL3/lib/*/SDL3.dll) foreach(RUNTIME_LIB ${RUNTIME_LIBS}) add_custom_command(TARGET runtime_deps PRE_BUILD diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index e10a77e3f1..cf2ee4fbd5 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -382,7 +382,7 @@ else() endif() endif() - if (NACL AND USE_NACL_SAIGO AND SAIGO_DAEMON_ARCH_arm) + if (DAEMON_SYSTEM_NaCl AND USE_NACL_SAIGO AND SAIGO_DAEMON_ARCH_arm) # Saigo produces broken arm builds when optimizing them. # See: https://github.com/Unvanquished/Unvanquished/issues/3297 # When setting this clang-specific option, we don't have to care @@ -431,7 +431,7 @@ else() try_flag(WARNINGS "-Werror") endif() - if (NACL AND NOT USE_NACL_SAIGO) + if (DAEMON_SYSTEM_NaCl AND NOT USE_NACL_SAIGO) # PNaCl only supports libc++ as standard library. set_c_cxx_flag("-stdlib=libc++") set_c_cxx_flag("--pnacl-allow-exceptions") @@ -443,12 +443,12 @@ else() try_cxx_flag(FNO_GNU_UNIQUE "-fno-gnu-unique") # Use MSVC-compatible bitfield layout - if (WIN32) + if (DAEMON_SYSTEM_Windows) set_c_cxx_flag("-mms-bitfields") endif() # Linker flags - if (NOT APPLE) + if (NOT DAEMON_SYSTEM_macOS) try_linker_flag(LINKER_O1 "-Wl,-O1") try_linker_flag(LINKER_SORT_COMMON "-Wl,--sort-common") try_linker_flag(LINKER_AS_NEEDED "-Wl,--as-needed") @@ -461,7 +461,7 @@ else() try_linker_flag(LINKER_Z_NOW "-Wl,-z,now") endif() - if (WIN32) + if (DAEMON_SYSTEM_Windows) try_linker_flag(LINKER_DYNAMICBASE "-Wl,--dynamicbase") try_linker_flag(LINKER_NXCOMPAT "-Wl,--nxcompat") try_linker_flag(LINKER_LARGE_ADDRESS_AWARE "-Wl,--large-address-aware") @@ -474,7 +474,7 @@ else() # The -pthread flag sets some preprocessor defines, # it is also used to link with libpthread on Linux. - if (NOT APPLE) + if (NOT DAEMON_SYSTEM_macOS) try_c_cxx_flag(PTHREAD "-pthread") endif() @@ -507,7 +507,7 @@ else() if (USE_HARDENING) # PNaCl accepts the flags but does not define __stack_chk_guard and __stack_chk_fail. - if (NOT NACL) + if (NOT DAEMON_SYSTEM_NaCl) try_c_cxx_flag(FSTACK_PROTECTOR_STRONG "-fstack-protector-strong") if (NOT FLAG_FSTACK_PROTECTOR_STRONG) @@ -518,12 +518,12 @@ else() try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow") try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector") - if (NOT NACL) + if (NOT DAEMON_SYSTEM_NaCl) # The -pie flag requires -fPIC: # > ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC # This flag isn't used on macOS: # > clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument] - if (FLAG_FPIC AND NOT APPLE) + if (FLAG_FPIC AND NOT DAEMON_SYSTEM_macOS) try_exe_linker_flag(LINKER_PIE "-pie") endif() endif() @@ -546,7 +546,7 @@ else() # PNaCl accepts the flag but does nothing with it, underlying clang doesn't support it. # Saigo NaCl compiler doesn't support LTO, the flag is accepted but linking fails # with “unable to pass LLVM bit-code files to linker” error. - if (USE_LTO AND NOT NACL) + if (USE_LTO AND NOT DAEMON_SYSTEM_NaCl) try_c_cxx_flag(LTO_AUTO "-flto=auto") if (NOT FLAG_LTO_AUTO) @@ -612,7 +612,7 @@ if (MSVC) set_c_cxx_flag("/arch:IA32") # minimum endif() endif() -elseif (NOT NACL) +elseif (NOT DAEMON_SYSTEM_NaCl) # Among the required hardware features, the NX bit (No eXecute bit) # feature may be required for NativeClient to work. Some early # Intel EM64T processors are known to not implement the NX bit. @@ -716,7 +716,7 @@ elseif (NOT NACL) endif() # Windows-specific definitions -if (WIN32) +if (DAEMON_SYSTEM_Windows) add_definitions( -DWINVER=0x501 # Minimum Windows version: XP -DWIN32 # Define WIN32 for compatibility (compiler defines _WIN32) @@ -731,7 +731,7 @@ if (MSVC) endif() # Mac-specific definitions -if (APPLE) +if (DAEMON_SYSTEM_macOS) add_definitions(-DMACOS_X) set(CMAKE_INSTALL_RPATH "@executable_path") set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) diff --git a/cmake/DaemonNacl.cmake b/cmake/DaemonNacl.cmake index abd09e83fc..959edc620f 100644 --- a/cmake/DaemonNacl.cmake +++ b/cmake/DaemonNacl.cmake @@ -28,7 +28,7 @@ option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF) -if( NACL ) +if (DAEMON_SYSTEM_NaCl) # Build nexe binary. if(USE_NACL_SAIGO) # DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET carries the architecture. @@ -53,13 +53,13 @@ if( NACL ) endif() else() # Build native dll or native exe. - if( APPLE ) + if (DAEMON_SYSTEM_macOS) add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=1 ) - elseif( LINUX ) + elseif (DAEMON_SYSTEM_Linux) add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) - elseif( FREEBSD ) + elseif (DAEMON_SYSTEM_FreeBSD) add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=1 -DNACL_OSX=0 ) - elseif( WIN32 ) + elseif (DAEMON_SYSTEM_Windows) add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) endif() diff --git a/cmake/DaemonPlatform/Architecture.cmake b/cmake/DaemonPlatform/Architecture.cmake index 39b401e6f2..b455fb688f 100644 --- a/cmake/DaemonPlatform/Architecture.cmake +++ b/cmake/DaemonPlatform/Architecture.cmake @@ -74,7 +74,7 @@ daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") # Modifying NACL_ARCH breaks engine compatibility with nexe game binaries # since NACL_ARCH contributes to the nexe file name. set(DAEMON_NACL_ARCH "${DAEMON_ARCH}") -if (LINUX OR FREEBSD) +if (DAEMON_SYSTEM_Linux_COMPATIBILITY) set(ARMHF_USAGE arm64 armel) if (DAEMON_ARCH IN_LIST ARMHF_USAGE) # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. @@ -92,7 +92,7 @@ if (LINUX OR FREEBSD) add_definitions(-DDAEMON_NACL_BOX64_EMULATION) endif() endif() -elseif(APPLE) +elseif (DAEMON_SYSTEM_macOS) if ("${DAEMON_ARCH}" STREQUAL arm64) # You can get emulated NaCl going like this: # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ diff --git a/cmake/DaemonPlatform/System.cmake b/cmake/DaemonPlatform/System.cmake index 749fb5a811..453184b91d 100644 --- a/cmake/DaemonPlatform/System.cmake +++ b/cmake/DaemonPlatform/System.cmake @@ -1,5 +1,5 @@ # Daemon BSD Source Code -# Copyright (c) 2013-2016, Daemon Developers +# Copyright (c) 2025, Daemon Developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,14 +28,126 @@ # System detection. ################################################################################ -# When adding a new platform, look at all the places WIN32, APPLE and LINUX are used -if( CMAKE_SYSTEM_NAME MATCHES "Linux" ) - set( LINUX ON ) -elseif( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" ) - set( FREEBSD ON ) -elseif( WIN32 ) -elseif( APPLE ) -elseif( NACL ) -else() - message( FATAL_ERROR "Platform not supported" ) +# When adding a new system, look at all the places DAEMON_HOST_SYSTEM +# and DAEMON_SYSTEM are used. + +function(daemon_detect_host_system) + set(system_name "Unknown") + + foreach(name Linux;FreeBSD;Android;Windows) + if (CMAKE_HOST_SYSTEM_NAME MATCHES "${name}") + set(system_name "${CMAKE_SYSTEM_NAME}") + endif() + endforeach() + + if (system_name STREQUAL "Unknown") + message(WARNING "Host system detection failed, may misdetect the target as the host.") + + if (WIN32) + set(system_name "Windows") + elseif (APPLE) + set(system_name "macOS") + endif() + endif() + + if (system_name STREQUAL "Unknown") + set(SYSTEM_Darwin "macOS") + set(SYSTEM_MSYS "Windows") + + foreach(name Darwin;MSYS) + if ("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "${name}") + set(system_name "${SYSTEM_${name}}") + endif() + endforeach() + + detect_cmake_host_system("system_name") + endif() + + set(DAEMON_HOST_SYSTEM_NAME "${system_name}" PARENT_SCOPE) +endfunction() + +function(daemon_detect_system) + try_compile(BUILD_RESULT + "${CMAKE_BINARY_DIR}" + "${CMAKE_CURRENT_LIST_DIR}/System/System.c" + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + OUTPUT_VARIABLE BUILD_LOG + ) + + if (NOT BUILD_RESULT) + message(WARNING "Failed to build System.c, relying on CMake builtin detection.") + set(system_name "Unknown") + else() + set(BUILD_LOG "\n${BUILD_LOG}\n") + string(REGEX REPLACE "\n[^\n]*REPORT>[^\n]*\n" "\n" BUILD_LOG "${BUILD_LOG}") + + string(REGEX REPLACE ".*\nDAEMON_SYSTEM_NAME=([^\n]*)\n.*" "\\1" + system_name "${BUILD_LOG}") + + foreach(name Linux;Unix;${system_name}) + set(compatibility_regex ".*\nDAEMON_SYSTEM_${name}_COMPATIBILITY=([^\n]*)\n.*") + if ("${BUILD_LOG}" MATCHES ${compatibility_regex}) + string(REGEX REPLACE ${compatibility_regex} "\\1" + system_${name}_compatibility "${BUILD_LOG}") + endif() + + set(DAEMON_SYSTEM_${name}_COMPATIBILITY + "${system_${name}_compatibility}" + PARENT_SCOPE) + endforeach() + endif() + + if (system_name STREQUAL "Unknown") + detect_cmake_host_system("system_name") + endif() + + set(DAEMON_SYSTEM_NAME "${system_name}" PARENT_SCOPE) +endfunction() + +daemon_detect_host_system() +daemon_detect_system() + +if ("${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Unknown host system") +endif() + +if ("${DAEMON_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Unknown target system") +endif() + +if ("${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${DAEMON_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Assuming the host system is the same as the target: ${DAEMON_SYSTEM_NAME}") + set(DAEMON_HOST_SYSTEM_NAME "${DAEMON_SYSTEM_NAME}") endif() + +if ("${DAEMON_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Assuming the target system is the same as the host: ${DAEMON_SYSTEM_NAME}") + set(DAEMON_SYSTEM_NAME "${DAEMON_HOST_SYSTEM_NAME}") +endif() + +message(STATUS "Detected host system: ${DAEMON_HOST_SYSTEM_NAME}") +message(STATUS "Detected target system: ${DAEMON_SYSTEM_NAME}") + +if (NOT "${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "${DAEMON_SYSTEM_NAME}") + message(STATUS "Detected cross-compilation") +endif() + +# Makes possible to do things like: +# > if (DAEMON_HOST_SYSTEM_Linux) +# > if (DAEMON_SYSTEM_Windows) +set("DAEMON_HOST_SYSTEM_${DAEMON_HOST_SYSTEM_NAME}" ON) +set("DAEMON_SYSTEM_${DAEMON_SYSTEM_NAME}" ON) + +# This is for systems with behaviors similar to Linux, +# implementing standards like FHS, XDG, GLVND… +# Makes possible to do that in CMake code: +# > if (DAEMON_HOST_SYSTEM_Linux_COMPATIBILITY) +# > if (DAEMON_SYSTEM_Linux_COMPATIBILITY) +foreach(name Linux;FreeBSD) + foreach(slug HOST;HOST_SYSTEM) + if (DAEMON_${slug}_${name}) + set(DAEMON_${slug}_Linux_COMPATIBILITY ON) + endif() + endforeach() +endforeach() diff --git a/cmake/DaemonPlatform/System/System.c b/cmake/DaemonPlatform/System/System.c new file mode 100644 index 0000000000..71f3d53bcd --- /dev/null +++ b/cmake/DaemonPlatform/System/System.c @@ -0,0 +1,79 @@ +/* +=========================================================================== +Daemon BSD Source Code +Copyright (c) 2025, Daemon Developers +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Daemon developers nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=========================================================================== +*/ + +#if defined(__APPLE__) && defined(__MACH__) +#include +#endif + +#define STRING(s) #s +#define XSTRING(s) STRING(s) + +#define REPORT(key, value) \ + "REPORT>" +#define REPORT_COMPATIBILITY(name) \ + REPORT(name "_COMPATIBILITY", "ON") +#define REPORT_NAME(name) \ + REPORT("NAME", name) + +#if defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) + #pragma message(REPORT_COMPATIBILITY("Linux")) +#endif + +#if defined(__unix__) || defined(__unix) || defined(unix) + #pragma message(REPORT_COMPATIBILITY("Unix")) +#endif + +#if defined(__wasm__) || defined(__wasm) || defined(__wasm32) || defined(__wasi__) + #pragma message(REPORT_NAME("Wasm")) +#elif defined(__pnacl__) || defined(__saigo__) || defined(NACLENTRYALIGN) + #pragma message(REPORT_NAME("NaCl")) +#elif defined(__WINNT__) || defined(__WINNT) || defined(WINNT) \ +|| defined(__WIN64__) || defined(__WIN64) || defined(_WIN64) || defined(WIN64) \ +|| defined(__WIN32__) || defined(__WIN32) || defined(_WIN32) || defined(WIN32) \ +|| defined(__MINGW64__) || defined(__MINGW32__) + #pragma message(REPORT_NAME("Windows")) +#elif defined(__APPLE__) && defined(__MACH__) && (TARGET_OS_MAC && !TARGET_OS_IPHONE) + #pragma message(REPORT_NAME("macOS")) +#elif defined(__FreeBSD__) + #pragma message(REPORT_NAME("FreeBSD")) +#elif defined(__ANDROID__) + #pragma message(REPORT_NAME("Android")) +#elif defined(__gnu_linux__) + #pragma message(REPORT_NAME("Linux")) +#elif defined(__linux__) || defined(__linux) || defined(linux) + #pragma message(REPORT_NAME("Linux") +#else + #pragma message(REPORT_NAME("Unknown")) +#endif + +// Make the compilation succeeds if system is supported. +int main(int argc, char** argv) { + return 0; +} diff --git a/cmake/DaemonPlatform/System/System.sh b/cmake/DaemonPlatform/System/System.sh new file mode 100755 index 0000000000..7ebc552b54 --- /dev/null +++ b/cmake/DaemonPlatform/System/System.sh @@ -0,0 +1,49 @@ +#! /usr/bin/env bash + +# Daemon BSD Source Code +# Copyright (c) 2025, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Test script not used by the CMake build system. Usage example: +# ./System.sh gcc + +set -ueo pipefail + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +file_path="${script_dir}/System.c" + +# PNaCl doesn't work with “-o /dev/null” as it uses the output path as a +# pattern for temporary files and then the parent folder should be writable. +# Zig caches the build if both the source and the output don't change. Since +# the /dev/null file never changes, Zig skips the compilation once done once. +# So we need to use a randomly named path in a writable directory. +temp_file="$(mktemp)" + +"${@}" "${file_path}" -o "${temp_file}" 2>&1 \ + | grep 'REPORT>.*//' \ +|| "${@}" "${file_path}" -o "${temp_file}" + +rm "${temp_file}" diff --git a/freetype.cmake b/freetype.cmake index f6556dbaca..6dff87a83e 100644 --- a/freetype.cmake +++ b/freetype.cmake @@ -2,7 +2,7 @@ set(FREETYPE_DIR ${DAEMON_DIR}/libs/freetype) set(FREETYPE_INCLUDE_DIRS ${FREETYPE_DIR}/include) set(FREETYPE_LIBRARIES freetype) -if (NACL) +if (DAEMON_SYSTEM_NaCl) # Using Freetype's own zlib prevents the need for a zlib submodule when building the nexe cgame. set(FREETYPE_INTERNAL_ZLIB ON) else() diff --git a/src.cmake b/src.cmake index 2265b4fc97..c51414c642 100644 --- a/src.cmake +++ b/src.cmake @@ -211,7 +211,7 @@ set(OMPLIST ${ENGINE_DIR}/framework/OmpSystem.h ) -if (WIN32) +if (DAEMON_SYSTEM_Windows) set(ENGINELIST ${ENGINELIST} ${ENGINE_DIR}/sys/con_passive.cpp ) @@ -301,7 +301,7 @@ set(CLIENTLIST ${RENDERERLIST} ) -if (APPLE) +if (DAEMON_SYSTEM_macOS) set(CLIENTLIST ${CLIENTLIST} ${ENGINE_DIR}/sys/DisableAccentMenu.m) endif() diff --git a/srclibs.cmake b/srclibs.cmake index 08b1a31b7a..0de7355dd3 100644 --- a/srclibs.cmake +++ b/srclibs.cmake @@ -33,19 +33,19 @@ set(NACLLIST_MODULE ${LIB_DIR}/nacl/native_client/src/untrusted/nacl/imc_socketpair.c ) -if (APPLE) +if (DAEMON_SYSTEM_macOS) set(NACLLIST_NATIVE ${LIB_DIR}/nacl/native_client/src/shared/imc/nacl_imc_common.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/osx/nacl_imc.cc ) -elseif (LINUX OR FREEBSD) +elseif (DAEMON_SYSTEM_Linux_COMPATIBILITY) set(NACLLIST_NATIVE ${LIB_DIR}/nacl/native_client/src/shared/imc/nacl_imc_common.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/linux/nacl_imc.cc ) -elseif (WIN32) +elseif (DAEMON_SYSTEM_Windows) set(NACLLIST_NATIVE ${LIB_DIR}/nacl/native_client/src/shared/imc/nacl_imc_common.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/win/nacl_imc.cc @@ -101,7 +101,7 @@ set(PDCURSESLIST ${LIB_DIR}/pdcursesmod/pdcurses/window.c ) -if (WIN32) +if (DAEMON_SYSTEM_Windows) set(PDCURSESLIST ${PDCURSESLIST} ${LIB_DIR}/pdcursesmod/wingui/pdcclip.c @@ -153,7 +153,7 @@ set(TINYGETTEXTLIST ${LIB_DIR}/tinygettext/tinygettext.hpp ) -if (WIN32) +if (DAEMON_SYSTEM_Windows) set(BREAKPAD_COMMON_LIST ${LIB_DIR}/breakpad/src/common/windows/guid_string.cc ${LIB_DIR}/breakpad/src/common/windows/guid_string.h @@ -179,7 +179,9 @@ if (WIN32) ${LIB_DIR}/breakpad/src/client/windows/handler/exception_handler.cc ${LIB_DIR}/breakpad/src/client/windows/handler/exception_handler.h ) -elseif (LINUX) +# We don't know if this works outside of Linux, +# so we don't use DAEMON_SYSTEM_Linux_COMPATIBILITY. +elseif (DAEMON_SYSTEM_Linux) set(BREAKPAD_LIST ${LIB_DIR}/breakpad/src/client/linux/crash_generation/crash_generation_client.cc ${LIB_DIR}/breakpad/src/client/linux/crash_generation/crash_generation_server.cc From 416fbcc9d9c333123e17ce9e9b19e8666443b7d2 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 12:11:22 +0100 Subject: [PATCH 05/14] =?UTF-8?q?cmake:=20use=20compiler=20detection=20ins?= =?UTF-8?q?tead=20of=20=E2=80=9CMSVC=E2=80=9D=20and=20=E2=80=9CNOT=20MSVC?= =?UTF-8?q?=20AND=20WIN32=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 8 ++++---- cmake/DaemonFlags.cmake | 12 ++++++------ cmake/DaemonPlatform/Compiler.cmake | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ef4faffc..56da729f86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,9 +206,9 @@ if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) set(DEPS_ARCH "${DAEMON_ARCH}") - if (MSVC) + if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) set(DEPS_COMPILER msvc) - elseif (WIN32) + elseif (DAEMON_CXX_COMPILER_MinGW) set(DEPS_COMPILER mingw) else() set(DEPS_COMPILER default) @@ -836,9 +836,9 @@ macro(AddApplicationInternal Target Executable) # Append Windows specific manifests. # Adding the .manifest as a source works better for MSVC, but it has no # effect for MinGW (https://gitlab.kitware.com/cmake/cmake/-/issues/23244). - if (MINGW) + if (DAEMON_CXX_COMPILER_MinGW) target_sources(${Target} PRIVATE ${ENGINE_DIR}/sys/windows-resource/manifest.rc) - elseif (WIN32) + elseif (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) target_sources(${Target} PRIVATE ${ENGINE_DIR}/sys/windows-resource/supported-os.manifest) endif() diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index cf2ee4fbd5..f51903066f 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -55,7 +55,7 @@ mark_as_advanced(USE_RECOMMENDED_CXX_STANDARD) option(USE_CPP23 "Use C++23 standard where possible" OFF) -if (MSVC) +if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) set(DEFAULT_STRIP_SOURCE_PATHS ON) else() set(DEFAULT_STRIP_SOURCE_PATHS OFF) @@ -153,7 +153,7 @@ function(try_flag LIST FLAG) # Other compilers might interpret it as a filename so reject without testing. string(SUBSTRING "${FLAG}" 0 1 FLAG_FIRST_CHAR) if ("${FLAG_FIRST_CHAR}" STREQUAL "/") - if (MSVC) + if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) set(${TEST} 1) else() set(${TEST} 0) @@ -233,7 +233,7 @@ if (STRIP_SOURCE_PATHS) set(FILENAME_STRIP_DIRS ${FILENAME_STRIP_DIRS} "${DAEMON_DIR}/src" "${DAEMON_DIR}") endif() foreach(strip_dir ${FILENAME_STRIP_DIRS}) - if (MSVC) + if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) string(REPLACE "/" "\\" backslashed_dir ${strip_dir}) # set_c_cxx_flag can't be used because macros barf if the input contains backslashes # https://gitlab.kitware.com/cmake/cmake/-/issues/19281 @@ -263,7 +263,7 @@ if (NOT NACL AND BUILD_CLIENT) option(USE_OPENMP "Use OpenMP to parallelize some tasks" OFF) endif() -if (MSVC) +if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) set_c_cxx_flag("/MP") # There is no flag for standards before C++17 @@ -604,7 +604,7 @@ endif() option(USE_CPU_RECOMMENDED_FEATURES "Use some common hardware features like SSE2, NEON, VFP, MCX16, etc." ON) # Target options. -if (MSVC) +if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) if (DAEMON_ARCH_i686) if (USE_CPU_RECOMMENDED_FEATURES) set_c_cxx_flag("/arch:SSE2") # This is the default @@ -726,7 +726,7 @@ if (DAEMON_SYSTEM_Windows) set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib") endif() -if (MSVC) +if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() diff --git a/cmake/DaemonPlatform/Compiler.cmake b/cmake/DaemonPlatform/Compiler.cmake index 6fab3a4604..fef264443a 100644 --- a/cmake/DaemonPlatform/Compiler.cmake +++ b/cmake/DaemonPlatform/Compiler.cmake @@ -185,6 +185,7 @@ foreach(lang C;CXX) if (MSVC) # Let CMake do the job, it does it very well, # and there is probably no variant to take care about. + set(DAEMON_${lang}_COMPILER_MSVC_COMPATIBILITY ON) set(DAEMON_${lang}_COMPILER_NAME "${CMAKE_${lang}_COMPILER_ID}") set(DAEMON_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}") get_filename_component(DAEMON_${lang}_COMPILER_BASENAME "${CMAKE_${lang}_COMPILER}" NAME) From b53ae63e6f161c48409cc90234840a4bf2ec3488 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 13:01:56 +0100 Subject: [PATCH 06/14] cmake: mutualize the detection framework --- cmake/DaemonPlatform/Architecture.cmake | 151 ++++++++---------- cmake/DaemonPlatform/Compiler.cmake | 69 ++------ cmake/DaemonPlatform/Detection.cmake | 102 ++++++++++++ .../Architecture.c} | 27 ++-- .../{Compiler => Detection}/Compiler.c | 21 +-- .../{Compiler => Detection}/Compiler.cpp | 0 .../{System => Detection}/System.c | 13 +- .../Compiler.sh => Detection/detect} | 36 +++-- .../qprocessordetection.h | 0 cmake/DaemonPlatform/Detection/report.h | 47 ++++++ cmake/DaemonPlatform/Platform.cmake | 10 +- cmake/DaemonPlatform/System.cmake | 33 +--- cmake/DaemonPlatform/System/System.sh | 49 ------ 13 files changed, 283 insertions(+), 275 deletions(-) create mode 100644 cmake/DaemonPlatform/Detection.cmake rename cmake/DaemonPlatform/{Architecture/Architecture.cpp => Detection/Architecture.c} (88%) rename cmake/DaemonPlatform/{Compiler => Detection}/Compiler.c (90%) rename cmake/DaemonPlatform/{Compiler => Detection}/Compiler.cpp (100%) rename cmake/DaemonPlatform/{System => Detection}/System.c (92%) rename cmake/DaemonPlatform/{Compiler/Compiler.sh => Detection/detect} (69%) rename cmake/DaemonPlatform/{Architecture => Detection}/qprocessordetection.h (100%) create mode 100644 cmake/DaemonPlatform/Detection/report.h delete mode 100755 cmake/DaemonPlatform/System/System.sh diff --git a/cmake/DaemonPlatform/Architecture.cmake b/cmake/DaemonPlatform/Architecture.cmake index b455fb688f..5619021a22 100644 --- a/cmake/DaemonPlatform/Architecture.cmake +++ b/cmake/DaemonPlatform/Architecture.cmake @@ -1,5 +1,5 @@ # Daemon BSD Source Code -# Copyright (c) 2022, Daemon Developers +# Copyright (c) 2022-2025, Daemon Developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -30,108 +30,97 @@ # When adding a new architecture, look at all the places DAEMON_ARCH is used. -try_compile(BUILD_RESULT - "${CMAKE_BINARY_DIR}" - "${CMAKE_CURRENT_LIST_DIR}/Architecture/Architecture.cpp" - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - OUTPUT_VARIABLE BUILD_LOG -) - -# Setting -Werror in CXXFLAGS would produce errors instead of warning -# but that should not break the architecture detection, -# so we only print a CMake warning there and use BUILD_LOG content to -# detect unknown platforms. -# Catching compilation error is still useful, for example to detect -# undefined types, missing header or things like that. -# Setting USE_WERROR to ON doesn't print this warning. -if (NOT BUILD_RESULT) - message(WARNING - "Failed to build Architecture.cpp\n" - "Setting -Werror in CXXFLAGS can produce false positive errors\n" - "${BUILD_LOG}" - ) -endif() - -string(REGEX MATCH "DAEMON_ARCH_([a-zA-Z0-9_]+)" DAEMON_ARCH_DEFINE "${BUILD_LOG}") -string(REPLACE "DAEMON_ARCH_" "" DAEMON_ARCH "${DAEMON_ARCH_DEFINE}") +option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON) +mark_as_advanced(USE_ARCH_INTRINSICS) -set("DAEMON_ARCH_${DAEMON_ARCH}" ON) +function(daemon_detect_arch) + daemon_run_detection("" "ARCH" "Architecture.c" "") -if (NOT DAEMON_ARCH) - message(FATAL_ERROR - "Missing DAEMON_ARCH, there is a mistake in Architecture.cpp\n" - "${BUILD_LOG}" - ) -endif() + set(DAEMON_ARCH "${arch_name}" PARENT_SCOPE) -message(STATUS "Detected target architecture: ${DAEMON_ARCH}") + message(STATUS "Detected target architecture: ${arch_name}") -add_definitions(-D${DAEMON_ARCH_DEFINE}) + add_definitions(-DDAEMON_ARCH_${arch_name}) -# This string can be modified without breaking compatibility. -daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") + set(nacl_arch "${arch_name}") -# Modifying NACL_ARCH breaks engine compatibility with nexe game binaries -# since NACL_ARCH contributes to the nexe file name. -set(DAEMON_NACL_ARCH "${DAEMON_ARCH}") -if (DAEMON_SYSTEM_Linux_COMPATIBILITY) - set(ARMHF_USAGE arm64 armel) - if (DAEMON_ARCH IN_LIST ARMHF_USAGE) + if (DAEMON_SYSTEM_Linux_COMPATIBILITY) + set(armhf_usage "arm64;armel") + if ("${arch_name}" IN_LIST armhf_usage) # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. # The nexe is system agnostic so there should be no difference with armel. - set(DAEMON_NACL_ARCH "armhf") + set(nacl_arch "armhf") + + set(box64_usage ppc64el riscv64) + if ("${arch_name}" IN_LIST box64_usage) + option(DAEMON_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) + if (DAEMON_NACL_BOX64_EMULATION) + # Use Box64 to run x86_64 NaCl loader and amd64 nexe. + # Box64 must be installed and available in PATH at runtime. + set(nacl_arch "amd64") + add_definitions(-DDAEMON_NACL_BOX64_EMULATION) + endif() + endif() endif() - set(BOX64_USAGE ppc64el riscv64) - if (ARCH IN_LIST BOX64_USAGE) - option(DAEMON_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) - if (DAEMON_NACL_BOX64_EMULATION) - # Use Box64 to run x86_64 NaCl loader and amd64 nexe. - # Box64 must be installed and available in PATH at runtime. - set(NACL_ARCH "amd64") - add_definitions(-DDAEMON_NACL_BOX64_EMULATION) + elseif (DAEMON_SYSTEM_macOS) + if ("${arch_name}" STREQUAL "arm64") + # You can get emulated NaCl going like this: + # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ + set(nacl_arch "amd64") endif() endif() -elseif (DAEMON_SYSTEM_macOS) - if ("${DAEMON_ARCH}" STREQUAL arm64) - # You can get emulated NaCl going like this: - # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ - set(DAEMON_NACL_ARCH "amd64") - endif() -endif() -set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH}" ON) + # The DAEMON_NACL_ARCH variable contributes to the nexe file name. + set(DAEMON_NACL_ARCH "${nacl_arch}" PARENT_SCOPE) -daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"") + # NaCl runtime is only available on architectures that have a NaCl loader. + set(nacl_runtime_arch amd64 i686 armhf) + if ("${nacl_arch}" IN_LIST nacl_runtime_arch) + add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED) + endif() +endfunction() -# NaCl runtime is only available on architectures that have a NaCl loader. -set(NACL_RUNTIME_ARCH amd64 i686 armhf) -if (NACL_ARCH IN_LIST NACL_RUNTIME_ARCH) - add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED) -endif() +function(daemon_set_arch_intrinsics name) + message(STATUS "Enabling ${name} architecture intrinsics") + add_definitions(-DDAEMON_USE_ARCH_INTRINSICS_${name}) +endfunction() option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON) mark_as_advanced(USE_ARCH_INTRINSICS) -macro(set_arch_intrinsics name) +function(daemon_set_intrinsics) if (USE_ARCH_INTRINSICS) - message(STATUS "Enabling ${name} architecture intrinsics") - add_definitions(-DDAEMON_USE_ARCH_INTRINSICS_${name}=1) + # Makes possible to do that in C++ code: + # > if defined(DAEMON_USE_ARCH_INTRINSICS) + add_definitions(-DDAEMON_USE_ARCH_INTRINSICS) + + # Makes possible to do that in C++ code: + # > if defined(DAEMON_USE_ARCH_INTRINSICS_amd64) + # > if defined(DAEMON_USE_ARCH_INTRINSICS_i686) + daemon_set_arch_intrinsics("${DAEMON_ARCH}") + + set(amd64_PARENT "i686") + set(arm64_PARENT "armhf") + set(ppc64el_PARENT "ppc64") + + if ("${DAEMON_ARCH}_PARENT") + daemon_set_arch_intrinsics("${${DAEMON_ARCH}_PARENT}") + endif() else() - message(STATUS "Disabling ${name} architecture intrinsics") + message(STATUS "Disabling ${DAEMON_ARCH} architecture intrinsics") endif() -endmacro() - -if (USE_ARCH_INTRINSICS) - add_definitions(-DDAEMON_USE_ARCH_INTRINSICS=1) -endif() +endfunction() -set_arch_intrinsics(${DAEMON_ARCH}) +daemon_detect_arch() +daemon_set_intrinsics() -set(amd64_PARENT "i686") -set(arm64_PARENT "armhf") -set(ppc64el_PARENT "ppc64") +# Makes possible to do that in CMake code: +# > if (DAEMON_ARCH_arm64) +# > if (DAEMON_NACL_ARCH_armhf) +set("DAEMON_ARCH_${DAEMON_ARCH}" ON) +set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH}" ON) -if (${DAEMON_ARCH}_PARENT) - set_arch_intrinsics(${${DAEMON_ARCH}_PARENT}) -endif() +# Add printable strings to the executable. +daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") +daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"") diff --git a/cmake/DaemonPlatform/Compiler.cmake b/cmake/DaemonPlatform/Compiler.cmake index fef264443a..5a9cd5519c 100644 --- a/cmake/DaemonPlatform/Compiler.cmake +++ b/cmake/DaemonPlatform/Compiler.cmake @@ -1,5 +1,5 @@ # Daemon BSD Source Code -# Copyright (c) 2024, Daemon Developers +# Copyright (c) 2024-2025, Daemon Developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,63 +28,18 @@ # Compiler detection. ################################################################################ -# FIXME: Force -W#pragma-messages and -Wno-error -# In case there is -Wno-#pragma-messages or -Werror in CFLAGS/CXXFLAGS +# When adding a new compiler, look at all the places DAEMON_C_COMPILER +# and DAEMON_CXX_COMPILER are used. -function(detect_daemon_compiler lang) +function(daemon_detect_compiler lang) set(C_NAME "C") set(CXX_NAME "C++") set(C_EXT ".c") set(CXX_EXT ".cpp") - try_compile(BUILD_RESULT - "${CMAKE_BINARY_DIR}" - "${CMAKE_CURRENT_LIST_DIR}/Compiler/Compiler${${lang}_EXT}" - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - OUTPUT_VARIABLE BUILD_LOG - ) - get_filename_component(compiler_basename "${CMAKE_${lang}_COMPILER}" NAME) - if (NOT BUILD_RESULT) - message(WARNING "Failed to build Compiler${${lang}_EXT}, relying on CMake builtin detection.") - set(compiler_name "Unknown") - else() - set(BUILD_LOG "\n${BUILD_LOG}\n") - string(REGEX REPLACE "\n[^\n]*REPORT>[^\n]*\n" "\n" BUILD_LOG "${BUILD_LOG}") - - string(REGEX REPLACE ".*\nDAEMON_COMPILER_NAME=([^\n]*)\n.*" "\\1" - compiler_name "${BUILD_LOG}") - - foreach(name GCC;Clang;generic;${compiler_name}) - set(compatibility_regex ".*\nDAEMON_COMPILER_${name}_COMPATIBILITY=([^\n]*)\n.*") - if ("${BUILD_LOG}" MATCHES ${compatibility_regex}) - string(REGEX REPLACE ${compatibility_regex} "\\1" - compiler_${name}_compatibility "${BUILD_LOG}") - endif() - - set(version_regex ".*\nDAEMON_COMPILER_${name}_VERSION=([^\n]*)\n.*") - if ("${BUILD_LOG}" MATCHES ${version_regex}) - string(REGEX REPLACE ${version_regex} "\\1" - compiler_${name}_version "${BUILD_LOG}") - endif() - - set(version_string_regex ".*\nDAEMON_COMPILER_${name}_VERSION_STRING=([^\n]*)\n.*") - if ("${BUILD_LOG}" MATCHES ${version_string_regex}) - string(REGEX REPLACE ${version_string_regex} "\\1" - compiler_${name}_version_string "${BUILD_LOG}") - endif() - - set(DAEMON_${lang}_COMPILER_${name}_VERSION - "${compiler_${name}_version}" - PARENT_SCOPE) - - set(DAEMON_${lang}_COMPILER_${name}_COMPATIBILITY - "${compiler_${name}_compatibility}" - PARENT_SCOPE) - endforeach() - endif() + daemon_run_detection("${lang}_" "COMPILER" "Compiler${${lang}_EXT}" "GCC;Clang;generic") if (compiler_name STREQUAL "Unknown") if (CMAKE_${lang}_COMPILER_ID) @@ -126,7 +81,7 @@ function(detect_daemon_compiler lang) endif() endif() - # Compilers that use underlying Clang version as their own version. + # Compilers that use the underlying Clang version as their own version. foreach(name in AppleClang) if (compiler_name STREQUAL "${name}") set(compiler_${name}_version "${compiler_Clang_version}") @@ -190,7 +145,7 @@ foreach(lang C;CXX) set(DAEMON_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}") get_filename_component(DAEMON_${lang}_COMPILER_BASENAME "${CMAKE_${lang}_COMPILER}" NAME) else() - detect_daemon_compiler(${lang}) + daemon_detect_compiler(${lang}) if (DAEMON_${lang}_COMPILER_Clang_COMPATIBILITY) if (NOT DAEMON_${lang}_COMPILER_NAME STREQUAL "Clang") @@ -234,9 +189,15 @@ foreach(lang C;CXX) message(STATUS "Detected ${${lang}_NAME} compiler: ${DAEMON_${lang}_COMPILER_STRING}") + # Makes possible to do that in C++ code: + # > if defined(DAEMON_CXX_COMPILER_Clang) set(compiler_var_name "DAEMON_${lang}_COMPILER_${DAEMON_${lang}_COMPILER_NAME}") - set(${compiler_var_name} ON) - add_definitions(-D${compiler_var_name}=1) + add_definitions(-D${compiler_var_name}) + + # Makes possible to do that in CMake code: + # > if (DAEMON_CXX_COMPILER_Clang) + set("${compiler_var_name}" ON) + # Add printable string to the executable. daemon_add_buildinfo("char*" "DAEMON_${lang}_COMPILER_STRING" "\"${DAEMON_${lang}_COMPILER_STRING}\"") endforeach() diff --git a/cmake/DaemonPlatform/Detection.cmake b/cmake/DaemonPlatform/Detection.cmake new file mode 100644 index 0000000000..8418e37fea --- /dev/null +++ b/cmake/DaemonPlatform/Detection.cmake @@ -0,0 +1,102 @@ +# Daemon BSD Source Code +# Copyright (c) 2025, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Make sure to always call this macro from within a function, not in the global scope. +# As a macro it produces a lot of variables in the parent scope but it is meant to +# only be called by functions so they should never pollute the globale scope. +# It's a macro because we need to write a lot of variables in the calling function scope +# and we need to write some variables to the parent scope of the calling function. +macro(daemon_run_detection slug_prefix report_slug file_name compat_list) + string(TOLOWER "${report_slug}" local_slug) + + # Setting -Werror in CXXFLAGS would produce errors instead of warning + # but that should not break the detection, + # so we only print a CMake warning there and use build_log content to + # detect unknown platforms. + # Catching compilation error is still useful, for example to detect + # undefined types, missing header or things like that. + # Setting USE_WERROR to ON doesn't print this warning as the flag + # is set after the detection. + try_compile(build_result + "${CMAKE_BINARY_DIR}" + "${CMAKE_CURRENT_LIST_DIR}/Detection/${file_name}" + # TODO: Force -W#pragma-messages and -Wno-error + # In case there is -Wno-#pragma-messages or -Werror in CFLAGS/CXXFLAGS + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + OUTPUT_VARIABLE build_log + ) + + if (NOT build_result) + message(WARNING "Failed to build ${file_name}.\n" + "Setting -Werror in CFLAGS can produce false positive errors\n" + "${build_log}" + ) + set(${local_slug}_name "Unknown" PARENT_SCOPE) + else() + set(build_log "\n${build_log}\n") + + string(REGEX REPLACE "\n[^\n]*REPORT>[^\n]*\n" "\n" build_log "${build_log}") + + string(REGEX REPLACE ".*\nDAEMON_${report_slug}_NAME=([^\n]*)\n.*" "\\1" + ${local_slug}_name "${build_log}") + + foreach(name ${compat_list};${${local_slug}_name}) + set(COMPATIBILITY_REGEX ".*\nDAEMON_${report_slug}_${name}_COMPATIBILITY=([^\n]*)\n.*") + if ("${build_log}" MATCHES ${COMPATIBILITY_REGEX}) + string(REGEX REPLACE ${COMPATIBILITY_REGEX} "\\1" + ${local_slug}_${name}_compatibility "${build_log}") + + set("DAEMON_${slug_prefix}${report_slug}_${name}_COMPATIBILITY" + "${${local_slug}_${name}_compatibility}" + PARENT_SCOPE) + endif() + + set(VERSION_REGEX ".*\nDAEMON_${report_slug}_${name}_VERSION=([^\n]*)\n.*") + if ("${build_log}" MATCHES ${VERSION_REGEX}) + string(REGEX REPLACE ${VERSION_REGEX} "\\1" + ${local_slug}_${name}_version "${build_log}") + + set("DAEMON_${slug_prefix}${report_slug}_${name}_VERSION" + "${${local_slug}_${name}_version}" + PARENT_SCOPE) + endif() + + set(VERSION_STRING_REGEX ".*\nDAEMON_${report_slug}_${name}_VERSION_STRING=([^\n]*)\n.*") + if ("${build_log}" MATCHES ${VERSION_STRING_REGEX}) + string(REGEX REPLACE ${VERSION_STRING_REGEX} "\\1" + ${local_slug}_${name}_version_string "${build_log}") + endif() + endforeach() + endif() +endmacro() + +# Target detection. +include("${CMAKE_CURRENT_LIST_DIR}/System.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/Architecture.cmake") + +# Compiler detection. +include("${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake") diff --git a/cmake/DaemonPlatform/Architecture/Architecture.cpp b/cmake/DaemonPlatform/Detection/Architecture.c similarity index 88% rename from cmake/DaemonPlatform/Architecture/Architecture.cpp rename to cmake/DaemonPlatform/Detection/Architecture.c index fc595fb2e5..9404693858 100644 --- a/cmake/DaemonPlatform/Architecture/Architecture.cpp +++ b/cmake/DaemonPlatform/Detection/Architecture.c @@ -1,7 +1,7 @@ /* =========================================================================== Daemon BSD Source Code -Copyright (c) 2022, Daemon Developers +Copyright (c) 2022-2025, Daemon Developers All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,6 +28,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================== */ +#define REPORT_SLUG "ARCH" +#include "report.h" + /* The qprocessordetection.h file doesn't detect endianness for some platforms including ppc64, but we know how to do it for them. */ @@ -55,11 +58,11 @@ platform variants we cannot support anyway. */ /* PNaCl virtual machines. */ #if defined(__native_client__) - #pragma message("DAEMON_ARCH_nacl") + #pragma message(REPORT_NAME("nacl")) /* Wasm virtual machines, work in progress. */ #elif defined(Q_PROCESSOR_WASM) - #pragma message("DAEMON_ARCH_wasm") + #pragma message(REPORT_NAME("wasm")) /* Devices like: - IBM PC compatibles and derivatives, @@ -67,13 +70,13 @@ platform variants we cannot support anyway. */ - Steam Deck, Atari VCS consoles… */ #elif defined(Q_PROCESSOR_X86_64) - #pragma message("DAEMON_ARCH_amd64") + #pragma message(REPORT_NAME("amd64")) #elif defined(Q_PROCESSOR_X86_32) // Assume at least i686. Detecting older revisions would be unlikely to work here // because the revisions are likely configured by flags, but this file is "compiled" // without most command-line flags. - #pragma message("DAEMON_ARCH_i686") + #pragma message(REPORT_NAME("i686")) /* Devices like: - Raspberry Pi, @@ -81,31 +84,31 @@ platform variants we cannot support anyway. */ - Android phones and tablets… */ #elif defined(Q_PROCESSOR_ARM_64) - #pragma message("DAEMON_ARCH_arm64") + #pragma message(REPORT_NAME("arm64")) #elif defined(Q_PROCESSOR_ARM_32) && defined(__ARM_PCS_VFP) - #pragma message("DAEMON_ARCH_armhf") + #pragma message(REPORT_NAME("armhf")) #elif defined(Q_PROCESSOR_ARM_32) && !defined(__ARM_PCS_VFP) - #pragma message("DAEMON_ARCH_armel") + #pragma message(REPORT_NAME("armel")) /* Devices like: - Raptor Computing Systems Talos, Blackbird… */ #elif defined(Q_PROCESSOR_POWER_64) && Q_BYTE_ORDER == Q_BIG_ENDIAN - #pragma message("DAEMON_ARCH_ppc64") + #pragma message(REPORT_NAME("ppc64")) #elif defined(Q_PROCESSOR_POWER_64) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN - #pragma message("DAEMON_ARCH_ppc64el") + #pragma message(REPORT_NAME("ppc64el")) /* Devices like: - SiFive HiFive Unmatched, Horse Creek… */ #elif defined(Q_PROCESSOR_RISCV_64) - #pragma message("DAEMON_ARCH_riscv64") + #pragma message(REPORT_NAME("riscv64")) #else - #pragma message("DAEMON_ARCH_unknown") + #pragma message(REPORT_NAME("unknown")) #endif // Make the compilation succeeds if architecture is supported. diff --git a/cmake/DaemonPlatform/Compiler/Compiler.c b/cmake/DaemonPlatform/Detection/Compiler.c similarity index 90% rename from cmake/DaemonPlatform/Compiler/Compiler.c rename to cmake/DaemonPlatform/Detection/Compiler.c index f05c0954bf..a6c80ab201 100644 --- a/cmake/DaemonPlatform/Compiler/Compiler.c +++ b/cmake/DaemonPlatform/Detection/Compiler.c @@ -1,7 +1,7 @@ /* =========================================================================== Daemon BSD Source Code -Copyright (c) 2024, Daemon Developers +Copyright (c) 2024-2025, Daemon Developers All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,23 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================== */ -#define STRING(s) #s -#define XSTRING(s) STRING(s) - -#define REPORT(key, value) \ - "REPORT>" -#define REPORT_VERSION_3(name, major, minor, patch) \ - REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor) "." XSTRING(patch)) -#define REPORT_VERSION_2(name, major, minor) \ - REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor)) -#define REPORT_VERSION_1(name, major) \ - REPORT(name "_VERSION", XSTRING(major)) -#define REPORT_VERSION_STRING(name, value) \ - REPORT(name "_VERSION_STRING", value) -#define REPORT_COMPATIBILITY(name) \ - REPORT(name "_COMPATIBILITY", "ON") -#define REPORT_NAME(name) \ - REPORT("NAME", name) +#define REPORT_SLUG "COMPILER" +#include "report.h" // GCC diff --git a/cmake/DaemonPlatform/Compiler/Compiler.cpp b/cmake/DaemonPlatform/Detection/Compiler.cpp similarity index 100% rename from cmake/DaemonPlatform/Compiler/Compiler.cpp rename to cmake/DaemonPlatform/Detection/Compiler.cpp diff --git a/cmake/DaemonPlatform/System/System.c b/cmake/DaemonPlatform/Detection/System.c similarity index 92% rename from cmake/DaemonPlatform/System/System.c rename to cmake/DaemonPlatform/Detection/System.c index 71f3d53bcd..130136e45a 100644 --- a/cmake/DaemonPlatform/System/System.c +++ b/cmake/DaemonPlatform/Detection/System.c @@ -28,20 +28,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================== */ +#define REPORT_SLUG "SYSTEM" +#include "report.h" + #if defined(__APPLE__) && defined(__MACH__) #include #endif -#define STRING(s) #s -#define XSTRING(s) STRING(s) - -#define REPORT(key, value) \ - "REPORT>" -#define REPORT_COMPATIBILITY(name) \ - REPORT(name "_COMPATIBILITY", "ON") -#define REPORT_NAME(name) \ - REPORT("NAME", name) - #if defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) #pragma message(REPORT_COMPATIBILITY("Linux")) #endif diff --git a/cmake/DaemonPlatform/Compiler/Compiler.sh b/cmake/DaemonPlatform/Detection/detect similarity index 69% rename from cmake/DaemonPlatform/Compiler/Compiler.sh rename to cmake/DaemonPlatform/Detection/detect index 03ad794cc6..8bf3503be6 100755 --- a/cmake/DaemonPlatform/Compiler/Compiler.sh +++ b/cmake/DaemonPlatform/Detection/detect @@ -27,23 +27,33 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Test script not used by the CMake build system. Usage example: -# ./Compiler.sh gcc +# ./detect gcc set -ueo pipefail script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -file_path="${script_dir}/Compiler.c" -# PNaCl doesn't work with “-o /dev/null” as it uses the output path as a -# pattern for temporary files and then the parent folder should be writable. -# Zig caches the build if both the source and the output don't change. Since -# the /dev/null file never changes, Zig skips the compilation once done once. -# So we need to use a randomly named path in a writable directory. -temp_file="$(mktemp)" +if [ -z "${1:-}" ] +then + echo "ERROR: missing compiler" >&2 + false +fi -"${@}" "${file_path}" -o "${temp_file}" 2>&1 \ - | grep 'REPORT>.*//' \ -|| "${@}" "${file_path}" -o "${temp_file}" +for base_name in Compiler System Architecture +do + file_path="${script_dir}/${base_name}.c" -rm "${temp_file}" + # PNaCl doesn't work with “-o /dev/null” as it uses the output path as a + # pattern for temporary files and then the parent folder should be writable. + # Zig caches the build if both the source and the output don't change. Since + # the /dev/null file never changes, Zig skips the compilation once done once. + # So we need to use a randomly named path in a writable directory. + temp_file="$(mktemp)" + + "${@}" "${file_path}" -o "${temp_file}" 2>&1 \ + | grep 'REPORT>.*//' \ + || "${@}" "${file_path}" -o "${temp_file}" + + rm "${temp_file}" +done diff --git a/cmake/DaemonPlatform/Architecture/qprocessordetection.h b/cmake/DaemonPlatform/Detection/qprocessordetection.h similarity index 100% rename from cmake/DaemonPlatform/Architecture/qprocessordetection.h rename to cmake/DaemonPlatform/Detection/qprocessordetection.h diff --git a/cmake/DaemonPlatform/Detection/report.h b/cmake/DaemonPlatform/Detection/report.h new file mode 100644 index 0000000000..f819d290ee --- /dev/null +++ b/cmake/DaemonPlatform/Detection/report.h @@ -0,0 +1,47 @@ +/* +=========================================================================== +Daemon BSD Source Code +Copyright (c) 2024-2025, Daemon Developers +All rights reserveid. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Daemon developers nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=========================================================================== +*/ + +#define STRING(s) #s +#define XSTRING(s) STRING(s) + +#define REPORT(key, value) \ + "REPORT>" +#define REPORT_VERSION_3(name, major, minor, patch) \ + REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor) "." XSTRING(patch)) +#define REPORT_VERSION_2(name, major, minor) \ + REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor)) +#define REPORT_VERSION_1(name, major) \ + REPORT(name "_VERSION", XSTRING(major)) +#define REPORT_VERSION_STRING(name, value) \ + REPORT(name "_VERSION_STRING", value) +#define REPORT_COMPATIBILITY(name) \ + REPORT(name "_COMPATIBILITY", "ON") +#define REPORT_NAME(name) \ + REPORT("NAME", name) diff --git a/cmake/DaemonPlatform/Platform.cmake b/cmake/DaemonPlatform/Platform.cmake index 58a691f446..0e79eec906 100644 --- a/cmake/DaemonPlatform/Platform.cmake +++ b/cmake/DaemonPlatform/Platform.cmake @@ -30,11 +30,7 @@ ################################################################################ # Source generation. -include(${CMAKE_CURRENT_LIST_DIR}/SourceGenerator.cmake) +include("${CMAKE_CURRENT_LIST_DIR}/SourceGenerator.cmake") -# Target detection. -include(${CMAKE_CURRENT_LIST_DIR}/System.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/Architecture.cmake) - -# Compiler detection. -include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake) +# System, architecture and compiler detection. +include("${CMAKE_CURRENT_LIST_DIR}/Detection.cmake") diff --git a/cmake/DaemonPlatform/System.cmake b/cmake/DaemonPlatform/System.cmake index 453184b91d..bc7cd1c617 100644 --- a/cmake/DaemonPlatform/System.cmake +++ b/cmake/DaemonPlatform/System.cmake @@ -67,36 +67,7 @@ function(daemon_detect_host_system) endfunction() function(daemon_detect_system) - try_compile(BUILD_RESULT - "${CMAKE_BINARY_DIR}" - "${CMAKE_CURRENT_LIST_DIR}/System/System.c" - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - OUTPUT_VARIABLE BUILD_LOG - ) - - if (NOT BUILD_RESULT) - message(WARNING "Failed to build System.c, relying on CMake builtin detection.") - set(system_name "Unknown") - else() - set(BUILD_LOG "\n${BUILD_LOG}\n") - string(REGEX REPLACE "\n[^\n]*REPORT>[^\n]*\n" "\n" BUILD_LOG "${BUILD_LOG}") - - string(REGEX REPLACE ".*\nDAEMON_SYSTEM_NAME=([^\n]*)\n.*" "\\1" - system_name "${BUILD_LOG}") - - foreach(name Linux;Unix;${system_name}) - set(compatibility_regex ".*\nDAEMON_SYSTEM_${name}_COMPATIBILITY=([^\n]*)\n.*") - if ("${BUILD_LOG}" MATCHES ${compatibility_regex}) - string(REGEX REPLACE ${compatibility_regex} "\\1" - system_${name}_compatibility "${BUILD_LOG}") - endif() - - set(DAEMON_SYSTEM_${name}_COMPATIBILITY - "${system_${name}_compatibility}" - PARENT_SCOPE) - endforeach() - endif() + daemon_run_detection("" "SYSTEM" "System.c" "Linux;Unix") if (system_name STREQUAL "Unknown") detect_cmake_host_system("system_name") @@ -133,7 +104,7 @@ if (NOT "${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "${DAEMON_SYSTEM_NAME}") message(STATUS "Detected cross-compilation") endif() -# Makes possible to do things like: +# Makes possible to do that in CMake code: # > if (DAEMON_HOST_SYSTEM_Linux) # > if (DAEMON_SYSTEM_Windows) set("DAEMON_HOST_SYSTEM_${DAEMON_HOST_SYSTEM_NAME}" ON) diff --git a/cmake/DaemonPlatform/System/System.sh b/cmake/DaemonPlatform/System/System.sh deleted file mode 100755 index 7ebc552b54..0000000000 --- a/cmake/DaemonPlatform/System/System.sh +++ /dev/null @@ -1,49 +0,0 @@ -#! /usr/bin/env bash - -# Daemon BSD Source Code -# Copyright (c) 2025, Daemon Developers -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Test script not used by the CMake build system. Usage example: -# ./System.sh gcc - -set -ueo pipefail - -script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -file_path="${script_dir}/System.c" - -# PNaCl doesn't work with “-o /dev/null” as it uses the output path as a -# pattern for temporary files and then the parent folder should be writable. -# Zig caches the build if both the source and the output don't change. Since -# the /dev/null file never changes, Zig skips the compilation once done once. -# So we need to use a randomly named path in a writable directory. -temp_file="$(mktemp)" - -"${@}" "${file_path}" -o "${temp_file}" 2>&1 \ - | grep 'REPORT>.*//' \ -|| "${@}" "${file_path}" -o "${temp_file}" - -rm "${temp_file}" From 89292c5d4d508b110a3cf7eda03b733249e3c822 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 21:13:36 +0100 Subject: [PATCH 07/14] cmake: do not write buildinfo files when SourceGenerator isn't included --- cmake/DaemonPlatform/Architecture.cmake | 8 +++++--- cmake/DaemonPlatform/Compiler.cmake | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/DaemonPlatform/Architecture.cmake b/cmake/DaemonPlatform/Architecture.cmake index 5619021a22..71de072488 100644 --- a/cmake/DaemonPlatform/Architecture.cmake +++ b/cmake/DaemonPlatform/Architecture.cmake @@ -121,6 +121,8 @@ daemon_set_intrinsics() set("DAEMON_ARCH_${DAEMON_ARCH}" ON) set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH}" ON) -# Add printable strings to the executable. -daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") -daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"") +if (DAEMON_SOURCE_GENERATOR) + # Add printable strings to the executable. + daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") + daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"") +endif() diff --git a/cmake/DaemonPlatform/Compiler.cmake b/cmake/DaemonPlatform/Compiler.cmake index 5a9cd5519c..bd4af175f4 100644 --- a/cmake/DaemonPlatform/Compiler.cmake +++ b/cmake/DaemonPlatform/Compiler.cmake @@ -198,6 +198,8 @@ foreach(lang C;CXX) # > if (DAEMON_CXX_COMPILER_Clang) set("${compiler_var_name}" ON) - # Add printable string to the executable. - daemon_add_buildinfo("char*" "DAEMON_${lang}_COMPILER_STRING" "\"${DAEMON_${lang}_COMPILER_STRING}\"") + if (DAEMON_SOURCE_GENERATOR) + # Add printable string to the executable. + daemon_add_buildinfo("char*" "DAEMON_${lang}_COMPILER_STRING" "\"${DAEMON_${lang}_COMPILER_STRING}\"") + endif() endforeach() From 004ff4bbfd1501e86e76cf7d5fe86a372ab79fe9 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 21:26:09 +0100 Subject: [PATCH 08/14] =?UTF-8?q?cmake:=20report=20native=20NaCl=20nexe=20?= =?UTF-8?q?architecture=20and=20=E2=80=9Cpnacl=E2=80=9D=20for=20pexe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake/DaemonPlatform/Detection/Architecture.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/DaemonPlatform/Detection/Architecture.c b/cmake/DaemonPlatform/Detection/Architecture.c index 9404693858..ae973a210a 100644 --- a/cmake/DaemonPlatform/Detection/Architecture.c +++ b/cmake/DaemonPlatform/Detection/Architecture.c @@ -57,8 +57,8 @@ care of platform name variants that are meant to distinguish platform variants we cannot support anyway. */ /* PNaCl virtual machines. */ -#if defined(__native_client__) - #pragma message(REPORT_NAME("nacl")) +#if defined(__pnacl__) + #pragma message(REPORT_NAME("pnacl")) /* Wasm virtual machines, work in progress. */ #elif defined(Q_PROCESSOR_WASM) @@ -107,6 +107,11 @@ platform variants we cannot support anyway. */ #elif defined(Q_PROCESSOR_RISCV_64) #pragma message(REPORT_NAME("riscv64")) +/* Remaining native NaCl architecture. */ + +#elif defined(Q_PROCESSOR_MIPS_32) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + #pragma message(REPORT_NAME("mipsel")) + #else #pragma message(REPORT_NAME("unknown")) #endif From cdce7e4d1300c9de9db1d18c159a37ddf1b89da0 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 21:52:03 +0100 Subject: [PATCH 09/14] cmake: generate printable DAEMON_SYSTEM_STRING --- cmake/DaemonPlatform/System.cmake | 5 +++++ src/common/Platform.h | 8 +++----- src/engine/framework/System.cpp | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmake/DaemonPlatform/System.cmake b/cmake/DaemonPlatform/System.cmake index bc7cd1c617..b0d96a3345 100644 --- a/cmake/DaemonPlatform/System.cmake +++ b/cmake/DaemonPlatform/System.cmake @@ -122,3 +122,8 @@ foreach(name Linux;FreeBSD) endif() endforeach() endforeach() + +if (DAEMON_SOURCE_GENERATOR) + # Add printable string to the executable. + daemon_add_buildinfo("char*" "DAEMON_SYSTEM_STRING" "\"${DAEMON_SYSTEM_NAME}\"") +endif() diff --git a/src/common/Platform.h b/src/common/Platform.h index 1dba232341..15e686a898 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -33,19 +33,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Platform-specific configuration #if defined(_WIN32) -#define PLATFORM_STRING "Windows" #elif defined(__APPLE__) -#define PLATFORM_STRING "macOS" #elif defined(__linux__) -#define PLATFORM_STRING "Linux" #elif defined(__FreeBSD__) -#define PLATFORM_STRING "FreeBSD" #elif defined(__native_client__) -#define PLATFORM_STRING "NaCl" #else #error "Platform not supported" #endif +// TODO: Remove once the game code is ported to DAEMON_SYSTEM_STRING. +#define PLATFORM_STRING DAEMON_SYSTEM_STRING + #if defined(__native_client__) #elif defined(_WIN32) #define DLL_EXT ".dll" diff --git a/src/engine/framework/System.cpp b/src/engine/framework/System.cpp index 4f697ce3be..b5291bbe3e 100644 --- a/src/engine/framework/System.cpp +++ b/src/engine/framework/System.cpp @@ -845,7 +845,7 @@ static void Init(int argc, char** argv) #endif // Print a banner and a copy of the command-line arguments - Log::Notice("%s %s %s (%s) %s", Q3_VERSION, PLATFORM_STRING, DAEMON_ARCH_STRING, DAEMON_CXX_COMPILER_STRING, __DATE__); + Log::Notice("%s %s %s (%s) %s", Q3_VERSION, DAEMON_SYSTEM_STRING, DAEMON_ARCH_STRING, DAEMON_CXX_COMPILER_STRING, __DATE__); std::string argsString = "cmdline:"; for (int i = 1; i < argc; i++) { From 9d03afbb1529e41320b76e4a9c5f662f7578a2b6 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 16 Dec 2025 22:02:20 +0100 Subject: [PATCH 10/14] cmake: unify the wording of Platform detected names --- CMakeLists.txt | 12 ++++++------ cmake/DaemonFlags.cmake | 4 ++-- cmake/DaemonGame.cmake | 2 +- cmake/DaemonNacl.cmake | 4 ++-- cmake/DaemonPlatform/Architecture.cmake | 22 +++++++++++----------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56da729f86..99fba11fdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) set(DEPS_EXT ".tar.xz") - set(DEPS_ARCH "${DAEMON_ARCH}") + set(DEPS_ARCH "${DAEMON_ARCH_NAME}") if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) set(DEPS_COMPILER msvc) @@ -681,10 +681,10 @@ if (BUILD_CLIENT OR DAEMON_SYSTEM_Windows) set(sdlvar_amd64 SDL_CPU_X64) set(sdlvar_armhf SDL_CPU_ARM32) set(sdlvar_arm64 SDL_CPU_ARM64) - if (sdlvar_${DAEMON_ARCH}) - set(${sdlvar_${DAEMON_ARCH}} 1) + if (sdlvar_${DAEMON_ARCH_NAME}) + set(${sdlvar_${DAEMON_ARCH_NAME}} 1) else() - message("Developer TODO: translate architecture ${DAEMON_ARCH} for SDL") + message("Developer TODO: translate architecture ${DAEMON_ARCH_NAME} for SDL") endif() find_package(SDL3 REQUIRED CONFIG) @@ -978,8 +978,8 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH}.nexe - ${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH}.nexe + ${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe + ${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe ) # Linux uses a bootstrap program to reserve address space diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index f51903066f..9961a7974f 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -535,7 +535,7 @@ else() elseif(DAEMON_ARCH_amd64) set_linker_flag("-Wl,-e,mainCRTStartup") else() - message(FATAL_ERROR "Unsupported architecture ${DAEMON_ARCH}") + message(FATAL_ERROR "Unsupported architecture ${DAEMON_ARCH_NAME}") endif() endif() endif() @@ -672,7 +672,7 @@ elseif (NOT DAEMON_SYSTEM_NaCl) unset(GCC_GENERIC_TUNE) set(GCC_GENERIC_CPU "power5") else() - message(WARNING "Unknown architecture ${DAEMON_ARCH}") + message(WARNING "Unknown architecture ${DAEMON_ARCH_NAME}") endif() if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig") diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index b5b37fd580..93581f0437 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -81,7 +81,7 @@ if (NOT FORK EQUAL 2) if (BUILD_GAME_NACL_TARGETS STREQUAL "all") set(NACL_TARGETS "${NACL_ALL_TARGETS}") elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native") - set(NACL_TARGETS "${DAEMON_ARCH}") + set(NACL_TARGETS "${DAEMON_ARCH_NAME}") elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none") set(NACL_TARGETS "") else() diff --git a/cmake/DaemonNacl.cmake b/cmake/DaemonNacl.cmake index 959edc620f..ae31641487 100644 --- a/cmake/DaemonNacl.cmake +++ b/cmake/DaemonNacl.cmake @@ -31,7 +31,7 @@ option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF) if (DAEMON_SYSTEM_NaCl) # Build nexe binary. if(USE_NACL_SAIGO) - # DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET carries the architecture. + # DAEMON_NACL_ARCH_NAME is "pnacl" here, NACL_TARGET carries the architecture. if (NACL_TARGET STREQUAL "amd64") add_definitions(-DNACL_BUILD_ARCH=x86) add_definitions(-DNACL_BUILD_SUBARCH=64) @@ -47,7 +47,7 @@ if (DAEMON_SYSTEM_NaCl) # Those defines looks to be meaningless to produce arch-independent pexe # with PNaCl but they must be set to anything supported by native builds. # This requirement looks to be a PNaCl bug. - # DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET is not set. + # DAEMON_NACL_ARCH_NAME is "pnacl" here, NACL_TARGET is not set. add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=64 ) endif() diff --git a/cmake/DaemonPlatform/Architecture.cmake b/cmake/DaemonPlatform/Architecture.cmake index 71de072488..9277b7e406 100644 --- a/cmake/DaemonPlatform/Architecture.cmake +++ b/cmake/DaemonPlatform/Architecture.cmake @@ -36,7 +36,7 @@ mark_as_advanced(USE_ARCH_INTRINSICS) function(daemon_detect_arch) daemon_run_detection("" "ARCH" "Architecture.c" "") - set(DAEMON_ARCH "${arch_name}" PARENT_SCOPE) + set(DAEMON_ARCH_NAME "${arch_name}" PARENT_SCOPE) message(STATUS "Detected target architecture: ${arch_name}") @@ -71,8 +71,8 @@ function(daemon_detect_arch) endif() endif() - # The DAEMON_NACL_ARCH variable contributes to the nexe file name. - set(DAEMON_NACL_ARCH "${nacl_arch}" PARENT_SCOPE) + # The DAEMON_NACL_ARCH_NAME variable contributes to the nexe file name. + set(DAEMON_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) # NaCl runtime is only available on architectures that have a NaCl loader. set(nacl_runtime_arch amd64 i686 armhf) @@ -98,17 +98,17 @@ function(daemon_set_intrinsics) # Makes possible to do that in C++ code: # > if defined(DAEMON_USE_ARCH_INTRINSICS_amd64) # > if defined(DAEMON_USE_ARCH_INTRINSICS_i686) - daemon_set_arch_intrinsics("${DAEMON_ARCH}") + daemon_set_arch_intrinsics("${DAEMON_ARCH_NAME}") set(amd64_PARENT "i686") set(arm64_PARENT "armhf") set(ppc64el_PARENT "ppc64") - if ("${DAEMON_ARCH}_PARENT") - daemon_set_arch_intrinsics("${${DAEMON_ARCH}_PARENT}") + if ("${DAEMON_ARCH_NAME}_PARENT") + daemon_set_arch_intrinsics("${${DAEMON_ARCH_NAME}_PARENT}") endif() else() - message(STATUS "Disabling ${DAEMON_ARCH} architecture intrinsics") + message(STATUS "Disabling ${DAEMON_ARCH_NAME} architecture intrinsics") endif() endfunction() @@ -118,11 +118,11 @@ daemon_set_intrinsics() # Makes possible to do that in CMake code: # > if (DAEMON_ARCH_arm64) # > if (DAEMON_NACL_ARCH_armhf) -set("DAEMON_ARCH_${DAEMON_ARCH}" ON) -set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH}" ON) +set("DAEMON_ARCH_${DAEMON_ARCH_NAME}" ON) +set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH_NAME}" ON) if (DAEMON_SOURCE_GENERATOR) # Add printable strings to the executable. - daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"") - daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"") + daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH_NAME}\"") + daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"") endif() From 8498844fa6520c0cbf8e64e8cbbf361cb2bc657b Mon Sep 17 00:00:00 2001 From: "dev@illwieckz.net" Date: Thu, 4 Jun 2026 16:32:17 +0200 Subject: [PATCH 11/14] cmake: rewrite comments --- cmake/DaemonPlatform/Detection.cmake | 4 ++++ cmake/DaemonPlatform/Platform.cmake | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/DaemonPlatform/Detection.cmake b/cmake/DaemonPlatform/Detection.cmake index 8418e37fea..31460a4dc5 100644 --- a/cmake/DaemonPlatform/Detection.cmake +++ b/cmake/DaemonPlatform/Detection.cmake @@ -24,6 +24,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +################################################################################ +# System, architecture and compiler detection. +################################################################################ + # Make sure to always call this macro from within a function, not in the global scope. # As a macro it produces a lot of variables in the parent scope but it is meant to # only be called by functions so they should never pollute the globale scope. diff --git a/cmake/DaemonPlatform/Platform.cmake b/cmake/DaemonPlatform/Platform.cmake index 0e79eec906..5265e0e9db 100644 --- a/cmake/DaemonPlatform/Platform.cmake +++ b/cmake/DaemonPlatform/Platform.cmake @@ -29,7 +29,7 @@ # projects. ################################################################################ -# Source generation. +# Source generation and file embedding. include("${CMAKE_CURRENT_LIST_DIR}/SourceGenerator.cmake") # System, architecture and compiler detection. From 1c32a2cc1530c31a3a7a7e1eab34edfc916b7a6b Mon Sep 17 00:00:00 2001 From: "dev@illwieckz.net" Date: Thu, 4 Jun 2026 16:31:40 +0200 Subject: [PATCH 12/14] cmake: rename DaemonPlatform to Yokai, use custom variable slug --- CMakeLists.txt | 12 +-- cmake/DaemonGame.cmake | 5 +- cmake/DaemonYokai.cmake | 32 +++++++ .../Platform.cmake => Yokai/All.cmake} | 0 .../Architecture.cmake | 66 +++++++------- .../{DaemonPlatform => Yokai}/Compiler.cmake | 62 ++++++------- .../{DaemonPlatform => Yokai}/Detection.cmake | 16 ++-- .../Detection/Architecture.c | 0 .../Detection/Compiler.c | 0 .../Detection/Compiler.cpp | 0 .../Detection/System.c | 0 .../Detection/detect | 0 .../Detection/qprocessordetection.h | 0 .../Detection/report.h | 2 +- .../FileEmbedder.cmake | 0 .../SourceGenerator.cmake | 90 ++++++++++--------- cmake/{DaemonPlatform => Yokai}/System.cmake | 60 ++++++------- cmake/Yokai/Variable.cmake | 48 ++++++++++ 18 files changed, 239 insertions(+), 154 deletions(-) create mode 100644 cmake/DaemonYokai.cmake rename cmake/{DaemonPlatform/Platform.cmake => Yokai/All.cmake} (100%) rename cmake/{DaemonPlatform => Yokai}/Architecture.cmake (63%) rename cmake/{DaemonPlatform => Yokai}/Compiler.cmake (70%) rename cmake/{DaemonPlatform => Yokai}/Detection.cmake (87%) rename cmake/{DaemonPlatform => Yokai}/Detection/Architecture.c (100%) rename cmake/{DaemonPlatform => Yokai}/Detection/Compiler.c (100%) rename cmake/{DaemonPlatform => Yokai}/Detection/Compiler.cpp (100%) rename cmake/{DaemonPlatform => Yokai}/Detection/System.c (100%) rename cmake/{DaemonPlatform => Yokai}/Detection/detect (100%) rename cmake/{DaemonPlatform => Yokai}/Detection/qprocessordetection.h (100%) rename cmake/{DaemonPlatform => Yokai}/Detection/report.h (97%) rename cmake/{DaemonPlatform => Yokai}/FileEmbedder.cmake (100%) rename cmake/{DaemonPlatform => Yokai}/SourceGenerator.cmake (54%) rename cmake/{DaemonPlatform => Yokai}/System.cmake (63%) create mode 100644 cmake/Yokai/Variable.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 99fba11fdf..51a22aa980 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ if (Daemon_OUT) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Daemon_OUT}) endif() -include(DaemonPlatform/Platform) +include(DaemonYokai) ################################################################################ # Configuration options @@ -587,7 +587,7 @@ else() message(STATUS "Found OpenGL ABI: ${OpenGL_selected_ABI}") message(STATUS "Found OpenGL library: ${OpenGL_selected_LIBRARY}") - daemon_add_buildinfo("char*" "DAEMON_OPENGL_ABI_STRING" "\"${OpenGL_selected_ABI}\"") + yokai_add_buildinfo("char*" "DAEMON_OPENGL_ABI_STRING" "\"${OpenGL_selected_ABI}\"") add_definitions("-DDAEMON_OPENGL_ABI_${OpenGL_selected_ABI}") add_definitions("-DDAEMON_OPENGL_ABI") endif() @@ -639,7 +639,7 @@ endif() if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP) if (NACL_RUNTIME_PATH) - daemon_add_buildinfo("char*" "DAEMON_NACL_RUNTIME_PATH_STRING" "\"${NACL_RUNTIME_PATH}\"") + yokai_add_buildinfo("char*" "DAEMON_NACL_RUNTIME_PATH_STRING" "\"${NACL_RUNTIME_PATH}\"") add_definitions("-DDAEMON_NACL_RUNTIME_PATH") endif() @@ -877,7 +877,7 @@ function(AddApplication) ADD_PRECOMPILED_HEADER(${A_Target}-objects) endfunction() -daemon_write_buildinfo("Engine") +yokai_write_buildinfo("Engine") if (NOT DAEMON_SYSTEM_NaCl) add_library(engine-lib EXCLUDE_FROM_ALL ${PCH_FILE} ${BUILDINFOLIST} ${COMMONLIST} ${ENGINELIST}) @@ -930,9 +930,9 @@ if (BUILD_CLIENT) ) # Generate GLSL include files. - daemon_embed_files("EngineShaders" "${GLSL_EMBED_DIR}" "${GLSL_EMBED_LIST}" "TEXT" "client-objects") + yokai_embed_files("EngineShaders" "${GLSL_EMBED_DIR}" "${GLSL_EMBED_LIST}" "TEXT" "client-objects") - daemon_embed_files(ConsoleFont "${CMAKE_CURRENT_SOURCE_DIR}/libs/unifont" unifont.otf BINARY client-objects) + yokai_embed_files(ConsoleFont "${CMAKE_CURRENT_SOURCE_DIR}/libs/unifont" unifont.otf BINARY client-objects) endif() if (BUILD_SERVER) diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index 93581f0437..c98eae1fab 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -39,7 +39,8 @@ option(BUILD_GAME_NATIVE_DLL "Build the shared library files, mostly useful for option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for better performances by server owners" OFF) include(ExternalProject) -include(DaemonPlatform/Platform) + +include(DaemonYokai) # Do not report unused native compiler if native vms are not built. # If only NACL vms are built, this will be reported in chainloaded build. @@ -106,7 +107,7 @@ if (NOT FORK EQUAL 2) endif() endif() -daemon_write_buildinfo("Game") +yokai_write_buildinfo("Game") function(buildGameModule module_slug) set(module_target "${GAMEMODULE_NAME}-${module_slug}") diff --git a/cmake/DaemonYokai.cmake b/cmake/DaemonYokai.cmake new file mode 100644 index 0000000000..5fbdf19972 --- /dev/null +++ b/cmake/DaemonYokai.cmake @@ -0,0 +1,32 @@ +# Daemon BSD Source Code +# Copyright (c) 2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +################################################################################ +# Initialize Yokai CMake helpers. +################################################################################ + +set(YOKAI_FILE_SLUG "Daemon") +include(Yokai/All) diff --git a/cmake/DaemonPlatform/Platform.cmake b/cmake/Yokai/All.cmake similarity index 100% rename from cmake/DaemonPlatform/Platform.cmake rename to cmake/Yokai/All.cmake diff --git a/cmake/DaemonPlatform/Architecture.cmake b/cmake/Yokai/Architecture.cmake similarity index 63% rename from cmake/DaemonPlatform/Architecture.cmake rename to cmake/Yokai/Architecture.cmake index 9277b7e406..2332e783d4 100644 --- a/cmake/DaemonPlatform/Architecture.cmake +++ b/cmake/Yokai/Architecture.cmake @@ -28,23 +28,23 @@ # Architecture detection. ################################################################################ -# When adding a new architecture, look at all the places DAEMON_ARCH is used. +# When adding a new architecture, look at all the places ${YOKAI_CMAKE_SLUG}_ARCH is used. option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON) mark_as_advanced(USE_ARCH_INTRINSICS) -function(daemon_detect_arch) - daemon_run_detection("" "ARCH" "Architecture.c" "") +function(yokai_detect_arch) + yokai_run_detection("" "ARCH" "Architecture.c" "") - set(DAEMON_ARCH_NAME "${arch_name}" PARENT_SCOPE) + set(${YOKAI_CMAKE_SLUG}_ARCH_NAME "${arch_name}" PARENT_SCOPE) message(STATUS "Detected target architecture: ${arch_name}") - add_definitions(-DDAEMON_ARCH_${arch_name}) + add_definitions(-D${YOKAI_C_PREFIX}_ARCH_${arch_name}) set(nacl_arch "${arch_name}") - if (DAEMON_SYSTEM_Linux_COMPATIBILITY) + if (${YOKAI_CMAKE_SLUG}_SYSTEM_Linux_COMPATIBILITY) set(armhf_usage "arm64;armel") if ("${arch_name}" IN_LIST armhf_usage) # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. @@ -53,17 +53,17 @@ function(daemon_detect_arch) set(box64_usage ppc64el riscv64) if ("${arch_name}" IN_LIST box64_usage) - option(DAEMON_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) - if (DAEMON_NACL_BOX64_EMULATION) + option(${YOKAI_CMAKE_SLUG}_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) + if (${YOKAI_CMAKE_SLUG}_NACL_BOX64_EMULATION) # Use Box64 to run x86_64 NaCl loader and amd64 nexe. # Box64 must be installed and available in PATH at runtime. set(nacl_arch "amd64") - add_definitions(-DDAEMON_NACL_BOX64_EMULATION) + add_definitions(-D${YOKAI_C_PREFIX}_NACL_BOX64_EMULATION) endif() endif() endif() - elseif (DAEMON_SYSTEM_macOS) + elseif (${YOKAI_CMAKE_SLUG}_SYSTEM_macOS) if ("${arch_name}" STREQUAL "arm64") # You can get emulated NaCl going like this: # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ @@ -71,58 +71,58 @@ function(daemon_detect_arch) endif() endif() - # The DAEMON_NACL_ARCH_NAME variable contributes to the nexe file name. - set(DAEMON_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) + # The ${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME variable contributes to the nexe file name. + set(${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) # NaCl runtime is only available on architectures that have a NaCl loader. set(nacl_runtime_arch amd64 i686 armhf) if ("${nacl_arch}" IN_LIST nacl_runtime_arch) - add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED) + add_definitions(-D${YOKAI_CMAKE_SLUG}_NACL_RUNTIME_ENABLED) endif() endfunction() -function(daemon_set_arch_intrinsics name) +function(yokai_set_arch_intrinsics name) message(STATUS "Enabling ${name} architecture intrinsics") - add_definitions(-DDAEMON_USE_ARCH_INTRINSICS_${name}) + add_definitions(-D${YOKAI_C_PREFIX}_USE_ARCH_INTRINSICS_${name}) endfunction() option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON) mark_as_advanced(USE_ARCH_INTRINSICS) -function(daemon_set_intrinsics) +function(yokai_set_intrinsics) if (USE_ARCH_INTRINSICS) # Makes possible to do that in C++ code: - # > if defined(DAEMON_USE_ARCH_INTRINSICS) - add_definitions(-DDAEMON_USE_ARCH_INTRINSICS) + # > if defined(${YOKAI_CMAKE_SLUG}_USE_ARCH_INTRINSICS) + add_definitions(-D${YOKAI_C_PREFIX}_USE_ARCH_INTRINSICS) # Makes possible to do that in C++ code: - # > if defined(DAEMON_USE_ARCH_INTRINSICS_amd64) - # > if defined(DAEMON_USE_ARCH_INTRINSICS_i686) - daemon_set_arch_intrinsics("${DAEMON_ARCH_NAME}") + # > if defined(${YOKAI_CMAKE_SLUG}_USE_ARCH_INTRINSICS_amd64) + # > if defined(${YOKAI_CMAKE_SLUG}_USE_ARCH_INTRINSICS_i686) + yokai_set_arch_intrinsics("${${YOKAI_CMAKE_SLUG}_ARCH_NAME}") set(amd64_PARENT "i686") set(arm64_PARENT "armhf") set(ppc64el_PARENT "ppc64") - if ("${DAEMON_ARCH_NAME}_PARENT") - daemon_set_arch_intrinsics("${${DAEMON_ARCH_NAME}_PARENT}") + if ("${${YOKAI_CMAKE_SLUG}_ARCH_NAME}_PARENT") + yokai_set_arch_intrinsics("${${${YOKAI_CMAKE_SLUG}_ARCH_NAME}_PARENT}") endif() else() - message(STATUS "Disabling ${DAEMON_ARCH_NAME} architecture intrinsics") + message(STATUS "Disabling ${${YOKAI_CMAKE_SLUG}_ARCH_NAME} architecture intrinsics") endif() endfunction() -daemon_detect_arch() -daemon_set_intrinsics() +yokai_detect_arch() +yokai_set_intrinsics() # Makes possible to do that in CMake code: -# > if (DAEMON_ARCH_arm64) -# > if (DAEMON_NACL_ARCH_armhf) -set("DAEMON_ARCH_${DAEMON_ARCH_NAME}" ON) -set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH_NAME}" ON) +# > if (${YOKAI_CMAKE_SLUG}_ARCH_arm64) +# > if (${YOKAI_CMAKE_SLUG}_NACL_ARCH_armhf) +set("${YOKAI_CMAKE_SLUG}_ARCH_${${YOKAI_CMAKE_SLUG}_ARCH_NAME}" ON) +set("${YOKAI_CMAKE_SLUG}_NACL_ARCH_${${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME}" ON) -if (DAEMON_SOURCE_GENERATOR) +if (${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR) # Add printable strings to the executable. - daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH_NAME}\"") - daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"") + yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_ARCH_STRING" "\"${${YOKAI_CMAKE_SLUG}_ARCH_NAME}\"") + yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_NACL_ARCH_STRING" "\"${${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME}\"") endif() diff --git a/cmake/DaemonPlatform/Compiler.cmake b/cmake/Yokai/Compiler.cmake similarity index 70% rename from cmake/DaemonPlatform/Compiler.cmake rename to cmake/Yokai/Compiler.cmake index bd4af175f4..d490e88126 100644 --- a/cmake/DaemonPlatform/Compiler.cmake +++ b/cmake/Yokai/Compiler.cmake @@ -28,10 +28,10 @@ # Compiler detection. ################################################################################ -# When adding a new compiler, look at all the places DAEMON_C_COMPILER -# and DAEMON_CXX_COMPILER are used. +# When adding a new compiler, look at all the places ${YOKAI_CMAKE_SLUG}_C_COMPILER +# and ${YOKAI_CMAKE_SLUG}_CXX_COMPILER are used. -function(daemon_detect_compiler lang) +function(yokai_detect_compiler lang) set(C_NAME "C") set(CXX_NAME "C++") set(C_EXT ".c") @@ -39,7 +39,7 @@ function(daemon_detect_compiler lang) get_filename_component(compiler_basename "${CMAKE_${lang}_COMPILER}" NAME) - daemon_run_detection("${lang}_" "COMPILER" "Compiler${${lang}_EXT}" "GCC;Clang;generic") + yokai_run_detection("${lang}_" "COMPILER" "Compiler${${lang}_EXT}" "GCC;Clang;generic") if (compiler_name STREQUAL "Unknown") if (CMAKE_${lang}_COMPILER_ID) @@ -126,9 +126,9 @@ function(daemon_detect_compiler lang) message(WARNING "Unknown ${${lang}_NAME} compiler version") endif() - set(DAEMON_${lang}_COMPILER_BASENAME "${compiler_basename}" PARENT_SCOPE) - set(DAEMON_${lang}_COMPILER_NAME "${compiler_name}" PARENT_SCOPE) - set(DAEMON_${lang}_COMPILER_VERSION "${compiler_version}" PARENT_SCOPE) + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_BASENAME "${compiler_basename}" PARENT_SCOPE) + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME "${compiler_name}" PARENT_SCOPE) + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION "${compiler_version}" PARENT_SCOPE) endfunction() message(STATUS "CMake generator: ${CMAKE_GENERATOR}") @@ -140,20 +140,20 @@ foreach(lang C;CXX) if (MSVC) # Let CMake do the job, it does it very well, # and there is probably no variant to take care about. - set(DAEMON_${lang}_COMPILER_MSVC_COMPATIBILITY ON) - set(DAEMON_${lang}_COMPILER_NAME "${CMAKE_${lang}_COMPILER_ID}") - set(DAEMON_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}") - get_filename_component(DAEMON_${lang}_COMPILER_BASENAME "${CMAKE_${lang}_COMPILER}" NAME) + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_MSVC_COMPATIBILITY ON) + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME "${CMAKE_${lang}_COMPILER_ID}") + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}") + get_filename_component(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_BASENAME "${CMAKE_${lang}_COMPILER}" NAME) else() - daemon_detect_compiler(${lang}) + yokai_detect_compiler(${lang}) - if (DAEMON_${lang}_COMPILER_Clang_COMPATIBILITY) - if (NOT DAEMON_${lang}_COMPILER_NAME STREQUAL "Clang") - set(DAEMON_${lang}_COMPILER_EXTENDED_VERSION - "${DAEMON_${lang}_COMPILER_VERSION}/Clang_${DAEMON_${lang}_COMPILER_Clang_VERSION}") + if (${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_Clang_COMPATIBILITY) + if (NOT ${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME STREQUAL "Clang") + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION + "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION}/Clang_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_Clang_VERSION}") endif() - elseif (DAEMON_${lang}_COMPILER_GCC_COMPATIBILITY) - if (NOT DAEMON_${lang}_COMPILER_NAME STREQUAL "GCC") + elseif (${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_GCC_COMPATIBILITY) + if (NOT ${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME STREQUAL "GCC") # Almost all compilers on Earth pretend to be GCC compatible. # So we first have to check it's really a GCC variant. # Parse “ -v” @@ -168,38 +168,38 @@ foreach(lang C;CXX) # the version of the GCC variant, not the version of the upstream # GCC we are looking for. if ("${CUSTOM_${lang}_GCC_OUTPUT}" MATCHES "\ngcc version ") - set(DAEMON_${lang}_COMPILER_EXTENDED_VERSION - "${DAEMON_${lang}_COMPILER_VERSION}/GCC_${DAEMON_${lang}_COMPILER_GCC_VERSION}") + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION + "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION}/GCC_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_GCC_VERSION}") endif() endif() endif() endif() endif() - if (NOT DAEMON_${lang}_COMPILER_EXTENDED_VERSION) - set(DAEMON_${lang}_COMPILER_EXTENDED_VERSION "${DAEMON_${lang}_COMPILER_VERSION}") + if (NOT ${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION) + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION}") endif() - set(DAEMON_${lang}_COMPILER_STRING - "${DAEMON_${lang}_COMPILER_NAME}_${DAEMON_${lang}_COMPILER_EXTENDED_VERSION}:${DAEMON_${lang}_COMPILER_BASENAME}") + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING + "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME}_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION}:${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_BASENAME}") if (CMAKE_CXX_COMPILER_ARG1) - set(DAEMON_${lang}_COMPILER_STRING "${DAEMON_${lang}_COMPILER_STRING}:${CMAKE_CXX_COMPILER_ARG1}") + set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING}:${CMAKE_CXX_COMPILER_ARG1}") endif() - message(STATUS "Detected ${${lang}_NAME} compiler: ${DAEMON_${lang}_COMPILER_STRING}") + message(STATUS "Detected ${${lang}_NAME} compiler: ${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING}") # Makes possible to do that in C++ code: - # > if defined(DAEMON_CXX_COMPILER_Clang) - set(compiler_var_name "DAEMON_${lang}_COMPILER_${DAEMON_${lang}_COMPILER_NAME}") + # > if defined(${YOKAI_CMAKE_SLUG}_CXX_COMPILER_Clang) + set(compiler_var_name "${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME}") add_definitions(-D${compiler_var_name}) # Makes possible to do that in CMake code: - # > if (DAEMON_CXX_COMPILER_Clang) + # > if (${YOKAI_CMAKE_SLUG}_CXX_COMPILER_Clang) set("${compiler_var_name}" ON) - if (DAEMON_SOURCE_GENERATOR) + if (${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR) # Add printable string to the executable. - daemon_add_buildinfo("char*" "DAEMON_${lang}_COMPILER_STRING" "\"${DAEMON_${lang}_COMPILER_STRING}\"") + yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_${lang}_COMPILER_STRING" "\"${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING}\"") endif() endforeach() diff --git a/cmake/DaemonPlatform/Detection.cmake b/cmake/Yokai/Detection.cmake similarity index 87% rename from cmake/DaemonPlatform/Detection.cmake rename to cmake/Yokai/Detection.cmake index 31460a4dc5..870ea30ce5 100644 --- a/cmake/DaemonPlatform/Detection.cmake +++ b/cmake/Yokai/Detection.cmake @@ -28,12 +28,14 @@ # System, architecture and compiler detection. ################################################################################ +include("${CMAKE_CURRENT_LIST_DIR}/Variable.cmake") + # Make sure to always call this macro from within a function, not in the global scope. # As a macro it produces a lot of variables in the parent scope but it is meant to # only be called by functions so they should never pollute the globale scope. # It's a macro because we need to write a lot of variables in the calling function scope # and we need to write some variables to the parent scope of the calling function. -macro(daemon_run_detection slug_prefix report_slug file_name compat_list) +macro(yokai_run_detection slug_prefix report_slug file_name compat_list) string(TOLOWER "${report_slug}" local_slug) # Setting -Werror in CXXFLAGS would produce errors instead of warning @@ -65,31 +67,31 @@ macro(daemon_run_detection slug_prefix report_slug file_name compat_list) string(REGEX REPLACE "\n[^\n]*REPORT>[^\n]*\n" "\n" build_log "${build_log}") - string(REGEX REPLACE ".*\nDAEMON_${report_slug}_NAME=([^\n]*)\n.*" "\\1" + string(REGEX REPLACE ".*\nYOKAI_${report_slug}_NAME=([^\n]*)\n.*" "\\1" ${local_slug}_name "${build_log}") foreach(name ${compat_list};${${local_slug}_name}) - set(COMPATIBILITY_REGEX ".*\nDAEMON_${report_slug}_${name}_COMPATIBILITY=([^\n]*)\n.*") + set(COMPATIBILITY_REGEX ".*\nYOKAI_${report_slug}_${name}_COMPATIBILITY=([^\n]*)\n.*") if ("${build_log}" MATCHES ${COMPATIBILITY_REGEX}) string(REGEX REPLACE ${COMPATIBILITY_REGEX} "\\1" ${local_slug}_${name}_compatibility "${build_log}") - set("DAEMON_${slug_prefix}${report_slug}_${name}_COMPATIBILITY" + set("${YOKAI_CMAKE_SLUG}_${slug_prefix}${report_slug}_${name}_COMPATIBILITY" "${${local_slug}_${name}_compatibility}" PARENT_SCOPE) endif() - set(VERSION_REGEX ".*\nDAEMON_${report_slug}_${name}_VERSION=([^\n]*)\n.*") + set(VERSION_REGEX ".*\nYOKAI_${report_slug}_${name}_VERSION=([^\n]*)\n.*") if ("${build_log}" MATCHES ${VERSION_REGEX}) string(REGEX REPLACE ${VERSION_REGEX} "\\1" ${local_slug}_${name}_version "${build_log}") - set("DAEMON_${slug_prefix}${report_slug}_${name}_VERSION" + set("${YOKAI_CMAKE_SLUG}_${slug_prefix}${report_slug}_${name}_VERSION" "${${local_slug}_${name}_version}" PARENT_SCOPE) endif() - set(VERSION_STRING_REGEX ".*\nDAEMON_${report_slug}_${name}_VERSION_STRING=([^\n]*)\n.*") + set(VERSION_STRING_REGEX ".*\nYOKAI_${report_slug}_${name}_VERSION_STRING=([^\n]*)\n.*") if ("${build_log}" MATCHES ${VERSION_STRING_REGEX}) string(REGEX REPLACE ${VERSION_STRING_REGEX} "\\1" ${local_slug}_${name}_version_string "${build_log}") diff --git a/cmake/DaemonPlatform/Detection/Architecture.c b/cmake/Yokai/Detection/Architecture.c similarity index 100% rename from cmake/DaemonPlatform/Detection/Architecture.c rename to cmake/Yokai/Detection/Architecture.c diff --git a/cmake/DaemonPlatform/Detection/Compiler.c b/cmake/Yokai/Detection/Compiler.c similarity index 100% rename from cmake/DaemonPlatform/Detection/Compiler.c rename to cmake/Yokai/Detection/Compiler.c diff --git a/cmake/DaemonPlatform/Detection/Compiler.cpp b/cmake/Yokai/Detection/Compiler.cpp similarity index 100% rename from cmake/DaemonPlatform/Detection/Compiler.cpp rename to cmake/Yokai/Detection/Compiler.cpp diff --git a/cmake/DaemonPlatform/Detection/System.c b/cmake/Yokai/Detection/System.c similarity index 100% rename from cmake/DaemonPlatform/Detection/System.c rename to cmake/Yokai/Detection/System.c diff --git a/cmake/DaemonPlatform/Detection/detect b/cmake/Yokai/Detection/detect similarity index 100% rename from cmake/DaemonPlatform/Detection/detect rename to cmake/Yokai/Detection/detect diff --git a/cmake/DaemonPlatform/Detection/qprocessordetection.h b/cmake/Yokai/Detection/qprocessordetection.h similarity index 100% rename from cmake/DaemonPlatform/Detection/qprocessordetection.h rename to cmake/Yokai/Detection/qprocessordetection.h diff --git a/cmake/DaemonPlatform/Detection/report.h b/cmake/Yokai/Detection/report.h similarity index 97% rename from cmake/DaemonPlatform/Detection/report.h rename to cmake/Yokai/Detection/report.h index f819d290ee..43a85c7930 100644 --- a/cmake/DaemonPlatform/Detection/report.h +++ b/cmake/Yokai/Detection/report.h @@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define XSTRING(s) STRING(s) #define REPORT(key, value) \ - "REPORT>" + "REPORT>" #define REPORT_VERSION_3(name, major, minor, patch) \ REPORT(name "_VERSION", XSTRING(major) "." XSTRING(minor) "." XSTRING(patch)) #define REPORT_VERSION_2(name, major, minor) \ diff --git a/cmake/DaemonPlatform/FileEmbedder.cmake b/cmake/Yokai/FileEmbedder.cmake similarity index 100% rename from cmake/DaemonPlatform/FileEmbedder.cmake rename to cmake/Yokai/FileEmbedder.cmake diff --git a/cmake/DaemonPlatform/SourceGenerator.cmake b/cmake/Yokai/SourceGenerator.cmake similarity index 54% rename from cmake/DaemonPlatform/SourceGenerator.cmake rename to cmake/Yokai/SourceGenerator.cmake index 7fc6d71090..be82a4d8c6 100644 --- a/cmake/DaemonPlatform/SourceGenerator.cmake +++ b/cmake/Yokai/SourceGenerator.cmake @@ -1,5 +1,5 @@ -# Daemon BSD Source Code -# Copyright (c) 2025, Daemon Developers +# ${YOKAI_FILE_SLUG} BSD Source Code +# Copyright (c) 2025, ${YOKAI_FILE_SLUG} Developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,71 +28,73 @@ # Source generation and file embedding. ################################################################################ -set(DAEMON_SOURCE_GENERATOR "${CMAKE_CURRENT_LIST_FILE}") +include("${CMAKE_CURRENT_LIST_DIR}/Variable.cmake") + +set(${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR "${CMAKE_CURRENT_LIST_FILE}") get_filename_component(current_list_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(DAEMON_FILE_EMBEDDER "${current_list_dir}/FileEmbedder.cmake") +set(${YOKAI_CMAKE_SLUG}_FILE_EMBEDDER "${current_list_dir}/FileEmbedder.cmake") -set(DAEMON_GENERATED_SUBDIR "GeneratedSource") -set(DAEMON_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DAEMON_GENERATED_SUBDIR}") +set(${YOKAI_CMAKE_SLUG}_GENERATED_SUBDIR "GeneratedSource") +set(${YOKAI_CMAKE_SLUG}_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/${${YOKAI_CMAKE_SLUG}_GENERATED_SUBDIR}") -set(DAEMON_BUILDINFO_SUBDIR "DaemonBuildInfo") -set(DAEMON_EMBEDDED_SUBDIR "DaemonEmbeddedFiles") +set(${YOKAI_CMAKE_SLUG}_BUILDINFO_SUBDIR "${YOKAI_FILE_SLUG}BuildInfo") +set(${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR "${YOKAI_FILE_SLUG}EmbeddedFiles") -set(DAEMON_BUILDINFO_DIR "${DAEMON_GENERATED_DIR}/${DAEMON_BUILDINFO_SUBDIR}") -set(DAEMON_EMBEDDED_DIR "${DAEMON_GENERATED_DIR}/${DAEMON_EMBEDDED_SUBDIR}") +set(${YOKAI_CMAKE_SLUG}_BUILDINFO_DIR "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${${YOKAI_CMAKE_SLUG}_BUILDINFO_SUBDIR}") +set(${YOKAI_CMAKE_SLUG}_EMBEDDED_DIR "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}") -file(MAKE_DIRECTORY "${DAEMON_GENERATED_DIR}") -include_directories("${DAEMON_GENERATED_DIR}") +file(MAKE_DIRECTORY "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}") +include_directories("${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}") -file(MAKE_DIRECTORY "${DAEMON_BUILDINFO_DIR}") -file(MAKE_DIRECTORY "${DAEMON_EMBEDDED_DIR}") +file(MAKE_DIRECTORY "${${YOKAI_CMAKE_SLUG}_BUILDINFO_DIR}") +file(MAKE_DIRECTORY "${${YOKAI_CMAKE_SLUG}_EMBEDDED_DIR}") -set(DAEMON_GENERATED_HEADER "// Automatically generated, do not modify!\n") -set(DAEMON_GENERATED_CPP_EXT ".cpp") -set(DAEMON_GENERATED_H_EXT ".h") +set(${YOKAI_CMAKE_SLUG}_GENERATED_HEADER "// Automatically generated, do not modify!\n") +set(${YOKAI_CMAKE_SLUG}_GENERATED_CPP_EXT ".cpp") +set(${YOKAI_CMAKE_SLUG}_GENERATED_H_EXT ".h") set(BUILDINFOLIST) foreach(kind CPP H) - set(DAEMON_BUILDINFO_${kind}_TEXT "${DAEMON_GENERATED_HEADER}") + set(${YOKAI_CMAKE_SLUG}_BUILDINFO_${kind}_TEXT "${${YOKAI_CMAKE_SLUG}_GENERATED_HEADER}") endforeach() -macro(daemon_add_buildinfo type name value) - string(APPEND DAEMON_BUILDINFO_CPP_TEXT "const ${type} ${name}=${value};\n") - string(APPEND DAEMON_BUILDINFO_H_TEXT "extern const ${type} ${name};\n") +macro(yokai_add_buildinfo type name value) + string(APPEND ${YOKAI_CMAKE_SLUG}_BUILDINFO_CPP_TEXT "const ${type} ${name}=${value};\n") + string(APPEND ${YOKAI_CMAKE_SLUG}_BUILDINFO_H_TEXT "extern const ${type} ${name};\n") endmacro() -macro(daemon_write_buildinfo name) +macro(yokai_write_buildinfo name) foreach(kind CPP H) - set(buildinfo_file_path "${DAEMON_BUILDINFO_DIR}/${name}${DAEMON_GENERATED_${kind}_EXT}") + set(buildinfo_file_path "${${YOKAI_CMAKE_SLUG}_BUILDINFO_DIR}/${name}${${YOKAI_CMAKE_SLUG}_GENERATED_${kind}_EXT}") - file(GENERATE OUTPUT "${buildinfo_file_path}" CONTENT "${DAEMON_BUILDINFO_${kind}_TEXT}") + file(GENERATE OUTPUT "${buildinfo_file_path}" CONTENT "${${YOKAI_CMAKE_SLUG}_BUILDINFO_${kind}_TEXT}") list(APPEND BUILDINFOLIST "${buildinfo_file_path}") endforeach() endmacro() -macro(daemon_embed_files basename dir list format targetname) - set(embed_subdir "${DAEMON_EMBEDDED_SUBDIR}/${basename}") - set(embed_dir "${DAEMON_GENERATED_DIR}/${embed_subdir}") +macro(yokai_embed_files basename dir list format targetname) + set(embed_subdir "${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}/${basename}") + set(embed_dir "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${embed_subdir}") file(MAKE_DIRECTORY "${embed_dir}") foreach(kind CPP H) - set(embed_${kind}_basename "${basename}${DAEMON_GENERATED_${kind}_EXT}") - set(embed_${kind}_src_file "${DAEMON_EMBEDDED_DIR}/${embed_${kind}_basename}") - set(embed_${kind}_file "${DAEMON_EMBEDDED_SUBDIR}/${embed_${kind}_basename}") - set(embed_${kind}_text "${DAEMON_GENERATED_HEADER}") - set_property(SOURCE "${embed_${kind}_src_file}" APPEND PROPERTY OBJECT_DEPENDS "${DAEMON_SOURCE_GENERATOR}") + set(embed_${kind}_basename "${basename}${${YOKAI_CMAKE_SLUG}_GENERATED_${kind}_EXT}") + set(embed_${kind}_src_file "${${YOKAI_CMAKE_SLUG}_EMBEDDED_DIR}/${embed_${kind}_basename}") + set(embed_${kind}_file "${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}/${embed_${kind}_basename}") + set(embed_${kind}_text "${${YOKAI_CMAKE_SLUG}_GENERATED_HEADER}") + set_property(SOURCE "${embed_${kind}_src_file}" APPEND PROPERTY OBJECT_DEPENDS "${${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR}") set_property(TARGET "${targetname}" APPEND PROPERTY SOURCES "${embed_${kind}_src_file}") endforeach() - if (NOT DAEMON_EMBEDDED_FILES_HEADER) - set(DAEMON_EMBEDDED_FILES_HEADER "${DAEMON_EMBEDDED_SUBDIR}/DaemonEmbeddedFiles.h") + if (NOT ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER) + set(${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER "${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}/${YOKAI_FILE_SLUG}EmbeddedFiles.h") string(APPEND embed_header_text "// Automatically generated, do not modify!\n" - "#ifndef DAEMON_EMBEDDED_FILES_H_\n" - "#define DAEMON_EMBEDDED_FILES_H_\n" + "#ifndef ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_H_\n" + "#define ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_H_\n" "#include \n" "#include \n" "#include \n" @@ -104,10 +106,10 @@ macro(daemon_embed_files basename dir list format targetname) "};\n" "\n" "using embeddedFileMap_t = std::unordered_map;\n" - "#endif // DAEMON_EMBEDDED_FILES_H_\n" + "#endif // ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_H_\n" ) - set(embed_header_file "${DAEMON_GENERATED_DIR}/${DAEMON_EMBEDDED_FILES_HEADER}") + set(embed_header_file "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER}") file(GENERATE OUTPUT "${embed_header_file}" CONTENT "${embed_header_text}") endif() @@ -118,7 +120,7 @@ macro(daemon_embed_files basename dir list format targetname) ) string(APPEND embed_H_text - "#include \"${DAEMON_EMBEDDED_FILES_HEADER}\"\n" + "#include \"${${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER}\"\n" "\n" "namespace ${basename} {\n" ) @@ -129,7 +131,7 @@ macro(daemon_embed_files basename dir list format targetname) string(REGEX REPLACE "[^A-Za-z0-9]" "_" filename_symbol "${filename}") set(inpath "${dir}/${filename}") - set(outpath "${embed_dir}/${filename_symbol}${DAEMON_GENERATED_H_EXT}") + set(outpath "${embed_dir}/${filename_symbol}${${YOKAI_CMAKE_SLUG}_GENERATED_H_EXT}") add_custom_command( OUTPUT "${outpath}" @@ -138,11 +140,11 @@ macro(daemon_embed_files basename dir list format targetname) "-DOUTPUT_FILE=${outpath}" "-DFILE_FORMAT=${format}" "-DVARIABLE_NAME=${filename_symbol}" - -P "${DAEMON_FILE_EMBEDDER}" + -P "${${YOKAI_CMAKE_SLUG}_FILE_EMBEDDER}" MAIN_DEPENDENCY ${inpath} DEPENDS - "${DAEMON_FILE_EMBEDDER}" - "${DAEMON_SOURCE_GENERATOR}" + "${${YOKAI_CMAKE_SLUG}_FILE_EMBEDDER}" + "${${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR}" ) set_property(TARGET "${targetname}" APPEND PROPERTY SOURCES "${outpath}") @@ -174,7 +176,7 @@ macro(daemon_embed_files basename dir list format targetname) ) foreach(kind CPP H) - set(embed_file "${DAEMON_GENERATED_DIR}/${embed_${kind}_file}") + set(embed_file "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${embed_${kind}_file}") file(GENERATE OUTPUT "${embed_file}" CONTENT "${embed_${kind}_text}") endforeach() endmacro() diff --git a/cmake/DaemonPlatform/System.cmake b/cmake/Yokai/System.cmake similarity index 63% rename from cmake/DaemonPlatform/System.cmake rename to cmake/Yokai/System.cmake index b0d96a3345..a00de63423 100644 --- a/cmake/DaemonPlatform/System.cmake +++ b/cmake/Yokai/System.cmake @@ -28,10 +28,10 @@ # System detection. ################################################################################ -# When adding a new system, look at all the places DAEMON_HOST_SYSTEM -# and DAEMON_SYSTEM are used. +# When adding a new system, look at all the places ${YOKAI_CMAKE_SLUG}_HOST_SYSTEM +# and ${YOKAI_CMAKE_SLUG}_SYSTEM are used. -function(daemon_detect_host_system) +function(yokai_detect_host_system) set(system_name "Unknown") foreach(name Linux;FreeBSD;Android;Windows) @@ -63,67 +63,67 @@ function(daemon_detect_host_system) detect_cmake_host_system("system_name") endif() - set(DAEMON_HOST_SYSTEM_NAME "${system_name}" PARENT_SCOPE) + set(${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME "${system_name}" PARENT_SCOPE) endfunction() -function(daemon_detect_system) - daemon_run_detection("" "SYSTEM" "System.c" "Linux;Unix") +function(yokai_detect_system) + yokai_run_detection("" "SYSTEM" "System.c" "Linux;Unix") if (system_name STREQUAL "Unknown") detect_cmake_host_system("system_name") endif() - set(DAEMON_SYSTEM_NAME "${system_name}" PARENT_SCOPE) + set(${YOKAI_CMAKE_SLUG}_SYSTEM_NAME "${system_name}" PARENT_SCOPE) endfunction() -daemon_detect_host_system() -daemon_detect_system() +yokai_detect_host_system() +yokai_detect_system() -if ("${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "Unknown") +if ("${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "Unknown") message(WARNING "Unknown host system") endif() -if ("${DAEMON_SYSTEM_NAME}" STREQUAL "Unknown") +if ("${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" STREQUAL "Unknown") message(WARNING "Unknown target system") endif() -if ("${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${DAEMON_SYSTEM_NAME}" STREQUAL "Unknown") - message(WARNING "Assuming the host system is the same as the target: ${DAEMON_SYSTEM_NAME}") - set(DAEMON_HOST_SYSTEM_NAME "${DAEMON_SYSTEM_NAME}") +if ("${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Assuming the host system is the same as the target: ${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") + set(${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME "${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") endif() -if ("${DAEMON_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "Unknown") - message(WARNING "Assuming the target system is the same as the host: ${DAEMON_SYSTEM_NAME}") - set(DAEMON_SYSTEM_NAME "${DAEMON_HOST_SYSTEM_NAME}") +if ("${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Assuming the target system is the same as the host: ${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") + set(${YOKAI_CMAKE_SLUG}_SYSTEM_NAME "${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}") endif() -message(STATUS "Detected host system: ${DAEMON_HOST_SYSTEM_NAME}") -message(STATUS "Detected target system: ${DAEMON_SYSTEM_NAME}") +message(STATUS "Detected host system: ${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}") +message(STATUS "Detected target system: ${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") -if (NOT "${DAEMON_HOST_SYSTEM_NAME}" STREQUAL "${DAEMON_SYSTEM_NAME}") +if (NOT "${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") message(STATUS "Detected cross-compilation") endif() # Makes possible to do that in CMake code: -# > if (DAEMON_HOST_SYSTEM_Linux) -# > if (DAEMON_SYSTEM_Windows) -set("DAEMON_HOST_SYSTEM_${DAEMON_HOST_SYSTEM_NAME}" ON) -set("DAEMON_SYSTEM_${DAEMON_SYSTEM_NAME}" ON) +# > if (${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_Linux) +# > if (${YOKAI_CMAKE_SLUG}_SYSTEM_Windows) +set("${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" ON) +set("${YOKAI_CMAKE_SLUG}_SYSTEM_${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" ON) # This is for systems with behaviors similar to Linux, # implementing standards like FHS, XDG, GLVND… # Makes possible to do that in CMake code: -# > if (DAEMON_HOST_SYSTEM_Linux_COMPATIBILITY) -# > if (DAEMON_SYSTEM_Linux_COMPATIBILITY) +# > if (YOKAI_HOST_SYSTEM_Linux_COMPATIBILITY) +# > if (YOKAI_SYSTEM_Linux_COMPATIBILITY) foreach(name Linux;FreeBSD) foreach(slug HOST;HOST_SYSTEM) - if (DAEMON_${slug}_${name}) - set(DAEMON_${slug}_Linux_COMPATIBILITY ON) + if (YOKAI_${slug}_${name}) + set(YOKAI_${slug}_Linux_COMPATIBILITY ON) endif() endforeach() endforeach() -if (DAEMON_SOURCE_GENERATOR) +if (${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR) # Add printable string to the executable. - daemon_add_buildinfo("char*" "DAEMON_SYSTEM_STRING" "\"${DAEMON_SYSTEM_NAME}\"") + yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_SYSTEM_STRING" "\"${${YOKAI_C_SLUG}_SYSTEM_NAME}\"") endif() diff --git a/cmake/Yokai/Variable.cmake b/cmake/Yokai/Variable.cmake new file mode 100644 index 0000000000..f952f677e3 --- /dev/null +++ b/cmake/Yokai/Variable.cmake @@ -0,0 +1,48 @@ +# Daemon BSD Source Code +# Copyright (c) 2025, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +################################################################################ +# Reusable variable expansion. +################################################################################ + +if (NOT DEFINED YOKAI_FILE_SLUG) + set(YOKAI_FILE_SLUG "Yokai") +endif() + +if (NOT DEFINED YOKAI_CMAKE_SLUG) + string(TOUPPER "${YOKAI_FILE_SLUG}" YOKAI_CMAKE_SLUG) +endif() + +if (NOT DEFINED YOKAI_C_SLUG) + string(TOUPPER "${YOKAI_FILE_SLUG}" YOKAI_C_SLUG) +endif() + +if (NOT DEFINED YOKAI_INITIALIZED) + message(NOTICE "Using YOKAI_FILE_SLUG: ${YOKAI_FILE_SLUG}") + message(NOTICE "Using YOKAI_CMAKE_SLUG: ${YOKAI_CMAKE_SLUG}") + message(NOTICE "Using YOKAI_C_SLUG: ${YOKAI_C_SLUG}") + set(YOKAI_INITIALIZED ON) +endif() From 58f096ae844c0f5dc44de31ed89a83252d14c744 Mon Sep 17 00:00:00 2001 From: "dev@illwieckz.net" Date: Thu, 4 Jun 2026 18:04:24 +0200 Subject: [PATCH 13/14] yokai: drop custom variable slug, unify symbol naming --- CMakeLists.txt | 86 ++++++++++++------------- cmake/DaemonFlags.cmake | 78 +++++++++++----------- cmake/DaemonGame.cmake | 8 +-- cmake/DaemonNacl.cmake | 20 +++--- cmake/DaemonYokai.cmake | 32 --------- cmake/Yokai/Architecture.cmake | 54 ++++++++-------- cmake/Yokai/Compiler.cmake | 56 ++++++++-------- cmake/Yokai/Detection.cmake | 6 +- cmake/Yokai/SourceGenerator.cmake | 84 ++++++++++++------------ cmake/Yokai/System.cmake | 42 ++++++------ cmake/Yokai/Variable.cmake | 48 -------------- freetype.cmake | 2 +- src.cmake | 4 +- src/common/Common.h | 8 +++ src/common/Compiler.h | 4 +- src/common/Platform.h | 14 ++-- src/engine/framework/System.cpp | 28 ++++---- src/engine/framework/VirtualMachine.cpp | 18 +++--- src/engine/qcommon/common.cpp | 2 +- src/engine/qcommon/q_shared.h | 4 +- src/engine/renderer/gl_shader.cpp | 6 +- src/engine/renderer/tr_font.cpp | 8 +-- src/engine/renderer/tr_model_iqm.cpp | 2 +- srclibs.cmake | 14 ++-- 24 files changed, 276 insertions(+), 352 deletions(-) delete mode 100644 cmake/DaemonYokai.cmake delete mode 100644 cmake/Yokai/Variable.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 51a22aa980..f9ab73cae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ if (Daemon_OUT) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Daemon_OUT}) endif() -include(DaemonYokai) +include(Yokai/All) ################################################################################ # Configuration options @@ -90,11 +90,11 @@ if(NOT DAEMON_EXTERNAL_APP) set(NACL_RUNTIME_PATH "" CACHE STRING "Directory containing the NaCl binaries") - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) # The alternative code is based on non-curses unix terminal functions. set(USE_CURSES ON) else() - if (NOT DAEMON_SYSTEM_macOS) + if (NOT YOKAI_SYSTEM_macOS) # Not supported on macOS because the included version is too old. option(USE_CURSES_NCURSES "Use ncurses instead of PDCursesMod" ON) endif() @@ -199,29 +199,29 @@ endmacro() set(DEFAULT_USE_EXTERNAL_DEPS_LIBS ON) -if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) +if (USE_EXTERNAL_DEPS AND NOT YOKAI_SYSTEM_NaCl) set(EXTERNAL_DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external_deps" CACHE STRING "Directory in which to store the downloaded dependencies.") set(DEPS_EXT ".tar.xz") - set(DEPS_ARCH "${DAEMON_ARCH_NAME}") + set(DEPS_ARCH "${YOKAI_ARCH_NAME}") - if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) + if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) set(DEPS_COMPILER msvc) - elseif (DAEMON_CXX_COMPILER_MinGW) + elseif (YOKAI_CXX_COMPILER_MinGW) set(DEPS_COMPILER mingw) else() set(DEPS_COMPILER default) endif() - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) set(DEPS_SYSTEM windows) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686) - elseif (DAEMON_SYSTEM_macOS) + elseif (YOKAI_SYSTEM_macOS) set(DEPS_SYSTEM macos) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64) - if (DAEMON_ARCH_arm64) + if (YOKAI_ARCH_arm64) set(DEPS_ARCH amd64) set_deps_dir() @@ -230,10 +230,10 @@ if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) set(DEFAULT_USE_EXTERNAL_DEPS_LIBS OFF) endif() endif() - elseif (DAEMON_SYSTEM_Linux) + elseif (YOKAI_SYSTEM_Linux) set(DEPS_SYSTEM linux) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686 arm64 armhf) - elseif (DAEMON_SYSTEM_FreeBSD) + elseif (YOKAI_SYSTEM_FreeBSD) set(DEPS_SYSTEM freebsd) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686) @@ -264,7 +264,7 @@ endif() option(USE_EXTERNAL_DEPS_LIBS "Build and link against libraries from the EXTERNAL_DEPS_DIR" ${DEFAULT_USE_EXTERNAL_DEPS_LIBS}) -if (USE_EXTERNAL_DEPS AND NOT DAEMON_SYSTEM_NaCl) +if (USE_EXTERNAL_DEPS AND NOT YOKAI_SYSTEM_NaCl) if (DEPS_DIR) message(STATUS "Using external deps dir: ${DEPS_DIR}") @@ -462,13 +462,13 @@ endif() # Native client include(DaemonNacl) -if (DAEMON_SYSTEM_NaCl) +if (YOKAI_SYSTEM_NaCl) add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE}) set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module) else() add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE}) set_target_properties(srclibs-nacl-native PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs") - if (DAEMON_SYSTEM_macOS) + if (YOKAI_SYSTEM_macOS) # Do not error for OSAtomic* deprecation notices target_compile_options(srclibs-nacl-native PRIVATE "-Wno-error=deprecated-declarations") endif() @@ -476,9 +476,9 @@ else() endif() # Base OS libs -if (DAEMON_SYSTEM_Windows) +if (YOKAI_SYSTEM_Windows) set(LIBS_BASE ${LIBS_BASE} winmm ws2_32) -elseif (DAEMON_SYSTEM_NaCl) +elseif (YOKAI_SYSTEM_NaCl) find_library(NACL_EXCEPTION nacl_exception) find_library(NACL_MINIDUMP minidump_generator) @@ -510,7 +510,7 @@ else() set(LIBS_BASE ${LIBS_BASE} ${CMAKE_DL_LIBS}) find_package(Threads REQUIRED) set(LIBS_BASE ${LIBS_BASE} ${CMAKE_THREAD_LIBS_INIT}) - if (DAEMON_SYSTEM_macOS) + if (YOKAI_SYSTEM_macOS) set(LIBS_CLIENT ${LIBS_CLIENT} "-framework Carbon" "-framework IOKit" "-framework Cocoa") endif() endif() @@ -533,7 +533,7 @@ else() # Look for OpenGL here before we potentially switch to looking for static libs. if (BUILD_CLIENT) - if (DAEMON_SYSTEM_Linux_COMPATIBILITY) + if (YOKAI_SYSTEM_Linux_COMPATIBILITY) # Set LEGACY OpenGL ABI if the variable is not explictly set. # The backward-incompatible GLVND OpenGL ABI should only be used # by developers who have a good reason to require it. @@ -549,7 +549,7 @@ else() # This code is unreachable since it already errored out at find_package time. # This code only executes if OpenGL is supported, either because the GLVND ABI # is available, either because the LEGACY ABI is available. - if (DAEMON_SYSTEM_Linux_COMPATIBILITY) + if (YOKAI_SYSTEM_Linux_COMPATIBILITY) if (NOT OPENGL_gl_LIBRARY) # When OpenGL_GL_PREFERENCE is supported and GLVND is available # OPENGL_gl_LIBRARY is expected to be empty. So we can use the @@ -596,7 +596,7 @@ endif() # Prefer static libs if ( USE_STATIC_LIBS ) - if (DAEMON_SYSTEM_Linux_COMPATIBILITY) + if (YOKAI_SYSTEM_Linux_COMPATIBILITY) set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif() endif() @@ -624,7 +624,7 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} ${CURSESW_LIBRARIES}) include_directories(${CURSESW_INCLUDE_DIR}) else () - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} gdi32 comdlg32) endif() @@ -674,23 +674,23 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT) endif() # SDL, required for all targets on win32 because of iconv and SDL_SetHint(SDL_TIMER_RESOLUTION, 0) -if (BUILD_CLIENT OR DAEMON_SYSTEM_Windows) +if (BUILD_CLIENT OR YOKAI_SYSTEM_Windows) # Use our detected architecture instead of letting SDL do it again # Note that sdlcpu.cmake is only included on a random subset of platforms set(sdlvar_i686 SDL_CPU_X86) set(sdlvar_amd64 SDL_CPU_X64) set(sdlvar_armhf SDL_CPU_ARM32) set(sdlvar_arm64 SDL_CPU_ARM64) - if (sdlvar_${DAEMON_ARCH_NAME}) - set(${sdlvar_${DAEMON_ARCH_NAME}} 1) + if (sdlvar_${YOKAI_ARCH_NAME}) + set(${sdlvar_${YOKAI_ARCH_NAME}} 1) else() - message("Developer TODO: translate architecture ${DAEMON_ARCH_NAME} for SDL") + message("Developer TODO: translate architecture ${YOKAI_ARCH_NAME} for SDL") endif() find_package(SDL3 REQUIRED CONFIG) message("Found SDL3 ${SDL3_VERSION}: ${SDL3_DIR}") - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} SDL3::SDL3) else() set(LIBS_CLIENT ${LIBS_CLIENT} SDL3::SDL3) @@ -702,7 +702,7 @@ if (USE_BREAKPAD) add_definitions(-DUSE_BREAKPAD) include_directories(${LIB_DIR}/breakpad/src) - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) add_library(srclibs-breakpad-common EXCLUDE_FROM_ALL ${BREAKPAD_COMMON_LIST}) add_library(srclibs-breakpad-crash_generation_server EXCLUDE_FROM_ALL ${BREAKPAD_CRASHGENERATIONSERVER_LIST}) add_library(srclibs-breakpad-exception_handler EXCLUDE_FROM_ALL ${BREAKPAD_EXCEPTIONHANDLER_LIST}) @@ -732,7 +732,7 @@ if (USE_BREAKPAD) set(LIBS_ENGINE_BASE ${LIBS_ENGINE_BASE} srclibs-breakpad-exception_handler srclibs-breakpad-crash_generation_client srclibs-breakpad-common) - elseif (DAEMON_SYSTEM_Linux_COMPATIBILITY) + elseif (YOKAI_SYSTEM_Linux_COMPATIBILITY) add_library(srclibs-breakpad EXCLUDE_FROM_ALL ${BREAKPAD_LIST}) set_target_properties(srclibs-breakpad PROPERTIES POSITION_INDEPENDENT_CODE 1 FOLDER "libs") target_compile_definitions(srclibs-breakpad PUBLIC HAVE_GETCONTEXT=1) @@ -747,7 +747,7 @@ option(PREFER_EXTERNAL_LIBS "Tries to use system libs where possible." ON) macro(prefer_package LIB_NAME LIB_CMAKE) if (NOT ${LIB_NAME}_FOUND) - if (PREFER_EXTERNAL_LIBS AND NOT DAEMON_SYSTEM_NaCl) + if (PREFER_EXTERNAL_LIBS AND NOT YOKAI_SYSTEM_NaCl) find_package(${LIB_NAME}) if (NOT ${LIB_NAME}_FOUND) @@ -836,9 +836,9 @@ macro(AddApplicationInternal Target Executable) # Append Windows specific manifests. # Adding the .manifest as a source works better for MSVC, but it has no # effect for MinGW (https://gitlab.kitware.com/cmake/cmake/-/issues/23244). - if (DAEMON_CXX_COMPILER_MinGW) + if (YOKAI_CXX_COMPILER_MinGW) target_sources(${Target} PRIVATE ${ENGINE_DIR}/sys/windows-resource/manifest.rc) - elseif (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) + elseif (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) target_sources(${Target} PRIVATE ${ENGINE_DIR}/sys/windows-resource/supported-os.manifest) endif() @@ -877,9 +877,9 @@ function(AddApplication) ADD_PRECOMPILED_HEADER(${A_Target}-objects) endfunction() -yokai_write_buildinfo("Engine") +yokai_write_buildinfo("DaemonEngine") -if (NOT DAEMON_SYSTEM_NaCl) +if (NOT YOKAI_SYSTEM_NaCl) add_library(engine-lib EXCLUDE_FROM_ALL ${PCH_FILE} ${BUILDINFOLIST} ${COMMONLIST} ${ENGINELIST}) target_link_libraries(engine-lib ${LIBS_BASE} ${LIBS_ENGINE_BASE} ${CPP23SupportLibrary}) set_property(TARGET engine-lib APPEND PROPERTY COMPILE_DEFINITIONS BUILD_ENGINE) @@ -930,9 +930,9 @@ if (BUILD_CLIENT) ) # Generate GLSL include files. - yokai_embed_files("EngineShaders" "${GLSL_EMBED_DIR}" "${GLSL_EMBED_LIST}" "TEXT" "client-objects") + yokai_embed_files("DaemonEngineShaders" "${GLSL_EMBED_DIR}" "${GLSL_EMBED_LIST}" "TEXT" "client-objects") - yokai_embed_files(ConsoleFont "${CMAKE_CURRENT_SOURCE_DIR}/libs/unifont" unifont.otf BINARY client-objects) + yokai_embed_files("DaemonEngineFont" "${CMAKE_CURRENT_SOURCE_DIR}/libs/unifont" "unifont.otf" "BINARY" "client-objects") endif() if (BUILD_SERVER) @@ -978,13 +978,13 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe - ${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe + ${DEPS_DIR}/irt_core-${YOKAI_NACL_ARCH_NAME}.nexe + ${FULL_OUTPUT_DIR}/irt_core-${YOKAI_NACL_ARCH_NAME}.nexe ) # Linux uses a bootstrap program to reserve address space - if (DAEMON_SYSTEM_Linux_COMPATIBILITY) - if (DAEMON_ARCH_arm64) + if (YOKAI_SYSTEM_Linux_COMPATIBILITY) + if (YOKAI_ARCH_arm64) add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp) add_dependencies(runtime_deps nacl_helper_bootstrap-armhf) @@ -1008,7 +1008,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Win32 requires nacl_loader_amd64.exe in order to run on Win64 - if (DAEMON_SYSTEM_Windows AND DAEMON_ARCH_i686) + if (YOKAI_SYSTEM_Windows AND YOKAI_ARCH_i686) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPS_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX} @@ -1022,7 +1022,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Mac requires some libraries from external_deps - if (DAEMON_SYSTEM_macOS) + if (YOKAI_SYSTEM_macOS) file(GLOB RUNTIME_FRAMEWORKS ${DEPS_DIR}/lib/*.framework) foreach(RUNTIME_FRAMEWORK ${RUNTIME_FRAMEWORKS}) get_filename_component(RUNTIME_FRAMEWORK_NAME ${RUNTIME_FRAMEWORK} NAME) @@ -1044,7 +1044,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endif() # Windows requires some libraries from external_deps - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) file(GLOB RUNTIME_LIBS ${DEPS_DIR}/bin/*.dll ${DEPS_DIR}/SDL3/lib/*/SDL3.dll) foreach(RUNTIME_LIB ${RUNTIME_LIBS}) add_custom_command(TARGET runtime_deps PRE_BUILD diff --git a/cmake/DaemonFlags.cmake b/cmake/DaemonFlags.cmake index 9961a7974f..051bec4a81 100644 --- a/cmake/DaemonFlags.cmake +++ b/cmake/DaemonFlags.cmake @@ -55,7 +55,7 @@ mark_as_advanced(USE_RECOMMENDED_CXX_STANDARD) option(USE_CPP23 "Use C++23 standard where possible" OFF) -if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) +if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) set(DEFAULT_STRIP_SOURCE_PATHS ON) else() set(DEFAULT_STRIP_SOURCE_PATHS OFF) @@ -65,12 +65,12 @@ option(STRIP_SOURCE_PATHS "Strip source paths in debug symbols" ${DEFAULT_STRIP_ # Required for on Clang/GCC if(USE_CPP23) - if (DAEMON_CXX_COMPILER_Clang_COMPATIBILITY OR DAEMON_CXX_COMPILER_GCC_COMPATIBILITY) - if ((DAEMON_CXX_COMPILER_Clang_VERSION VERSION_GREATER_EQUAL 19.1.0) OR (DAEMON_CXX_COMPILER_GCC_VERSION VERSION_GREATER_EQUAL 13.3)) + if (YOKAI_CXX_COMPILER_Clang_COMPATIBILITY OR YOKAI_CXX_COMPILER_GCC_COMPATIBILITY) + if ((YOKAI_CXX_COMPILER_Clang_VERSION VERSION_GREATER_EQUAL 19.1.0) OR (YOKAI_CXX_COMPILER_GCC_VERSION VERSION_GREATER_EQUAL 13.3)) set(CPP23SupportLibraryTryExp TRUE) endif() - if ((DAEMON_CXX_COMPILER_Clang_VERSION VERSION_GREATER_EQUAL 17.0.1) OR (DAEMON_CXX_COMPILER_GCC_VERSION VERSION_GREATER_EQUAL 12.1)) + if ((YOKAI_CXX_COMPILER_Clang_VERSION VERSION_GREATER_EQUAL 17.0.1) OR (YOKAI_CXX_COMPILER_GCC_VERSION VERSION_GREATER_EQUAL 12.1)) set(CPP23SupportLibraryTryBacktrace TRUE) endif() @@ -153,7 +153,7 @@ function(try_flag LIST FLAG) # Other compilers might interpret it as a filename so reject without testing. string(SUBSTRING "${FLAG}" 0 1 FLAG_FIRST_CHAR) if ("${FLAG_FIRST_CHAR}" STREQUAL "/") - if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) + if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) set(${TEST} 1) else() set(${TEST} 0) @@ -233,7 +233,7 @@ if (STRIP_SOURCE_PATHS) set(FILENAME_STRIP_DIRS ${FILENAME_STRIP_DIRS} "${DAEMON_DIR}/src" "${DAEMON_DIR}") endif() foreach(strip_dir ${FILENAME_STRIP_DIRS}) - if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) + if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) string(REPLACE "/" "\\" backslashed_dir ${strip_dir}) # set_c_cxx_flag can't be used because macros barf if the input contains backslashes # https://gitlab.kitware.com/cmake/cmake/-/issues/19281 @@ -263,7 +263,7 @@ if (NOT NACL AND BUILD_CLIENT) option(USE_OPENMP "Use OpenMP to parallelize some tasks" OFF) endif() -if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) +if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) set_c_cxx_flag("/MP") # There is no flag for standards before C++17 @@ -382,7 +382,7 @@ else() endif() endif() - if (DAEMON_SYSTEM_NaCl AND USE_NACL_SAIGO AND SAIGO_DAEMON_ARCH_arm) + if (YOKAI_SYSTEM_NaCl AND USE_NACL_SAIGO AND SAIGO_YOKAI_ARCH_arm) # Saigo produces broken arm builds when optimizing them. # See: https://github.com/Unvanquished/Unvanquished/issues/3297 # When setting this clang-specific option, we don't have to care @@ -431,7 +431,7 @@ else() try_flag(WARNINGS "-Werror") endif() - if (DAEMON_SYSTEM_NaCl AND NOT USE_NACL_SAIGO) + if (YOKAI_SYSTEM_NaCl AND NOT USE_NACL_SAIGO) # PNaCl only supports libc++ as standard library. set_c_cxx_flag("-stdlib=libc++") set_c_cxx_flag("--pnacl-allow-exceptions") @@ -443,12 +443,12 @@ else() try_cxx_flag(FNO_GNU_UNIQUE "-fno-gnu-unique") # Use MSVC-compatible bitfield layout - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) set_c_cxx_flag("-mms-bitfields") endif() # Linker flags - if (NOT DAEMON_SYSTEM_macOS) + if (NOT YOKAI_SYSTEM_macOS) try_linker_flag(LINKER_O1 "-Wl,-O1") try_linker_flag(LINKER_SORT_COMMON "-Wl,--sort-common") try_linker_flag(LINKER_AS_NEEDED "-Wl,--as-needed") @@ -461,7 +461,7 @@ else() try_linker_flag(LINKER_Z_NOW "-Wl,-z,now") endif() - if (DAEMON_SYSTEM_Windows) + if (YOKAI_SYSTEM_Windows) try_linker_flag(LINKER_DYNAMICBASE "-Wl,--dynamicbase") try_linker_flag(LINKER_NXCOMPAT "-Wl,--nxcompat") try_linker_flag(LINKER_LARGE_ADDRESS_AWARE "-Wl,--large-address-aware") @@ -474,7 +474,7 @@ else() # The -pthread flag sets some preprocessor defines, # it is also used to link with libpthread on Linux. - if (NOT DAEMON_SYSTEM_macOS) + if (NOT YOKAI_SYSTEM_macOS) try_c_cxx_flag(PTHREAD "-pthread") endif() @@ -507,7 +507,7 @@ else() if (USE_HARDENING) # PNaCl accepts the flags but does not define __stack_chk_guard and __stack_chk_fail. - if (NOT DAEMON_SYSTEM_NaCl) + if (NOT YOKAI_SYSTEM_NaCl) try_c_cxx_flag(FSTACK_PROTECTOR_STRONG "-fstack-protector-strong") if (NOT FLAG_FSTACK_PROTECTOR_STRONG) @@ -518,24 +518,24 @@ else() try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow") try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector") - if (NOT DAEMON_SYSTEM_NaCl) + if (NOT YOKAI_SYSTEM_NaCl) # The -pie flag requires -fPIC: # > ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC # This flag isn't used on macOS: # > clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument] - if (FLAG_FPIC AND NOT DAEMON_SYSTEM_macOS) + if (FLAG_FPIC AND NOT YOKAI_SYSTEM_macOS) try_exe_linker_flag(LINKER_PIE "-pie") endif() endif() if ("${FLAG_LINKER_PIE}" AND MINGW) # https://github.com/msys2/MINGW-packages/issues/4100 - if (DAEMON_ARCH_i686) + if (YOKAI_ARCH_i686) set_linker_flag("-Wl,-e,_mainCRTStartup") - elseif(DAEMON_ARCH_amd64) + elseif(YOKAI_ARCH_amd64) set_linker_flag("-Wl,-e,mainCRTStartup") else() - message(FATAL_ERROR "Unsupported architecture ${DAEMON_ARCH_NAME}") + message(FATAL_ERROR "Unsupported architecture ${YOKAI_ARCH_NAME}") endif() endif() endif() @@ -546,7 +546,7 @@ else() # PNaCl accepts the flag but does nothing with it, underlying clang doesn't support it. # Saigo NaCl compiler doesn't support LTO, the flag is accepted but linking fails # with “unable to pass LLVM bit-code files to linker” error. - if (USE_LTO AND NOT DAEMON_SYSTEM_NaCl) + if (USE_LTO AND NOT YOKAI_SYSTEM_NaCl) try_c_cxx_flag(LTO_AUTO "-flto=auto") if (NOT FLAG_LTO_AUTO) @@ -604,15 +604,15 @@ endif() option(USE_CPU_RECOMMENDED_FEATURES "Use some common hardware features like SSE2, NEON, VFP, MCX16, etc." ON) # Target options. -if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) - if (DAEMON_ARCH_i686) +if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) + if (YOKAI_ARCH_i686) if (USE_CPU_RECOMMENDED_FEATURES) set_c_cxx_flag("/arch:SSE2") # This is the default else() set_c_cxx_flag("/arch:IA32") # minimum endif() endif() -elseif (NOT DAEMON_SYSTEM_NaCl) +elseif (NOT YOKAI_SYSTEM_NaCl) # Among the required hardware features, the NX bit (No eXecute bit) # feature may be required for NativeClient to work. Some early # Intel EM64T processors are known to not implement the NX bit. @@ -625,25 +625,25 @@ elseif (NOT DAEMON_SYSTEM_NaCl) # Running a server with a native executable game is also a valid usage # not requiring the NX bit. - if (DAEMON_ARCH_amd64) + if (YOKAI_ARCH_amd64) # K8 or EM64T minimum: AMD Athlon 64 ClawHammer, Intel Xeon Nocona, Intel Pentium 4 model F (Prescott revision EO), VIA Nano. - if (DAEMON_CXX_COMPILER_ICC) + if (YOKAI_CXX_COMPILER_ICC) set(GCC_GENERIC_ARCH "pentium4") - elseif (DAEMON_CXX_COMPILER_Zig) + elseif (YOKAI_CXX_COMPILER_Zig) set(GCC_GENERIC_ARCH "x86_64") else() set(GCC_GENERIC_ARCH "x86-64") endif() set(GCC_GENERIC_TUNE "generic") - elseif (DAEMON_ARCH_i686) + elseif (YOKAI_ARCH_i686) # P6 or K6 minimum: Intel Pentium Pro, AMD K6, Via Cyrix III, Via C3. set(GCC_GENERIC_ARCH "i686") set(GCC_GENERIC_TUNE "generic") - elseif (DAEMON_ARCH_arm64) + elseif (YOKAI_ARCH_arm64) # Armv8-A minimum: Cortex-A50. set(GCC_GENERIC_ARCH "armv8-a") set(GCC_GENERIC_TUNE "generic") - elseif (DAEMON_ARCH_armhf) + elseif (YOKAI_ARCH_armhf) # Armv7-A minimum with VFPv3 and optional NEONv1: Cortex-A5. # Hard float ABI (mainstream 32-bit ARM Linux distributions). # An FPU should be explicitly set on recent compilers or this @@ -652,7 +652,7 @@ elseif (NOT DAEMON_SYSTEM_NaCl) # lacks an FPU set(GCC_GENERIC_ARCH "armv7-a+fp") set(GCC_GENERIC_TUNE "generic-armv7-a") - elseif (DAEMON_ARCH_armel) + elseif (YOKAI_ARCH_armel) # Armv6 minimum with optional VFP: ARM11. # Soft float ABI (previous mainstream 32-bit ARM Linux # distributions, mainstream 32-bit ARM Android distributions). @@ -672,10 +672,10 @@ elseif (NOT DAEMON_SYSTEM_NaCl) unset(GCC_GENERIC_TUNE) set(GCC_GENERIC_CPU "power5") else() - message(WARNING "Unknown architecture ${DAEMON_ARCH_NAME}") + message(WARNING "Unknown architecture ${YOKAI_ARCH_NAME}") endif() - if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig") + if ("${YOKAI_CXX_COMPILER_NAME}" STREQUAL "Zig") unset(GCC_GENERIC_TUNE) endif() @@ -696,18 +696,18 @@ elseif (NOT DAEMON_SYSTEM_NaCl) endif() if (USE_CPU_RECOMMENDED_FEATURES) - if (DAEMON_ARCH_amd64) + if (YOKAI_ARCH_amd64) # CMPXCHG16B minimum (x86-64-v2): AMD64 revision F. try_c_cxx_flag_werror(MCX16 "-mcx16") - elseif (DAEMON_ARCH_i686) + elseif (YOKAI_ARCH_i686) # SSE2 minimum: Intel Pentium 4 (Prescott), # Intel Pentium M (Banias), AMD K8, Via C7. try_c_cxx_flag_werror(MSSE2 "-msse2") try_c_cxx_flag_werror(MFPMATH_SSE "-mfpmath=sse") - elseif (DAEMON_ARCH_armhf) + elseif (YOKAI_ARCH_armhf) # NEONv1 minimum. try_c_cxx_flag_werror(MFPU_NEON "-mfpu=neon") - elseif (DAEMON_ARCH_armel) + elseif (YOKAI_ARCH_armel) # VFP minimum, hard float with soft float ABI. try_c_cxx_flag_werror(MFPU_VFP "-mfpu=vfp") try_c_cxx_flag_werror(MFLOAT_ABI_SOFTFP "-mfloat-abi=softfp") @@ -716,7 +716,7 @@ elseif (NOT DAEMON_SYSTEM_NaCl) endif() # Windows-specific definitions -if (DAEMON_SYSTEM_Windows) +if (YOKAI_SYSTEM_Windows) add_definitions( -DWINVER=0x501 # Minimum Windows version: XP -DWIN32 # Define WIN32 for compatibility (compiler defines _WIN32) @@ -726,12 +726,12 @@ if (DAEMON_SYSTEM_Windows) set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib") endif() -if (DAEMON_CXX_COMPILER_MSVC_COMPATIBILITY) +if (YOKAI_CXX_COMPILER_MSVC_COMPATIBILITY) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() # Mac-specific definitions -if (DAEMON_SYSTEM_macOS) +if (YOKAI_SYSTEM_macOS) add_definitions(-DMACOS_X) set(CMAKE_INSTALL_RPATH "@executable_path") set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index c98eae1fab..d5ec105fbb 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -40,7 +40,7 @@ option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for b include(ExternalProject) -include(DaemonYokai) +include(Yokai/All) # Do not report unused native compiler if native vms are not built. # If only NACL vms are built, this will be reported in chainloaded build. @@ -71,7 +71,7 @@ include(CMakeParseArguments) # The NaCl SDK only runs on amd64 or i686. if (NOT FORK EQUAL 2) if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME - AND (DAEMON_ARCH_amd64 OR DAEMON_ARCH_i686)) + AND (YOKAI_ARCH_amd64 OR YOKAI_ARCH_i686)) # can be loaded by daemon with vm.[sc]game.type 0 or 1 option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF) @@ -82,7 +82,7 @@ if (NOT FORK EQUAL 2) if (BUILD_GAME_NACL_TARGETS STREQUAL "all") set(NACL_TARGETS "${NACL_ALL_TARGETS}") elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native") - set(NACL_TARGETS "${DAEMON_ARCH_NAME}") + set(NACL_TARGETS "${YOKAI_ARCH_NAME}") elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none") set(NACL_TARGETS "") else() @@ -107,7 +107,7 @@ if (NOT FORK EQUAL 2) endif() endif() -yokai_write_buildinfo("Game") +yokai_write_buildinfo("DaemonGame") function(buildGameModule module_slug) set(module_target "${GAMEMODULE_NAME}-${module_slug}") diff --git a/cmake/DaemonNacl.cmake b/cmake/DaemonNacl.cmake index ae31641487..885e303f30 100644 --- a/cmake/DaemonNacl.cmake +++ b/cmake/DaemonNacl.cmake @@ -28,10 +28,10 @@ option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF) -if (DAEMON_SYSTEM_NaCl) +if (YOKAI_SYSTEM_NaCl) # Build nexe binary. if(USE_NACL_SAIGO) - # DAEMON_NACL_ARCH_NAME is "pnacl" here, NACL_TARGET carries the architecture. + # YOKAI_NACL_ARCH_NAME is "pnacl" here, NACL_TARGET carries the architecture. if (NACL_TARGET STREQUAL "amd64") add_definitions(-DNACL_BUILD_ARCH=x86) add_definitions(-DNACL_BUILD_SUBARCH=64) @@ -47,29 +47,29 @@ if (DAEMON_SYSTEM_NaCl) # Those defines looks to be meaningless to produce arch-independent pexe # with PNaCl but they must be set to anything supported by native builds. # This requirement looks to be a PNaCl bug. - # DAEMON_NACL_ARCH_NAME is "pnacl" here, NACL_TARGET is not set. + # YOKAI_NACL_ARCH_NAME is "pnacl" here, NACL_TARGET is not set. add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=64 ) endif() else() # Build native dll or native exe. - if (DAEMON_SYSTEM_macOS) + if (YOKAI_SYSTEM_macOS) add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=1 ) - elseif (DAEMON_SYSTEM_Linux) + elseif (YOKAI_SYSTEM_Linux) add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) - elseif (DAEMON_SYSTEM_FreeBSD) + elseif (YOKAI_SYSTEM_FreeBSD) add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=1 -DNACL_OSX=0 ) - elseif (DAEMON_SYSTEM_Windows) + elseif (YOKAI_SYSTEM_Windows) add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) endif() - if (DAEMON_NACL_ARCH_amd64) + if (YOKAI_NACL_ARCH_amd64) add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=64 ) - elseif (DAEMON_NACL_ARCH_i686) + elseif (YOKAI_NACL_ARCH_i686) add_definitions( -DNACL_BUILD_ARCH=x86 ) add_definitions( -DNACL_BUILD_SUBARCH=32 ) - elseif (DAEMON_NACL_ARCH_armhf) + elseif (YOKAI_NACL_ARCH_armhf) add_definitions( -DNACL_BUILD_ARCH=arm ) else() # NaCl does not support this architecture natively, but these defines must diff --git a/cmake/DaemonYokai.cmake b/cmake/DaemonYokai.cmake deleted file mode 100644 index 5fbdf19972..0000000000 --- a/cmake/DaemonYokai.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# Daemon BSD Source Code -# Copyright (c) 2026, Daemon Developers -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -################################################################################ -# Initialize Yokai CMake helpers. -################################################################################ - -set(YOKAI_FILE_SLUG "Daemon") -include(Yokai/All) diff --git a/cmake/Yokai/Architecture.cmake b/cmake/Yokai/Architecture.cmake index 2332e783d4..f66d3fa635 100644 --- a/cmake/Yokai/Architecture.cmake +++ b/cmake/Yokai/Architecture.cmake @@ -28,7 +28,7 @@ # Architecture detection. ################################################################################ -# When adding a new architecture, look at all the places ${YOKAI_CMAKE_SLUG}_ARCH is used. +# When adding a new architecture, look at all the places YOKAI_ARCH is used. option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON) mark_as_advanced(USE_ARCH_INTRINSICS) @@ -36,15 +36,15 @@ mark_as_advanced(USE_ARCH_INTRINSICS) function(yokai_detect_arch) yokai_run_detection("" "ARCH" "Architecture.c" "") - set(${YOKAI_CMAKE_SLUG}_ARCH_NAME "${arch_name}" PARENT_SCOPE) + set(YOKAI_ARCH_NAME "${arch_name}" PARENT_SCOPE) message(STATUS "Detected target architecture: ${arch_name}") - add_definitions(-D${YOKAI_C_PREFIX}_ARCH_${arch_name}) + add_definitions(-DYOKAI_ARCH_${arch_name}) set(nacl_arch "${arch_name}") - if (${YOKAI_CMAKE_SLUG}_SYSTEM_Linux_COMPATIBILITY) + if (YOKAI_SYSTEM_Linux_COMPATIBILITY) set(armhf_usage "arm64;armel") if ("${arch_name}" IN_LIST armhf_usage) # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. @@ -53,17 +53,17 @@ function(yokai_detect_arch) set(box64_usage ppc64el riscv64) if ("${arch_name}" IN_LIST box64_usage) - option(${YOKAI_CMAKE_SLUG}_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) - if (${YOKAI_CMAKE_SLUG}_NACL_BOX64_EMULATION) + option(YOKAI_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) + if (YOKAI_NACL_BOX64_EMULATION) # Use Box64 to run x86_64 NaCl loader and amd64 nexe. # Box64 must be installed and available in PATH at runtime. set(nacl_arch "amd64") - add_definitions(-D${YOKAI_C_PREFIX}_NACL_BOX64_EMULATION) + add_definitions(-DYOKAI_NACL_BOX64_EMULATION) endif() endif() endif() - elseif (${YOKAI_CMAKE_SLUG}_SYSTEM_macOS) + elseif (YOKAI_SYSTEM_macOS) if ("${arch_name}" STREQUAL "arm64") # You can get emulated NaCl going like this: # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ @@ -71,19 +71,19 @@ function(yokai_detect_arch) endif() endif() - # The ${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME variable contributes to the nexe file name. - set(${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) + # The YOKAI_NACL_ARCH_NAME variable contributes to the nexe file name. + set(YOKAI_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) # NaCl runtime is only available on architectures that have a NaCl loader. set(nacl_runtime_arch amd64 i686 armhf) if ("${nacl_arch}" IN_LIST nacl_runtime_arch) - add_definitions(-D${YOKAI_CMAKE_SLUG}_NACL_RUNTIME_ENABLED) + add_definitions(-DYOKAI_NACL_RUNTIME_ENABLED) endif() endfunction() function(yokai_set_arch_intrinsics name) message(STATUS "Enabling ${name} architecture intrinsics") - add_definitions(-D${YOKAI_C_PREFIX}_USE_ARCH_INTRINSICS_${name}) + add_definitions(-DYOKAI_USE_ARCH_INTRINSICS_${name}) endfunction() option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON) @@ -92,23 +92,23 @@ mark_as_advanced(USE_ARCH_INTRINSICS) function(yokai_set_intrinsics) if (USE_ARCH_INTRINSICS) # Makes possible to do that in C++ code: - # > if defined(${YOKAI_CMAKE_SLUG}_USE_ARCH_INTRINSICS) - add_definitions(-D${YOKAI_C_PREFIX}_USE_ARCH_INTRINSICS) + # > if defined(YOKAI_USE_ARCH_INTRINSICS) + add_definitions(-DYOKAI_USE_ARCH_INTRINSICS) # Makes possible to do that in C++ code: - # > if defined(${YOKAI_CMAKE_SLUG}_USE_ARCH_INTRINSICS_amd64) - # > if defined(${YOKAI_CMAKE_SLUG}_USE_ARCH_INTRINSICS_i686) - yokai_set_arch_intrinsics("${${YOKAI_CMAKE_SLUG}_ARCH_NAME}") + # > if defined(YOKAI_USE_ARCH_INTRINSICS_amd64) + # > if defined(YOKAI_USE_ARCH_INTRINSICS_i686) + yokai_set_arch_intrinsics("${YOKAI_ARCH_NAME}") set(amd64_PARENT "i686") set(arm64_PARENT "armhf") set(ppc64el_PARENT "ppc64") - if ("${${YOKAI_CMAKE_SLUG}_ARCH_NAME}_PARENT") - yokai_set_arch_intrinsics("${${${YOKAI_CMAKE_SLUG}_ARCH_NAME}_PARENT}") + if ("${YOKAI_ARCH_NAME}_PARENT") + yokai_set_arch_intrinsics("${${YOKAI_ARCH_NAME}_PARENT}") endif() else() - message(STATUS "Disabling ${${YOKAI_CMAKE_SLUG}_ARCH_NAME} architecture intrinsics") + message(STATUS "Disabling ${YOKAI_ARCH_NAME} architecture intrinsics") endif() endfunction() @@ -116,13 +116,13 @@ yokai_detect_arch() yokai_set_intrinsics() # Makes possible to do that in CMake code: -# > if (${YOKAI_CMAKE_SLUG}_ARCH_arm64) -# > if (${YOKAI_CMAKE_SLUG}_NACL_ARCH_armhf) -set("${YOKAI_CMAKE_SLUG}_ARCH_${${YOKAI_CMAKE_SLUG}_ARCH_NAME}" ON) -set("${YOKAI_CMAKE_SLUG}_NACL_ARCH_${${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME}" ON) +# > if (YOKAI_ARCH_arm64) +# > if (YOKAI_NACL_ARCH_armhf) +set("YOKAI_ARCH_${YOKAI_ARCH_NAME}" ON) +set("YOKAI_NACL_ARCH_${YOKAI_NACL_ARCH_NAME}" ON) -if (${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR) +if (YOKAI_SOURCE_GENERATOR) # Add printable strings to the executable. - yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_ARCH_STRING" "\"${${YOKAI_CMAKE_SLUG}_ARCH_NAME}\"") - yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_NACL_ARCH_STRING" "\"${${YOKAI_CMAKE_SLUG}_NACL_ARCH_NAME}\"") + yokai_add_buildinfo("char*" "YOKAI_ARCH_STRING" "\"${YOKAI_ARCH_NAME}\"") + yokai_add_buildinfo("char*" "YOKAI_NACL_ARCH_STRING" "\"${YOKAI_NACL_ARCH_NAME}\"") endif() diff --git a/cmake/Yokai/Compiler.cmake b/cmake/Yokai/Compiler.cmake index d490e88126..813509e7a8 100644 --- a/cmake/Yokai/Compiler.cmake +++ b/cmake/Yokai/Compiler.cmake @@ -28,8 +28,8 @@ # Compiler detection. ################################################################################ -# When adding a new compiler, look at all the places ${YOKAI_CMAKE_SLUG}_C_COMPILER -# and ${YOKAI_CMAKE_SLUG}_CXX_COMPILER are used. +# When adding a new compiler, look at all the places YOKAI_C_COMPILER +# and YOKAI_CXX_COMPILER are used. function(yokai_detect_compiler lang) set(C_NAME "C") @@ -126,9 +126,9 @@ function(yokai_detect_compiler lang) message(WARNING "Unknown ${${lang}_NAME} compiler version") endif() - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_BASENAME "${compiler_basename}" PARENT_SCOPE) - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME "${compiler_name}" PARENT_SCOPE) - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION "${compiler_version}" PARENT_SCOPE) + set(YOKAI_${lang}_COMPILER_BASENAME "${compiler_basename}" PARENT_SCOPE) + set(YOKAI_${lang}_COMPILER_NAME "${compiler_name}" PARENT_SCOPE) + set(YOKAI_${lang}_COMPILER_VERSION "${compiler_version}" PARENT_SCOPE) endfunction() message(STATUS "CMake generator: ${CMAKE_GENERATOR}") @@ -140,20 +140,20 @@ foreach(lang C;CXX) if (MSVC) # Let CMake do the job, it does it very well, # and there is probably no variant to take care about. - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_MSVC_COMPATIBILITY ON) - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME "${CMAKE_${lang}_COMPILER_ID}") - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}") - get_filename_component(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_BASENAME "${CMAKE_${lang}_COMPILER}" NAME) + set(YOKAI_${lang}_COMPILER_MSVC_COMPATIBILITY ON) + set(YOKAI_${lang}_COMPILER_NAME "${CMAKE_${lang}_COMPILER_ID}") + set(YOKAI_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}") + get_filename_component(YOKAI_${lang}_COMPILER_BASENAME "${CMAKE_${lang}_COMPILER}" NAME) else() yokai_detect_compiler(${lang}) - if (${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_Clang_COMPATIBILITY) - if (NOT ${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME STREQUAL "Clang") - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION - "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION}/Clang_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_Clang_VERSION}") + if (YOKAI_${lang}_COMPILER_Clang_COMPATIBILITY) + if (NOT YOKAI_${lang}_COMPILER_NAME STREQUAL "Clang") + set(YOKAI_${lang}_COMPILER_EXTENDED_VERSION + "${YOKAI_${lang}_COMPILER_VERSION}/Clang_${YOKAI_${lang}_COMPILER_Clang_VERSION}") endif() - elseif (${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_GCC_COMPATIBILITY) - if (NOT ${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME STREQUAL "GCC") + elseif (YOKAI_${lang}_COMPILER_GCC_COMPATIBILITY) + if (NOT YOKAI_${lang}_COMPILER_NAME STREQUAL "GCC") # Almost all compilers on Earth pretend to be GCC compatible. # So we first have to check it's really a GCC variant. # Parse “ -v” @@ -168,38 +168,38 @@ foreach(lang C;CXX) # the version of the GCC variant, not the version of the upstream # GCC we are looking for. if ("${CUSTOM_${lang}_GCC_OUTPUT}" MATCHES "\ngcc version ") - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION - "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION}/GCC_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_GCC_VERSION}") + set(YOKAI_${lang}_COMPILER_EXTENDED_VERSION + "${YOKAI_${lang}_COMPILER_VERSION}/GCC_${YOKAI_${lang}_COMPILER_GCC_VERSION}") endif() endif() endif() endif() endif() - if (NOT ${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION) - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_VERSION}") + if (NOT YOKAI_${lang}_COMPILER_EXTENDED_VERSION) + set(YOKAI_${lang}_COMPILER_EXTENDED_VERSION "${YOKAI_${lang}_COMPILER_VERSION}") endif() - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING - "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME}_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_EXTENDED_VERSION}:${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_BASENAME}") + set(YOKAI_${lang}_COMPILER_STRING + "${YOKAI_${lang}_COMPILER_NAME}_${YOKAI_${lang}_COMPILER_EXTENDED_VERSION}:${YOKAI_${lang}_COMPILER_BASENAME}") if (CMAKE_CXX_COMPILER_ARG1) - set(${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING "${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING}:${CMAKE_CXX_COMPILER_ARG1}") + set(YOKAI_${lang}_COMPILER_STRING "${YOKAI_${lang}_COMPILER_STRING}:${CMAKE_CXX_COMPILER_ARG1}") endif() - message(STATUS "Detected ${${lang}_NAME} compiler: ${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING}") + message(STATUS "Detected ${${lang}_NAME} compiler: ${YOKAI_${lang}_COMPILER_STRING}") # Makes possible to do that in C++ code: - # > if defined(${YOKAI_CMAKE_SLUG}_CXX_COMPILER_Clang) - set(compiler_var_name "${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_NAME}") + # > if defined(YOKAI_CXX_COMPILER_Clang) + set(compiler_var_name "YOKAI_${lang}_COMPILER_${YOKAI_${lang}_COMPILER_NAME}") add_definitions(-D${compiler_var_name}) # Makes possible to do that in CMake code: - # > if (${YOKAI_CMAKE_SLUG}_CXX_COMPILER_Clang) + # > if (YOKAI_CXX_COMPILER_Clang) set("${compiler_var_name}" ON) - if (${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR) + if (YOKAI_SOURCE_GENERATOR) # Add printable string to the executable. - yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_${lang}_COMPILER_STRING" "\"${${YOKAI_CMAKE_SLUG}_${lang}_COMPILER_STRING}\"") + yokai_add_buildinfo("char*" "YOKAI_${lang}_COMPILER_STRING" "\"${YOKAI_${lang}_COMPILER_STRING}\"") endif() endforeach() diff --git a/cmake/Yokai/Detection.cmake b/cmake/Yokai/Detection.cmake index 870ea30ce5..0b265574cd 100644 --- a/cmake/Yokai/Detection.cmake +++ b/cmake/Yokai/Detection.cmake @@ -28,8 +28,6 @@ # System, architecture and compiler detection. ################################################################################ -include("${CMAKE_CURRENT_LIST_DIR}/Variable.cmake") - # Make sure to always call this macro from within a function, not in the global scope. # As a macro it produces a lot of variables in the parent scope but it is meant to # only be called by functions so they should never pollute the globale scope. @@ -76,7 +74,7 @@ macro(yokai_run_detection slug_prefix report_slug file_name compat_list) string(REGEX REPLACE ${COMPATIBILITY_REGEX} "\\1" ${local_slug}_${name}_compatibility "${build_log}") - set("${YOKAI_CMAKE_SLUG}_${slug_prefix}${report_slug}_${name}_COMPATIBILITY" + set("YOKAI_${slug_prefix}${report_slug}_${name}_COMPATIBILITY" "${${local_slug}_${name}_compatibility}" PARENT_SCOPE) endif() @@ -86,7 +84,7 @@ macro(yokai_run_detection slug_prefix report_slug file_name compat_list) string(REGEX REPLACE ${VERSION_REGEX} "\\1" ${local_slug}_${name}_version "${build_log}") - set("${YOKAI_CMAKE_SLUG}_${slug_prefix}${report_slug}_${name}_VERSION" + set("YOKAI_${slug_prefix}${report_slug}_${name}_VERSION" "${${local_slug}_${name}_version}" PARENT_SCOPE) endif() diff --git a/cmake/Yokai/SourceGenerator.cmake b/cmake/Yokai/SourceGenerator.cmake index be82a4d8c6..e515556d89 100644 --- a/cmake/Yokai/SourceGenerator.cmake +++ b/cmake/Yokai/SourceGenerator.cmake @@ -1,5 +1,5 @@ -# ${YOKAI_FILE_SLUG} BSD Source Code -# Copyright (c) 2025, ${YOKAI_FILE_SLUG} Developers +# Daemon BSD Source Code +# Copyright (c) 2025, Daemon Developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,73 +28,71 @@ # Source generation and file embedding. ################################################################################ -include("${CMAKE_CURRENT_LIST_DIR}/Variable.cmake") - -set(${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR "${CMAKE_CURRENT_LIST_FILE}") +set(YOKAI_SOURCE_GENERATOR "${CMAKE_CURRENT_LIST_FILE}") get_filename_component(current_list_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(${YOKAI_CMAKE_SLUG}_FILE_EMBEDDER "${current_list_dir}/FileEmbedder.cmake") +set(YOKAI_FILE_EMBEDDER "${current_list_dir}/FileEmbedder.cmake") -set(${YOKAI_CMAKE_SLUG}_GENERATED_SUBDIR "GeneratedSource") -set(${YOKAI_CMAKE_SLUG}_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/${${YOKAI_CMAKE_SLUG}_GENERATED_SUBDIR}") +set(YOKAI_GENERATED_SUBDIR "YokaiGeneratedSource") +set(YOKAI_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/${YOKAI_GENERATED_SUBDIR}") -set(${YOKAI_CMAKE_SLUG}_BUILDINFO_SUBDIR "${YOKAI_FILE_SLUG}BuildInfo") -set(${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR "${YOKAI_FILE_SLUG}EmbeddedFiles") +set(YOKAI_BUILDINFO_SUBDIR "YokaiBuildInfo") +set(YOKAI_EMBEDDED_SUBDIR "YokaiEmbeddedFiles") -set(${YOKAI_CMAKE_SLUG}_BUILDINFO_DIR "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${${YOKAI_CMAKE_SLUG}_BUILDINFO_SUBDIR}") -set(${YOKAI_CMAKE_SLUG}_EMBEDDED_DIR "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}") +set(YOKAI_BUILDINFO_DIR "${YOKAI_GENERATED_DIR}/${YOKAI_BUILDINFO_SUBDIR}") +set(YOKAI_EMBEDDED_DIR "${YOKAI_GENERATED_DIR}/${YOKAI_EMBEDDED_SUBDIR}") -file(MAKE_DIRECTORY "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}") -include_directories("${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}") +file(MAKE_DIRECTORY "${YOKAI_GENERATED_DIR}") +include_directories("${YOKAI_GENERATED_DIR}") -file(MAKE_DIRECTORY "${${YOKAI_CMAKE_SLUG}_BUILDINFO_DIR}") -file(MAKE_DIRECTORY "${${YOKAI_CMAKE_SLUG}_EMBEDDED_DIR}") +file(MAKE_DIRECTORY "${YOKAI_BUILDINFO_DIR}") +file(MAKE_DIRECTORY "${YOKAI_EMBEDDED_DIR}") -set(${YOKAI_CMAKE_SLUG}_GENERATED_HEADER "// Automatically generated, do not modify!\n") -set(${YOKAI_CMAKE_SLUG}_GENERATED_CPP_EXT ".cpp") -set(${YOKAI_CMAKE_SLUG}_GENERATED_H_EXT ".h") +set(YOKAI_GENERATED_HEADER "// Automatically generated, do not modify!\n") +set(YOKAI_GENERATED_CPP_EXT ".cpp") +set(YOKAI_GENERATED_H_EXT ".h") set(BUILDINFOLIST) foreach(kind CPP H) - set(${YOKAI_CMAKE_SLUG}_BUILDINFO_${kind}_TEXT "${${YOKAI_CMAKE_SLUG}_GENERATED_HEADER}") + set(YOKAI_BUILDINFO_${kind}_TEXT "${YOKAI_GENERATED_HEADER}") endforeach() macro(yokai_add_buildinfo type name value) - string(APPEND ${YOKAI_CMAKE_SLUG}_BUILDINFO_CPP_TEXT "const ${type} ${name}=${value};\n") - string(APPEND ${YOKAI_CMAKE_SLUG}_BUILDINFO_H_TEXT "extern const ${type} ${name};\n") + string(APPEND YOKAI_BUILDINFO_CPP_TEXT "const ${type} ${name}=${value};\n") + string(APPEND YOKAI_BUILDINFO_H_TEXT "extern const ${type} ${name};\n") endmacro() macro(yokai_write_buildinfo name) foreach(kind CPP H) - set(buildinfo_file_path "${${YOKAI_CMAKE_SLUG}_BUILDINFO_DIR}/${name}${${YOKAI_CMAKE_SLUG}_GENERATED_${kind}_EXT}") + set(buildinfo_file_path "${YOKAI_BUILDINFO_DIR}/${name}${YOKAI_GENERATED_${kind}_EXT}") - file(GENERATE OUTPUT "${buildinfo_file_path}" CONTENT "${${YOKAI_CMAKE_SLUG}_BUILDINFO_${kind}_TEXT}") + file(GENERATE OUTPUT "${buildinfo_file_path}" CONTENT "${YOKAI_BUILDINFO_${kind}_TEXT}") list(APPEND BUILDINFOLIST "${buildinfo_file_path}") endforeach() endmacro() macro(yokai_embed_files basename dir list format targetname) - set(embed_subdir "${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}/${basename}") - set(embed_dir "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${embed_subdir}") + set(embed_subdir "${YOKAI_EMBEDDED_SUBDIR}/${basename}") + set(embed_dir "${YOKAI_GENERATED_DIR}/${embed_subdir}") file(MAKE_DIRECTORY "${embed_dir}") foreach(kind CPP H) - set(embed_${kind}_basename "${basename}${${YOKAI_CMAKE_SLUG}_GENERATED_${kind}_EXT}") - set(embed_${kind}_src_file "${${YOKAI_CMAKE_SLUG}_EMBEDDED_DIR}/${embed_${kind}_basename}") - set(embed_${kind}_file "${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}/${embed_${kind}_basename}") - set(embed_${kind}_text "${${YOKAI_CMAKE_SLUG}_GENERATED_HEADER}") - set_property(SOURCE "${embed_${kind}_src_file}" APPEND PROPERTY OBJECT_DEPENDS "${${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR}") + set(embed_${kind}_basename "${basename}${YOKAI_GENERATED_${kind}_EXT}") + set(embed_${kind}_src_file "${YOKAI_EMBEDDED_DIR}/${embed_${kind}_basename}") + set(embed_${kind}_file "${YOKAI_EMBEDDED_SUBDIR}/${embed_${kind}_basename}") + set(embed_${kind}_text "${YOKAI_GENERATED_HEADER}") + set_property(SOURCE "${embed_${kind}_src_file}" APPEND PROPERTY OBJECT_DEPENDS "${YOKAI_SOURCE_GENERATOR}") set_property(TARGET "${targetname}" APPEND PROPERTY SOURCES "${embed_${kind}_src_file}") endforeach() - if (NOT ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER) - set(${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER "${${YOKAI_CMAKE_SLUG}_EMBEDDED_SUBDIR}/${YOKAI_FILE_SLUG}EmbeddedFiles.h") + if (NOT YOKAI_EMBEDDED_FILES_HEADER) + set(YOKAI_EMBEDDED_FILES_HEADER "${YOKAI_EMBEDDED_SUBDIR}/YokaiEmbeddedFiles.h") string(APPEND embed_header_text "// Automatically generated, do not modify!\n" - "#ifndef ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_H_\n" - "#define ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_H_\n" + "#ifndef YOKAI_EMBEDDED_FILES_H_\n" + "#define YOKAI_EMBEDDED_FILES_H_\n" "#include \n" "#include \n" "#include \n" @@ -106,10 +104,10 @@ macro(yokai_embed_files basename dir list format targetname) "};\n" "\n" "using embeddedFileMap_t = std::unordered_map;\n" - "#endif // ${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_H_\n" + "#endif // YOKAI_EMBEDDED_FILES_H_\n" ) - set(embed_header_file "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER}") + set(embed_header_file "${YOKAI_GENERATED_DIR}/${YOKAI_EMBEDDED_FILES_HEADER}") file(GENERATE OUTPUT "${embed_header_file}" CONTENT "${embed_header_text}") endif() @@ -120,7 +118,7 @@ macro(yokai_embed_files basename dir list format targetname) ) string(APPEND embed_H_text - "#include \"${${YOKAI_CMAKE_SLUG}_EMBEDDED_FILES_HEADER}\"\n" + "#include \"${YOKAI_EMBEDDED_FILES_HEADER}\"\n" "\n" "namespace ${basename} {\n" ) @@ -131,7 +129,7 @@ macro(yokai_embed_files basename dir list format targetname) string(REGEX REPLACE "[^A-Za-z0-9]" "_" filename_symbol "${filename}") set(inpath "${dir}/${filename}") - set(outpath "${embed_dir}/${filename_symbol}${${YOKAI_CMAKE_SLUG}_GENERATED_H_EXT}") + set(outpath "${embed_dir}/${filename_symbol}${YOKAI_GENERATED_H_EXT}") add_custom_command( OUTPUT "${outpath}" @@ -140,11 +138,11 @@ macro(yokai_embed_files basename dir list format targetname) "-DOUTPUT_FILE=${outpath}" "-DFILE_FORMAT=${format}" "-DVARIABLE_NAME=${filename_symbol}" - -P "${${YOKAI_CMAKE_SLUG}_FILE_EMBEDDER}" + -P "${YOKAI_FILE_EMBEDDER}" MAIN_DEPENDENCY ${inpath} DEPENDS - "${${YOKAI_CMAKE_SLUG}_FILE_EMBEDDER}" - "${${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR}" + "${YOKAI_FILE_EMBEDDER}" + "${YOKAI_SOURCE_GENERATOR}" ) set_property(TARGET "${targetname}" APPEND PROPERTY SOURCES "${outpath}") @@ -176,7 +174,7 @@ macro(yokai_embed_files basename dir list format targetname) ) foreach(kind CPP H) - set(embed_file "${${YOKAI_CMAKE_SLUG}_GENERATED_DIR}/${embed_${kind}_file}") + set(embed_file "${YOKAI_GENERATED_DIR}/${embed_${kind}_file}") file(GENERATE OUTPUT "${embed_file}" CONTENT "${embed_${kind}_text}") endforeach() endmacro() diff --git a/cmake/Yokai/System.cmake b/cmake/Yokai/System.cmake index a00de63423..f2ee120530 100644 --- a/cmake/Yokai/System.cmake +++ b/cmake/Yokai/System.cmake @@ -28,8 +28,8 @@ # System detection. ################################################################################ -# When adding a new system, look at all the places ${YOKAI_CMAKE_SLUG}_HOST_SYSTEM -# and ${YOKAI_CMAKE_SLUG}_SYSTEM are used. +# When adding a new system, look at all the places YOKAI_HOST_SYSTEM +# and YOKAI_SYSTEM are used. function(yokai_detect_host_system) set(system_name "Unknown") @@ -63,7 +63,7 @@ function(yokai_detect_host_system) detect_cmake_host_system("system_name") endif() - set(${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME "${system_name}" PARENT_SCOPE) + set(YOKAI_HOST_SYSTEM_NAME "${system_name}" PARENT_SCOPE) endfunction() function(yokai_detect_system) @@ -73,42 +73,42 @@ function(yokai_detect_system) detect_cmake_host_system("system_name") endif() - set(${YOKAI_CMAKE_SLUG}_SYSTEM_NAME "${system_name}" PARENT_SCOPE) + set(YOKAI_SYSTEM_NAME "${system_name}" PARENT_SCOPE) endfunction() yokai_detect_host_system() yokai_detect_system() -if ("${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "Unknown") +if ("${YOKAI_HOST_SYSTEM_NAME}" STREQUAL "Unknown") message(WARNING "Unknown host system") endif() -if ("${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" STREQUAL "Unknown") +if ("${YOKAI_SYSTEM_NAME}" STREQUAL "Unknown") message(WARNING "Unknown target system") endif() -if ("${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" STREQUAL "Unknown") - message(WARNING "Assuming the host system is the same as the target: ${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") - set(${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME "${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") +if ("${YOKAI_HOST_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${YOKAI_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Assuming the host system is the same as the target: ${YOKAI_SYSTEM_NAME}") + set(YOKAI_HOST_SYSTEM_NAME "${YOKAI_SYSTEM_NAME}") endif() -if ("${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "Unknown") - message(WARNING "Assuming the target system is the same as the host: ${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") - set(${YOKAI_CMAKE_SLUG}_SYSTEM_NAME "${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}") +if ("${YOKAI_SYSTEM_NAME}" STREQUAL "Unknown" AND NOT "${YOKAI_HOST_SYSTEM_NAME}" STREQUAL "Unknown") + message(WARNING "Assuming the target system is the same as the host: ${YOKAI_SYSTEM_NAME}") + set(YOKAI_SYSTEM_NAME "${YOKAI_HOST_SYSTEM_NAME}") endif() -message(STATUS "Detected host system: ${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}") -message(STATUS "Detected target system: ${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") +message(STATUS "Detected host system: ${YOKAI_HOST_SYSTEM_NAME}") +message(STATUS "Detected target system: ${YOKAI_SYSTEM_NAME}") -if (NOT "${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" STREQUAL "${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}") +if (NOT "${YOKAI_HOST_SYSTEM_NAME}" STREQUAL "${YOKAI_SYSTEM_NAME}") message(STATUS "Detected cross-compilation") endif() # Makes possible to do that in CMake code: -# > if (${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_Linux) -# > if (${YOKAI_CMAKE_SLUG}_SYSTEM_Windows) -set("${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_${${YOKAI_CMAKE_SLUG}_HOST_SYSTEM_NAME}" ON) -set("${YOKAI_CMAKE_SLUG}_SYSTEM_${${YOKAI_CMAKE_SLUG}_SYSTEM_NAME}" ON) +# > if (YOKAI_HOST_SYSTEM_Linux) +# > if (YOKAI_SYSTEM_Windows) +set("YOKAI_HOST_SYSTEM_${YOKAI_HOST_SYSTEM_NAME}" ON) +set("YOKAI_SYSTEM_${YOKAI_SYSTEM_NAME}" ON) # This is for systems with behaviors similar to Linux, # implementing standards like FHS, XDG, GLVND… @@ -123,7 +123,7 @@ foreach(name Linux;FreeBSD) endforeach() endforeach() -if (${YOKAI_CMAKE_SLUG}_SOURCE_GENERATOR) +if (YOKAI_SOURCE_GENERATOR) # Add printable string to the executable. - yokai_add_buildinfo("char*" "${YOKAI_C_SLUG}_SYSTEM_STRING" "\"${${YOKAI_C_SLUG}_SYSTEM_NAME}\"") + yokai_add_buildinfo("char*" "YOKAI_SYSTEM_STRING" "\"${YOKAI_SYSTEM_NAME}\"") endif() diff --git a/cmake/Yokai/Variable.cmake b/cmake/Yokai/Variable.cmake deleted file mode 100644 index f952f677e3..0000000000 --- a/cmake/Yokai/Variable.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# Daemon BSD Source Code -# Copyright (c) 2025, Daemon Developers -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -################################################################################ -# Reusable variable expansion. -################################################################################ - -if (NOT DEFINED YOKAI_FILE_SLUG) - set(YOKAI_FILE_SLUG "Yokai") -endif() - -if (NOT DEFINED YOKAI_CMAKE_SLUG) - string(TOUPPER "${YOKAI_FILE_SLUG}" YOKAI_CMAKE_SLUG) -endif() - -if (NOT DEFINED YOKAI_C_SLUG) - string(TOUPPER "${YOKAI_FILE_SLUG}" YOKAI_C_SLUG) -endif() - -if (NOT DEFINED YOKAI_INITIALIZED) - message(NOTICE "Using YOKAI_FILE_SLUG: ${YOKAI_FILE_SLUG}") - message(NOTICE "Using YOKAI_CMAKE_SLUG: ${YOKAI_CMAKE_SLUG}") - message(NOTICE "Using YOKAI_C_SLUG: ${YOKAI_C_SLUG}") - set(YOKAI_INITIALIZED ON) -endif() diff --git a/freetype.cmake b/freetype.cmake index 6dff87a83e..5d5e89f1c8 100644 --- a/freetype.cmake +++ b/freetype.cmake @@ -2,7 +2,7 @@ set(FREETYPE_DIR ${DAEMON_DIR}/libs/freetype) set(FREETYPE_INCLUDE_DIRS ${FREETYPE_DIR}/include) set(FREETYPE_LIBRARIES freetype) -if (DAEMON_SYSTEM_NaCl) +if (YOKAI_SYSTEM_NaCl) # Using Freetype's own zlib prevents the need for a zlib submodule when building the nexe cgame. set(FREETYPE_INTERNAL_ZLIB ON) else() diff --git a/src.cmake b/src.cmake index c51414c642..dff99d628e 100644 --- a/src.cmake +++ b/src.cmake @@ -211,7 +211,7 @@ set(OMPLIST ${ENGINE_DIR}/framework/OmpSystem.h ) -if (DAEMON_SYSTEM_Windows) +if (YOKAI_SYSTEM_Windows) set(ENGINELIST ${ENGINELIST} ${ENGINE_DIR}/sys/con_passive.cpp ) @@ -301,7 +301,7 @@ set(CLIENTLIST ${RENDERERLIST} ) -if (DAEMON_SYSTEM_macOS) +if (YOKAI_SYSTEM_macOS) set(CLIENTLIST ${CLIENTLIST} ${ENGINE_DIR}/sys/DisableAccentMenu.m) endif() diff --git a/src/common/Common.h b/src/common/Common.h index 4fedbd6844..c40f8fb627 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -31,6 +31,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef COMMON_COMMON_H_ #define COMMON_COMMON_H_ +// TODO: Remove when the game is ported to Yokai. +#if !defined(DAEMON_ARCH_STRING) +#define DAEMON_ARCH_STRING YOKAI_ARCH_STRING +#endif +#if !defined(DAEMON_CXX_COMPILER_STRING) +#define DAEMON_CXX_COMPILER_STRING YOKAI_CXX_COMPILER_STRING +#endif + // Compiler.h, Platform.h and Endian.h are included by q_shared.h #include "engine/qcommon/q_shared.h" diff --git a/src/common/Compiler.h b/src/common/Compiler.h index 25516fe008..28d320a0ce 100644 --- a/src/common/Compiler.h +++ b/src/common/Compiler.h @@ -147,8 +147,8 @@ inline int CountTrailingZeroes(unsigned long long x) #endif // Raise an exception and break in the debugger -#if defined(DAEMON_ARCH_i686) || defined(DAEMON_ARCH_amd64) - // Always run this asm code even if DAEMON_USE_ARCH_INTRINSICS is not defined. +#if defined(YOKAI_ARCH_i686) || defined(YOKAI_ARCH_amd64) + // Always run this asm code even if YOKAI_USE_ARCH_INTRINSICS is not defined. #define BREAKPOINT() __asm__ __volatile__("int $3\n\t") #endif diff --git a/src/common/Platform.h b/src/common/Platform.h index 15e686a898..9fd0ace489 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -41,8 +41,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #error "Platform not supported" #endif -// TODO: Remove once the game code is ported to DAEMON_SYSTEM_STRING. -#define PLATFORM_STRING DAEMON_SYSTEM_STRING +// TODO: Remove once the game code is ported to YOKAI_SYSTEM_STRING. +#define PLATFORM_STRING YOKAI_SYSTEM_STRING #if defined(__native_client__) #elif defined(_WIN32) @@ -55,19 +55,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PATH_SEP '/' #endif -#if defined(DAEMON_ARCH_i686) +#if defined(YOKAI_ARCH_i686) #undef __i386__ #define __i386__ 1 -#elif defined(DAEMON_ARCH_amd64) +#elif defined(YOKAI_ARCH_amd64) #undef __x86_64__ #define __x86_64__ 1 #endif -/* The definition name syntax is: DAEMON_USE_ARCH_INTRINSICS_[_extension] +/* The definition name syntax is: YOKAI_USE_ARCH_INTRINSICS_[_extension] Examples: -- DAEMON_USE_ARCH_INTRINSICS_i686: i686 specific code, including asm code. +- YOKAI_USE_ARCH_INTRINSICS_i686: i686 specific code, including asm code. - DAEMON_USE_ARCH_INTRINSICS_i686_sse: i686 SSE specific code. - DAEMON_USE_ARCH_INTRINSICS_i686_sse2: i686 SSE2 specific code. @@ -78,7 +78,7 @@ i686 with SSE and amd64. The definitions for the architecture itself are automatically set by CMake. */ -#if defined(DAEMON_USE_ARCH_INTRINSICS) +#if defined(YOKAI_USE_ARCH_INTRINSICS) // Set architecture extensions definitions. #if defined(_MSC_VER) diff --git a/src/engine/framework/System.cpp b/src/engine/framework/System.cpp index b5291bbe3e..decfec02bc 100644 --- a/src/engine/framework/System.cpp +++ b/src/engine/framework/System.cpp @@ -56,11 +56,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(DAEMON_USE_FLOAT_EXCEPTIONS) #if defined(__USE_GNU) || defined(__FreeBSD__) || defined(_WIN32) - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_i686) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_i686) #define DAEMON_USE_FLOAT_EXCEPTIONS_AVAILABLE #endif #elif defined (__APPLE__) - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_arm64) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_arm64) #define DAEMON_USE_FLOAT_EXCEPTIONS_AVAILABLE #endif #endif @@ -390,7 +390,7 @@ static void CloseSingletonSocket() static void SetFloatingPointExceptions() { #if defined(DAEMON_USE_FLOAT_EXCEPTIONS_AVAILABLE) - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_i686) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_i686) #if defined(__USE_GNU) || defined(__FreeBSD__) || defined(__APPLE__) int exceptions = 0; #elif defined(_WIN32) @@ -400,7 +400,7 @@ static void SetFloatingPointExceptions() #if defined(DAEMON_USE_ARCH_INTRINSICS_i686_sse) int mxcsr_exceptions = 0; #endif - #elif defined(DAEMON_ARCH_arm64) + #elif defined(YOKAI_ARCH_arm64) #if defined(__APPLE__) unsigned long long fpcr_exceptions = 0; #endif @@ -409,7 +409,7 @@ static void SetFloatingPointExceptions() // Operations with NaN. if (common_floatExceptions_invalid.Get()) { - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_i686) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_i686) #if defined(__USE_GNU) || defined(__FreeBSD__) || defined(__APPLE__) exceptions |= FE_INVALID; #elif defined(_WIN32) @@ -419,7 +419,7 @@ static void SetFloatingPointExceptions() #if defined(DAEMON_USE_ARCH_INTRINSICS_i686_sse) mxcsr_exceptions |= _MM_MASK_INVALID; #endif - #elif defined(DAEMON_ARCH_arm64) + #elif defined(YOKAI_ARCH_arm64) #if defined(__APPLE__) fpcr_exceptions |= __fpcr_trap_invalid; #endif @@ -429,7 +429,7 @@ static void SetFloatingPointExceptions() // Division by zero. if (common_floatExceptions_divByZero.Get()) { - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_i686) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_i686) #if defined(__USE_GNU) || defined(__FreeBSD__) || defined(__APPLE__) exceptions |= FE_DIVBYZERO; #elif defined(_WIN32) @@ -439,7 +439,7 @@ static void SetFloatingPointExceptions() #if defined(DAEMON_USE_ARCH_INTRINSICS_i686_sse) mxcsr_exceptions |= _MM_MASK_DIV_ZERO; #endif - #elif defined(DAEMON_ARCH_arm64) + #elif defined(YOKAI_ARCH_arm64) #if defined(__APPLE__) fpcr_exceptions |= __fpcr_trap_divbyzero; #endif @@ -449,7 +449,7 @@ static void SetFloatingPointExceptions() // Operations producing an overflow. if (common_floatExceptions_overflow.Get()) { - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_i686) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_i686) #if defined(__USE_GNU) || defined(__FreeBSD__) || defined(__APPLE__) exceptions |= FE_OVERFLOW; #elif defined(_WIN32) @@ -459,14 +459,14 @@ static void SetFloatingPointExceptions() #if defined(DAEMON_USE_ARCH_INTRINSICS_i686_sse) mxcsr_exceptions |= _MM_MASK_OVERFLOW; #endif - #elif defined(DAEMON_ARCH_arm64) + #elif defined(YOKAI_ARCH_arm64) #if defined(__APPLE__) fpcr_exceptions |= __fpcr_trap_overflow; #endif #endif } - #if defined(DAEMON_ARCH_amd64) || defined(DAEMON_ARCH_i686) + #if defined(YOKAI_ARCH_amd64) || defined(YOKAI_ARCH_i686) #if defined(__USE_GNU) || defined(__FreeBSD__) // https://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Control-Functions.html feenableexcept(exceptions); @@ -483,10 +483,10 @@ static void SetFloatingPointExceptions() fenv_t env; fegetenv( &env ); - #if defined(DAEMON_ARCH_amd64) + #if defined(YOKAI_ARCH_amd64) env.__control &= ~exceptions; env.__mxcsr &= ~mxcsr_exceptions; - #elif defined(DAEMON_ARCH_arm64) + #elif defined(YOKAI_ARCH_arm64) env.__fpcr |= fpcr_exceptions; #endif @@ -845,7 +845,7 @@ static void Init(int argc, char** argv) #endif // Print a banner and a copy of the command-line arguments - Log::Notice("%s %s %s (%s) %s", Q3_VERSION, DAEMON_SYSTEM_STRING, DAEMON_ARCH_STRING, DAEMON_CXX_COMPILER_STRING, __DATE__); + Log::Notice("%s %s %s (%s) %s", Q3_VERSION, YOKAI_SYSTEM_STRING, YOKAI_ARCH_STRING, YOKAI_CXX_COMPILER_STRING, __DATE__); std::string argsString = "cmdline:"; for (int i = 1; i < argc; i++) { diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index bc37adae72..6e4db6049a 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -46,7 +46,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern char **environ; #ifdef __linux__ #include -#if defined(DAEMON_ARCH_armhf) +#if defined(YOKAI_ARCH_armhf) #include #endif #endif @@ -138,7 +138,7 @@ static Cvar::Cvar vm_timeout( "Receive timeout in seconds", Cvar::NONE, 2); -#if defined(DAEMON_NACL_RUNTIME_ENABLED) +#if defined(YOKAI_NACL_RUNTIME_ENABLED) static Cvar::Cvar vm_nacl_available( "vm.nacl.available", "Whether NaCl runtime is available on this platform", @@ -329,7 +329,7 @@ static std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair pair = IPC::Socket::CreatePair(); IPC::Socket rootSocket; -#if !defined(DAEMON_NACL_RUNTIME_ENABLED) +#if !defined(YOKAI_NACL_RUNTIME_ENABLED) if (type == TYPE_NACL || type == TYPE_NACL_LIBPATH) { Sys::Error("NaCl VM is not supported on this platform. " "Set vm.cgame.type and vm.sgame.type to 3 (native DLL) " diff --git a/src/engine/qcommon/common.cpp b/src/engine/qcommon/common.cpp index d96e7ea368..e4e9e7d6dd 100644 --- a/src/engine/qcommon/common.cpp +++ b/src/engine/qcommon/common.cpp @@ -571,7 +571,7 @@ void Com_Init() Cmd_AddCommand( "writebindings", Com_WriteBindings_f ); #endif - s = va( "%s %s %s %s", Q3_VERSION, PLATFORM_STRING, DAEMON_ARCH_STRING, __DATE__ ); + s = va( "%s %s %s %s", Q3_VERSION, PLATFORM_STRING, YOKAI_ARCH_STRING, __DATE__ ); com_version = Cvar_Get( "version", s, CVAR_ROM | CVAR_SERVERINFO | CVAR_USERINFO ); Cmd_AddCommand( "in_restart", Com_In_Restart_f ); diff --git a/src/engine/qcommon/q_shared.h b/src/engine/qcommon/q_shared.h index 7b33e27f36..1ca746067e 100644 --- a/src/engine/qcommon/q_shared.h +++ b/src/engine/qcommon/q_shared.h @@ -38,9 +38,9 @@ Maryland 20850 USA. #include "common/Defs.h" #if defined(BUILD_VM) -#include "DaemonBuildInfo/Game.h" +#include "YokaiBuildInfo/DaemonGame.h" #else -#include "DaemonBuildInfo/Engine.h" +#include "YokaiBuildInfo/DaemonEngine.h" #endif // math.h/cmath uses _USE_MATH_DEFINES to decide if to define M_PI etc or not. diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 60d853d642..6a5c1287a7 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "gl_shader.h" #include "Material.h" -#include "DaemonEmbeddedFiles/EngineShaders.h" +#include "YokaiEmbeddedFiles/DaemonEngineShaders.h" // We currently write GLBinaryHeader to a file and memcpy all over it. // Make sure it's a pod, so we don't put a std::string in it or something @@ -90,8 +90,8 @@ namespace // Implementation details const char* GetInternalShader(Str::StringRef filename) { - auto it = EngineShaders::FileMap.find(filename); - if (it != EngineShaders::FileMap.end()) + auto it = DaemonEngineShaders::FileMap.find(filename); + if (it != DaemonEngineShaders::FileMap.end()) return it->second.data; return nullptr; } diff --git a/src/engine/renderer/tr_font.cpp b/src/engine/renderer/tr_font.cpp index 54a7536c7e..a92bb9622c 100644 --- a/src/engine/renderer/tr_font.cpp +++ b/src/engine/renderer/tr_font.cpp @@ -39,7 +39,7 @@ Maryland 20850 USA. #include "qcommon/qcommon.h" #include "qcommon/q_unicode.h" -#include "DaemonEmbeddedFiles/ConsoleFont.h" +#include "YokaiEmbeddedFiles/DaemonEngineFont.h" #include #include FT_FREETYPE_H @@ -421,8 +421,8 @@ static int RE_LoadFontFile( const char *name, void **buffer ) { if ( !*name ) { - *buffer = (void *)( ConsoleFont::unifont_otf.data ); - return ConsoleFont::unifont_otf.size; + *buffer = (void *)( DaemonEngineFont::unifont_otf.data ); + return DaemonEngineFont::unifont_otf.size; } std::string tmp; @@ -452,7 +452,7 @@ static int RE_LoadFontFile( const char *name, void **buffer ) static void RE_FreeFontFile( void *data ) { - if ( data != ConsoleFont::unifont_otf.data ) + if ( data != DaemonEngineFont::unifont_otf.data ) { Z_Free( data ); } diff --git a/src/engine/renderer/tr_model_iqm.cpp b/src/engine/renderer/tr_model_iqm.cpp index a3b35fc0aa..5625e6f0e1 100644 --- a/src/engine/renderer/tr_model_iqm.cpp +++ b/src/engine/renderer/tr_model_iqm.cpp @@ -37,7 +37,7 @@ Maryland 20850 USA. /* Flags -O2, -O3 and -0s produce SIGBUS in R_LoadIQModel() on armhf, see https://github.com/DaemonEngine/Daemon/issues/736 */ -#if defined(DAEMON_ARCH_armhf) && !defined(DAEMON_BUILD_Debug) && __GNUC__ +#if defined(YOKAI_ARCH_armhf) && !defined(DAEMON_BUILD_Debug) && __GNUC__ #pragma GCC optimize("O1") #endif diff --git a/srclibs.cmake b/srclibs.cmake index 0de7355dd3..f0bd6d6918 100644 --- a/srclibs.cmake +++ b/srclibs.cmake @@ -33,19 +33,19 @@ set(NACLLIST_MODULE ${LIB_DIR}/nacl/native_client/src/untrusted/nacl/imc_socketpair.c ) -if (DAEMON_SYSTEM_macOS) +if (YOKAI_SYSTEM_macOS) set(NACLLIST_NATIVE ${LIB_DIR}/nacl/native_client/src/shared/imc/nacl_imc_common.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/osx/nacl_imc.cc ) -elseif (DAEMON_SYSTEM_Linux_COMPATIBILITY) +elseif (YOKAI_SYSTEM_Linux_COMPATIBILITY) set(NACLLIST_NATIVE ${LIB_DIR}/nacl/native_client/src/shared/imc/nacl_imc_common.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/posix/nacl_imc_posix.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/linux/nacl_imc.cc ) -elseif (DAEMON_SYSTEM_Windows) +elseif (YOKAI_SYSTEM_Windows) set(NACLLIST_NATIVE ${LIB_DIR}/nacl/native_client/src/shared/imc/nacl_imc_common.cc ${LIB_DIR}/nacl/native_client/src/shared/imc/win/nacl_imc.cc @@ -101,7 +101,7 @@ set(PDCURSESLIST ${LIB_DIR}/pdcursesmod/pdcurses/window.c ) -if (DAEMON_SYSTEM_Windows) +if (YOKAI_SYSTEM_Windows) set(PDCURSESLIST ${PDCURSESLIST} ${LIB_DIR}/pdcursesmod/wingui/pdcclip.c @@ -153,7 +153,7 @@ set(TINYGETTEXTLIST ${LIB_DIR}/tinygettext/tinygettext.hpp ) -if (DAEMON_SYSTEM_Windows) +if (YOKAI_SYSTEM_Windows) set(BREAKPAD_COMMON_LIST ${LIB_DIR}/breakpad/src/common/windows/guid_string.cc ${LIB_DIR}/breakpad/src/common/windows/guid_string.h @@ -180,8 +180,8 @@ if (DAEMON_SYSTEM_Windows) ${LIB_DIR}/breakpad/src/client/windows/handler/exception_handler.h ) # We don't know if this works outside of Linux, -# so we don't use DAEMON_SYSTEM_Linux_COMPATIBILITY. -elseif (DAEMON_SYSTEM_Linux) +# so we don't use YOKAI_SYSTEM_Linux_COMPATIBILITY. +elseif (YOKAI_SYSTEM_Linux) set(BREAKPAD_LIST ${LIB_DIR}/breakpad/src/client/linux/crash_generation/crash_generation_client.cc ${LIB_DIR}/breakpad/src/client/linux/crash_generation/crash_generation_server.cc From a709c821e1c1a5f1697c13ccd3a796a1c54ab85b Mon Sep 17 00:00:00 2001 From: "dev@illwieckz.net" Date: Fri, 5 Jun 2026 16:39:32 +0200 Subject: [PATCH 14/14] yokai: only run NaCl code when YOKAI_NACL_HOST is enabled --- CMakeLists.txt | 1 + cmake/Yokai/Architecture.cmake | 72 +++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9ab73cae6..2fd7d8488f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,7 @@ if (Daemon_OUT) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Daemon_OUT}) endif() +set(YOKAI_NACL_HOST ON) include(Yokai/All) ################################################################################ diff --git a/cmake/Yokai/Architecture.cmake b/cmake/Yokai/Architecture.cmake index f66d3fa635..8b6da48101 100644 --- a/cmake/Yokai/Architecture.cmake +++ b/cmake/Yokai/Architecture.cmake @@ -42,42 +42,44 @@ function(yokai_detect_arch) add_definitions(-DYOKAI_ARCH_${arch_name}) - set(nacl_arch "${arch_name}") - - if (YOKAI_SYSTEM_Linux_COMPATIBILITY) - set(armhf_usage "arm64;armel") - if ("${arch_name}" IN_LIST armhf_usage) - # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. - # The nexe is system agnostic so there should be no difference with armel. - set(nacl_arch "armhf") - - set(box64_usage ppc64el riscv64) - if ("${arch_name}" IN_LIST box64_usage) - option(YOKAI_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) - if (YOKAI_NACL_BOX64_EMULATION) - # Use Box64 to run x86_64 NaCl loader and amd64 nexe. - # Box64 must be installed and available in PATH at runtime. - set(nacl_arch "amd64") - add_definitions(-DYOKAI_NACL_BOX64_EMULATION) + if (YOKAI_NACL_HOST) + set(nacl_arch "${arch_name}") + + if (YOKAI_SYSTEM_Linux_COMPATIBILITY) + set(armhf_usage "arm64;armel") + if ("${arch_name}" IN_LIST armhf_usage) + # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. + # The nexe is system agnostic so there should be no difference with armel. + set(nacl_arch "armhf") + + set(box64_usage ppc64el riscv64) + if ("${arch_name}" IN_LIST box64_usage) + option(YOKAI_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) + if (YOKAI_NACL_BOX64_EMULATION) + # Use Box64 to run x86_64 NaCl loader and amd64 nexe. + # Box64 must be installed and available in PATH at runtime. + set(nacl_arch "amd64") + add_definitions(-DYOKAI_NACL_BOX64_EMULATION) + endif() endif() endif() - endif() - elseif (YOKAI_SYSTEM_macOS) - if ("${arch_name}" STREQUAL "arm64") - # You can get emulated NaCl going like this: - # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ - set(nacl_arch "amd64") + elseif (YOKAI_SYSTEM_macOS) + if ("${arch_name}" STREQUAL "arm64") + # You can get emulated NaCl going like this: + # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ + set(nacl_arch "amd64") + endif() endif() - endif() - # The YOKAI_NACL_ARCH_NAME variable contributes to the nexe file name. - set(YOKAI_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) + # The YOKAI_NACL_ARCH_NAME variable contributes to the nexe file name. + set(YOKAI_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) - # NaCl runtime is only available on architectures that have a NaCl loader. - set(nacl_runtime_arch amd64 i686 armhf) - if ("${nacl_arch}" IN_LIST nacl_runtime_arch) - add_definitions(-DYOKAI_NACL_RUNTIME_ENABLED) + # NaCl runtime is only available on architectures that have a NaCl loader. + set(nacl_runtime_arch amd64 i686 armhf) + if ("${nacl_arch}" IN_LIST nacl_runtime_arch) + add_definitions(-DYOKAI_NACL_RUNTIME_ENABLED) + endif() endif() endfunction() @@ -119,10 +121,16 @@ yokai_set_intrinsics() # > if (YOKAI_ARCH_arm64) # > if (YOKAI_NACL_ARCH_armhf) set("YOKAI_ARCH_${YOKAI_ARCH_NAME}" ON) -set("YOKAI_NACL_ARCH_${YOKAI_NACL_ARCH_NAME}" ON) + +if (YOKAI_NACL_HOST) + set("YOKAI_NACL_ARCH_${YOKAI_NACL_ARCH_NAME}" ON) +endif() if (YOKAI_SOURCE_GENERATOR) # Add printable strings to the executable. yokai_add_buildinfo("char*" "YOKAI_ARCH_STRING" "\"${YOKAI_ARCH_NAME}\"") - yokai_add_buildinfo("char*" "YOKAI_NACL_ARCH_STRING" "\"${YOKAI_NACL_ARCH_NAME}\"") + + if (YOKAI_NACL_HOST) + yokai_add_buildinfo("char*" "YOKAI_NACL_ARCH_STRING" "\"${YOKAI_NACL_ARCH_NAME}\"") + endif() endif()