Browse Source

cmake: LibraryNaming: greatly speedup common configurations

fix-cwd-path
Alibek Omarov 2 years ago
parent
commit
09d3e6327d
  1. 118
      cmake/LibraryNaming.cmake

118
cmake/LibraryNaming.cmake

@ -1,49 +1,81 @@
include(CheckSymbolExists) include(CheckSymbolExists)
# generated(see comments in public/build.h) macro(check_build_target symbol)
# cat build.h | grep '^#undef XASH' | awk '{ print "check_symbol_exists(" $2 " \"build.h\" " $2 ")" }' check_symbol_exists(${symbol} "build.h" ${symbol})
endmacro()
macro(check_group_build_target symbol group)
if(NOT ${group})
check_build_target(${symbol})
if(${symbol})
set(${group} TRUE)
endif()
else()
set(${symbol} FALSE)
endif()
endmacro()
# So there is a problem:
# 1. Number of these symbols only grows, as we support more and more ports
# 2. CMake was written by morons and can't check these symbols in parallel
# 3. MSVC is very slow at everything (startup, parsing, generating error)
# Solution: group these symbols and set variable if one of them was found
# this way we can reorder to reorder them by most common configurations
# but we can't generate this list anymore! ... OR IS IT ???
# Well, after reordering positions in engine's buildenums.h, we can partially autogenerate this list!
# echo "check_build_target(XASH_64BIT)"
# grep "#define PLATFORM" buildenums.h | cut -d' ' -f 2 | cut -d_ -f 2- | awk '{ print "check_group_build_target(XASH_" $1 " XASH_PLATFORM)" }'
# grep "#define ARCHITECTURE" buildenums.h | cut -d' ' -f 2 | cut -d_ -f 2- | awk '{ print "check_group_build_target(XASH_" $1 " XASH_ARCHITECTURE)"
# grep "#define ENDIAN" buildenums.h | cut -d' ' -f 2 | cut -d_ -f 2- | awk '{ print "check_group_build_target(XASH_" $1 "_ENDIAN XASH_ENDIANNESS)"}'
# echo "if(XASH_ARM)"
# grep '^#undef XASH' build.h | grep "XASH_ARM[v_]" | awk '{ print "check_build_target(" $2 ")"}'
# echo "endif()"
# echo "if(XASH_RISCV)"
# grep '^#undef XASH' build.h | grep "XASH_RISCV_" | awk '{ print "check_build_target(" $2 ")"}'
# echo "endif()"
set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/public/") set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/public/")
check_symbol_exists(XASH_64BIT "build.h" XASH_64BIT) check_build_target(XASH_64BIT)
check_symbol_exists(XASH_AMD64 "build.h" XASH_AMD64) check_group_build_target(XASH_WIN32 XASH_PLATFORM)
check_symbol_exists(XASH_ANDROID "build.h" XASH_ANDROID) check_group_build_target(XASH_LINUX XASH_PLATFORM)
check_symbol_exists(XASH_APPLE "build.h" XASH_APPLE) check_group_build_target(XASH_FREEBSD XASH_PLATFORM)
check_symbol_exists(XASH_ARM "build.h" XASH_ARM) check_group_build_target(XASH_ANDROID XASH_PLATFORM)
check_symbol_exists(XASH_ARM_HARDFP "build.h" XASH_ARM_HARDFP) check_group_build_target(XASH_APPLE XASH_PLATFORM)
check_symbol_exists(XASH_ARM_SOFTFP "build.h" XASH_ARM_SOFTFP) check_group_build_target(XASH_NETBSD XASH_PLATFORM)
check_symbol_exists(XASH_ARMv4 "build.h" XASH_ARMv4) check_group_build_target(XASH_OPENBSD XASH_PLATFORM)
check_symbol_exists(XASH_ARMv5 "build.h" XASH_ARMv5) check_group_build_target(XASH_EMSCRIPTEN XASH_PLATFORM)
check_symbol_exists(XASH_ARMv6 "build.h" XASH_ARMv6) check_group_build_target(XASH_DOS4GW XASH_PLATFORM)
check_symbol_exists(XASH_ARMv7 "build.h" XASH_ARMv7) check_group_build_target(XASH_HAIKU XASH_PLATFORM)
check_symbol_exists(XASH_ARMv8 "build.h" XASH_ARMv8) check_group_build_target(XASH_SERENITY XASH_PLATFORM)
check_symbol_exists(XASH_BIG_ENDIAN "build.h" XASH_BIG_ENDIAN) check_group_build_target(XASH_IRIX XASH_PLATFORM)
check_symbol_exists(XASH_BSD "build.h" XASH_BSD) check_group_build_target(XASH_NSWITCH XASH_PLATFORM)
check_symbol_exists(XASH_DOS4GW "build.h" XASH_DOS4GW) check_group_build_target(XASH_PSVITA XASH_PLATFORM)
check_symbol_exists(XASH_E2K "build.h" XASH_E2K) check_group_build_target(XASH_LINUX_UNKNOWN XASH_PLATFORM)
check_symbol_exists(XASH_EMSCRIPTEN "build.h" XASH_EMSCRIPTEN) check_group_build_target(XASH_X86 XASH_ARCHITECTURE)
check_symbol_exists(XASH_FREEBSD "build.h" XASH_FREEBSD) check_group_build_target(XASH_AMD64 XASH_ARCHITECTURE)
check_symbol_exists(XASH_HAIKU "build.h" XASH_HAIKU) check_group_build_target(XASH_ARM XASH_ARCHITECTURE)
check_symbol_exists(XASH_IOS "build.h" XASH_IOS) check_group_build_target(XASH_MIPS XASH_ARCHITECTURE)
check_symbol_exists(XASH_JS "build.h" XASH_JS) check_group_build_target(XASH_JS XASH_ARCHITECTURE)
check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX) check_group_build_target(XASH_E2K XASH_ARCHITECTURE)
check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN) check_group_build_target(XASH_RISCV XASH_ARCHITECTURE)
check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW) check_group_build_target(XASH_LITTLE_ENDIAN XASH_ENDIANNESS)
check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS) check_group_build_target(XASH_BIG_ENDIAN XASH_ENDIANNESS)
check_symbol_exists(XASH_PPC "build.h" XASH_PPC) if(XASH_ARM)
check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM) check_build_target(XASH_ARM_HARDFP)
check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC) check_build_target(XASH_ARM_SOFTFP)
check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD) check_build_target(XASH_ARMv4)
check_symbol_exists(XASH_OPENBSD "build.h" XASH_OPENBSD) check_build_target(XASH_ARMv5)
check_symbol_exists(XASH_POSIX "build.h" XASH_POSIX) check_build_target(XASH_ARMv6)
check_symbol_exists(XASH_RISCV "build.h" XASH_RISCV) check_build_target(XASH_ARMv7)
check_symbol_exists(XASH_RISCV_DOUBLEFP "build.h" XASH_RISCV_DOUBLEFP) check_build_target(XASH_ARMv8)
check_symbol_exists(XASH_RISCV_SINGLEFP "build.h" XASH_RISCV_SINGLEFP) endif()
check_symbol_exists(XASH_RISCV_SOFTFP "build.h" XASH_RISCV_SOFTFP) if(XASH_RISCV)
check_symbol_exists(XASH_SERENITY "build.h" XASH_SERENITY) check_build_target(XASH_RISCV_DOUBLEFP)
check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32) check_build_target(XASH_RISCV_SINGLEFP)
check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64) check_build_target(XASH_RISCV_SOFTFP)
check_symbol_exists(XASH_X86 "build.h" XASH_X86) endif()
check_symbol_exists(XASH_NSWITCH "build.h" XASH_NSWITCH)
check_symbol_exists(XASH_PSVITA "build.h" XASH_PSVITA)
unset(CMAKE_REQUIRED_INCLUDES) unset(CMAKE_REQUIRED_INCLUDES)
# engine/common/build.c # engine/common/build.c

Loading…
Cancel
Save