Skip to content

Commit 1d6b6b4

Browse files
committed
cmake: prefix ARCH and NACL_ARCH with DAEMON
1 parent e0900db commit 1d6b6b4

File tree

5 files changed

+51
-47
lines changed

5 files changed

+51
-47
lines changed

CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ if (USE_EXTERNAL_DEPS AND NOT NACL)
204204

205205
set(DEPS_EXT ".tar.xz")
206206

207-
set(DEPS_ARCH "${ARCH}")
207+
set(DEPS_ARCH "${DAEMON_ARCH}")
208208

209209
if (MSVC)
210210
set(DEPS_COMPILER msvc)
@@ -221,7 +221,7 @@ if (USE_EXTERNAL_DEPS AND NOT NACL)
221221
set(DEPS_SYSTEM macos)
222222
set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64)
223223

224-
if (ARCH STREQUAL arm64)
224+
if (DAEMON_ARCH_arm64)
225225
set(DEPS_ARCH amd64)
226226

227227
set_deps_dir()
@@ -681,10 +681,10 @@ if (BUILD_CLIENT OR WIN32)
681681
set(sdlvar_amd64 SDL_CPU_X64)
682682
set(sdlvar_armhf SDL_CPU_ARM32)
683683
set(sdlvar_arm64 SDL_CPU_ARM64)
684-
if (sdlvar_${ARCH})
685-
set(${sdlvar_${ARCH}} 1)
684+
if (sdlvar_${DAEMON_ARCH})
685+
set(${sdlvar_${DAEMON_ARCH}} 1)
686686
else()
687-
message("Developer TODO: translate architecture ${ARCH} for SDL")
687+
message("Developer TODO: translate architecture ${DAEMON_ARCH} for SDL")
688688
endif()
689689

690690
find_package(SDL3 REQUIRED CONFIG)
@@ -974,13 +974,13 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER
974974

975975
add_custom_command(TARGET runtime_deps PRE_BUILD
976976
COMMAND ${CMAKE_COMMAND} -E copy_if_different
977-
${DEPS_DIR}/irt_core-${NACL_ARCH}.nexe
978-
${FULL_OUTPUT_DIR}/irt_core-${NACL_ARCH}.nexe
977+
${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH}.nexe
978+
${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH}.nexe
979979
)
980980

981981
# Linux uses a bootstrap program to reserve address space
982982
if (LINUX OR FREEBSD)
983-
if (ARCH STREQUAL "arm64")
983+
if (DAEMON_ARCH_arm64)
984984
add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp)
985985
add_dependencies(runtime_deps nacl_helper_bootstrap-armhf)
986986

@@ -1004,7 +1004,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER
10041004
endif()
10051005

10061006
# Win32 requires nacl_loader_amd64.exe in order to run on Win64
1007-
if (WIN32 AND ARCH STREQUAL i686)
1007+
if (WIN32 AND DAEMON_ARCH_i686)
10081008
add_custom_command(TARGET runtime_deps PRE_BUILD
10091009
COMMAND ${CMAKE_COMMAND} -E copy_if_different
10101010
${DEPS_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX}

cmake/DaemonFlags.cmake

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ else()
362362
endif()
363363
endif()
364364

365-
if (NACL AND USE_NACL_SAIGO AND SAIGO_ARCH STREQUAL "arm")
365+
if (NACL AND USE_NACL_SAIGO AND SAIGO_DAEMON_ARCH_arm)
366366
# This should be set for every build type because build type flags
367367
# are set after the other custom flags and then have the last word.
368368
# DEBUG should already use -O0 anyway.
@@ -503,12 +503,12 @@ else()
503503

504504
if ("${FLAG_LINKER_PIE}" AND MINGW)
505505
# https://github.com/msys2/MINGW-packages/issues/4100
506-
if (ARCH STREQUAL "i686")
506+
if (DAEMON_ARCH_i686)
507507
set_linker_flag("-Wl,-e,_mainCRTStartup")
508-
elseif(ARCH STREQUAL "amd64")
508+
elseif(DAEMON_ARCH_amd64)
509509
set_linker_flag("-Wl,-e,mainCRTStartup")
510510
else()
511-
message(FATAL_ERROR "Unsupported architecture ${ARCH}")
511+
message(FATAL_ERROR "Unsupported architecture ${DAEMON_ARCH}")
512512
endif()
513513
endif()
514514
endif()
@@ -578,7 +578,7 @@ option(USE_CPU_RECOMMENDED_FEATURES "Use some common hardware features like SSE2
578578

579579
# Target options.
580580
if (MSVC)
581-
if (ARCH STREQUAL "i686")
581+
if (DAEMON_ARCH_i686)
582582
if (USE_CPU_RECOMMENDED_FEATURES)
583583
set_c_cxx_flag("/arch:SSE2") # This is the default
584584
else()
@@ -598,7 +598,7 @@ elseif (NOT NACL)
598598
# Running a server with a native executable game is also a valid usage
599599
# not requiring the NX bit.
600600

601-
if (ARCH STREQUAL "amd64")
601+
if (DAEMON_ARCH_amd64)
602602
# K8 or EM64T minimum: AMD Athlon 64 ClawHammer, Intel Xeon Nocona, Intel Pentium 4 model F (Prescott revision EO), VIA Nano.
603603
if (DAEMON_CXX_COMPILER_ICC)
604604
set(GCC_GENERIC_ARCH "pentium4")
@@ -608,15 +608,15 @@ elseif (NOT NACL)
608608
set(GCC_GENERIC_ARCH "x86-64")
609609
endif()
610610
set(GCC_GENERIC_TUNE "generic")
611-
elseif (ARCH STREQUAL "i686")
611+
elseif (DAEMON_ARCH_i686)
612612
# P6 or K6 minimum: Intel Pentium Pro, AMD K6, Via Cyrix III, Via C3.
613613
set(GCC_GENERIC_ARCH "i686")
614614
set(GCC_GENERIC_TUNE "generic")
615-
elseif (ARCH STREQUAL "arm64")
615+
elseif (DAEMON_ARCH_arm64)
616616
# Armv8-A minimum: Cortex-A50.
617617
set(GCC_GENERIC_ARCH "armv8-a")
618618
set(GCC_GENERIC_TUNE "generic")
619-
elseif (ARCH STREQUAL "armhf")
619+
elseif (DAEMON_ARCH_armhf)
620620
# Armv7-A minimum with VFPv3 and optional NEONv1: Cortex-A5.
621621
# Hard float ABI (mainstream 32-bit ARM Linux distributions).
622622
# An FPU should be explicitly set on recent compilers or this
@@ -625,15 +625,15 @@ elseif (NOT NACL)
625625
# lacks an FPU
626626
set(GCC_GENERIC_ARCH "armv7-a+fp")
627627
set(GCC_GENERIC_TUNE "generic-armv7-a")
628-
elseif (ARCH STREQUAL "armel")
628+
elseif (DAEMON_ARCH_armel)
629629
# Armv6 minimum with optional VFP: ARM11.
630630
# Soft float ABI (previous mainstream 32-bit ARM Linux
631631
# distributions, mainstream 32-bit ARM Android distributions).
632632
set(GCC_GENERIC_ARCH "armv6")
633633
# There is no generic tuning option for armv6.
634634
unset(GCC_GENERIC_TUNE)
635635
else()
636-
message(WARNING "Unknown architecture ${ARCH}")
636+
message(WARNING "Unknown architecture ${DAEMON_ARCH}")
637637
endif()
638638

639639
if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig")
@@ -652,18 +652,18 @@ elseif (NOT NACL)
652652
endif()
653653

654654
if (USE_CPU_RECOMMENDED_FEATURES)
655-
if (ARCH STREQUAL "amd64")
655+
if (DAEMON_ARCH_amd64)
656656
# CMPXCHG16B minimum (x86-64-v2): AMD64 revision F.
657657
try_c_cxx_flag_werror(MCX16 "-mcx16")
658-
elseif (ARCH STREQUAL "i686")
658+
elseif (DAEMON_ARCH_i686)
659659
# SSE2 minimum: Intel Pentium 4 (Prescott),
660660
# Intel Pentium M (Banias), AMD K8, Via C7.
661661
try_c_cxx_flag_werror(MSSE2 "-msse2")
662662
try_c_cxx_flag_werror(MFPMATH_SSE "-mfpmath=sse")
663-
elseif (ARCH STREQUAL "armhf")
663+
elseif (DAEMON_ARCH_armhf)
664664
# NEONv1 minimum.
665665
try_c_cxx_flag_werror(MFPU_NEON "-mfpu=neon")
666-
elseif (ARCH STREQUAL "armel")
666+
elseif (DAEMON_ARCH_armel)
667667
# VFP minimum, hard float with soft float ABI.
668668
try_c_cxx_flag_werror(MFPU_VFP "-mfpu=vfp")
669669
try_c_cxx_flag_werror(MFLOAT_ABI_SOFTFP "-mfloat-abi=softfp")

cmake/DaemonGame.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ include(CMakeParseArguments)
7070
# The NaCl SDK only runs on amd64 or i686.
7171
if (NOT FORK EQUAL 2)
7272
if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME
73-
AND (ARCH STREQUAL "amd64" OR ARCH STREQUAL "i686"))
73+
AND (DAEMON_ARCH_amd64 OR DAEMON_ARCH_i686))
7474
# can be loaded by daemon with vm.[sc]game.type 0 or 1
7575
option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF)
7676

@@ -81,7 +81,7 @@ if (NOT FORK EQUAL 2)
8181
if (BUILD_GAME_NACL_TARGETS STREQUAL "all")
8282
set(NACL_TARGETS "${NACL_ALL_TARGETS}")
8383
elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native")
84-
set(NACL_TARGETS "${ARCH}")
84+
set(NACL_TARGETS "${DAEMON_ARCH}")
8585
elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none")
8686
set(NACL_TARGETS "")
8787
else()

cmake/DaemonNacl.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF)
3131
if( NACL )
3232
# Build nexe binary.
3333
if(USE_NACL_SAIGO)
34-
# NACL_ARCH is "pnacl" here, NACL_TARGET carries the architecture.
34+
# DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET carries the architecture.
3535
if (NACL_TARGET STREQUAL "amd64")
3636
add_definitions(-DNACL_BUILD_ARCH=x86)
3737
add_definitions(-DNACL_BUILD_SUBARCH=64)
@@ -47,7 +47,7 @@ if( NACL )
4747
# Those defines looks to be meaningless to produce arch-independent pexe
4848
# with PNaCl but they must be set to anything supported by native builds.
4949
# This requirement looks to be a PNaCl bug.
50-
# NACL_ARCH is "pnacl" here, NACL_TARGET is not set.
50+
# DAEMON_NACL_ARCH is "pnacl" here, NACL_TARGET is not set.
5151
add_definitions( -DNACL_BUILD_ARCH=x86 )
5252
add_definitions( -DNACL_BUILD_SUBARCH=64 )
5353
endif()
@@ -63,16 +63,16 @@ else()
6363
add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 )
6464
endif()
6565

66-
if( NACL_ARCH STREQUAL "amd64" )
66+
if (DAEMON_NACL_ARCH_amd64)
6767
add_definitions( -DNACL_BUILD_ARCH=x86 )
6868
add_definitions( -DNACL_BUILD_SUBARCH=64 )
69-
elseif( NACL_ARCH STREQUAL "i686" )
69+
elseif (DAEMON_NACL_ARCH_i686)
7070
add_definitions( -DNACL_BUILD_ARCH=x86 )
7171
add_definitions( -DNACL_BUILD_SUBARCH=32 )
72-
elseif( NACL_ARCH STREQUAL "armhf" )
72+
elseif (DAEMON_NACL_ARCH_armhf)
7373
add_definitions( -DNACL_BUILD_ARCH=arm )
7474
else()
75-
message(WARNING "Unknown architecture ${NACL_ARCH}")
75+
message(WARNING "Unknown architecture ${DAEMON_NACL_ARCH}")
7676
endif()
7777
endif()
7878

cmake/DaemonPlatform/Architecture.cmake

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,42 +52,46 @@ if (NOT BUILD_RESULT)
5252
)
5353
endif()
5454

55-
string(REGEX MATCH "DAEMON_ARCH_([a-zA-Z0-9_]+)" ARCH_DEFINE "${BUILD_LOG}")
56-
string(REPLACE "DAEMON_ARCH_" "" ARCH "${ARCH_DEFINE}")
55+
string(REGEX MATCH "DAEMON_ARCH_([a-zA-Z0-9_]+)" DAEMON_ARCH_DEFINE "${BUILD_LOG}")
56+
string(REPLACE "DAEMON_ARCH_" "" DAEMON_ARCH "${DAEMON_ARCH_DEFINE}")
5757

58-
if (NOT ARCH)
58+
set("DAEMON_ARCH_${DAEMON_ARCH}" ON)
59+
60+
if (NOT DAEMON_ARCH)
5961
message(FATAL_ERROR
6062
"Missing DAEMON_ARCH, there is a mistake in Architecture.cpp\n"
6163
"${BUILD_LOG}"
6264
)
6365
endif()
6466

65-
message(STATUS "Detected target architecture: ${ARCH}")
67+
message(STATUS "Detected target architecture: ${DAEMON_ARCH}")
6668

67-
add_definitions(-D${ARCH_DEFINE})
69+
add_definitions(-D${DAEMON_ARCH_DEFINE})
6870

6971
# This string can be modified without breaking compatibility.
70-
daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${ARCH}\"")
72+
daemon_add_buildinfo("char*" "DAEMON_ARCH_STRING" "\"${DAEMON_ARCH}\"")
7173

7274
# Modifying NACL_ARCH breaks engine compatibility with nexe game binaries
7375
# since NACL_ARCH contributes to the nexe file name.
74-
set(NACL_ARCH "${ARCH}")
76+
set(DAEMON_NACL_ARCH "${DAEMON_ARCH}")
7577
if (LINUX OR FREEBSD)
7678
set(ARMHF_USAGE arm64 armel)
77-
if (ARCH IN_LIST ARMHF_USAGE)
79+
if (DAEMON_ARCH IN_LIST ARMHF_USAGE)
7880
# Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch.
7981
# The nexe is system agnostic so there should be no difference with armel.
80-
set(NACL_ARCH "armhf")
82+
set(DAEMON_NACL_ARCH "armhf")
8183
endif()
8284
elseif(APPLE)
83-
if ("${ARCH}" STREQUAL arm64)
85+
if ("${DAEMON_ARCH}" STREQUAL arm64)
8486
# You can get emulated NaCl going like this:
8587
# cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/
86-
set(NACL_ARCH "amd64")
88+
set(DAEMON_NACL_ARCH "amd64")
8789
endif()
8890
endif()
8991

90-
daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${NACL_ARCH}\"")
92+
set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH}" ON)
93+
94+
daemon_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH}\"")
9195

9296
option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON)
9397
mark_as_advanced(USE_ARCH_INTRINSICS)
@@ -105,11 +109,11 @@ if (USE_ARCH_INTRINSICS)
105109
add_definitions(-DDAEMON_USE_ARCH_INTRINSICS=1)
106110
endif()
107111

108-
set_arch_intrinsics(${ARCH})
112+
set_arch_intrinsics(${DAEMON_ARCH})
109113

110114
set(amd64_PARENT "i686")
111115
set(arm64_PARENT "armhf")
112116

113-
if (${ARCH}_PARENT)
114-
set_arch_intrinsics(${${ARCH}_PARENT})
117+
if (${DAEMON_ARCH}_PARENT)
118+
set_arch_intrinsics(${${DAEMON_ARCH}_PARENT})
115119
endif()

0 commit comments

Comments
 (0)