mirror of
https://github.com/FWGS/hlsdk-xash3d
synced 2024-11-22 01:47:45 +01:00
cmake: implement library naming for CMake
This commit is contained in:
parent
8622cc945d
commit
d59c169527
@ -65,6 +65,10 @@ if(64BIT AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
message(FATAL_ERROR "You enabled XASH_64BIT, but compiler can't create 64 bit code!")
|
||||
endif()
|
||||
|
||||
# Xash3D FWGS Library Naming Scheme compliance
|
||||
# see documentation: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/library-naming.md
|
||||
include(LibraryNaming)
|
||||
|
||||
if(64BIT)
|
||||
message(STATUS "Building for 64 Bit")
|
||||
else()
|
||||
@ -87,10 +91,11 @@ if(${CMAKE_VERSION} VERSION_LESS "3.0.2")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
add_compile_options(-Wempty-body) # GCC/Clang flag
|
||||
#add_compile_options(-Wempty-body) # GCC/Clang flag
|
||||
add_compile_options(-Wreturn-type) # GCC/Clang flag
|
||||
endif()
|
||||
|
||||
|
||||
if(BUILD_CLIENT)
|
||||
add_subdirectory(cl_dll)
|
||||
endif()
|
||||
|
103
cmake/LibraryNaming.cmake
Normal file
103
cmake/LibraryNaming.cmake
Normal file
@ -0,0 +1,103 @@
|
||||
include(CheckSymbolExists)
|
||||
|
||||
# generated(see comments in public/build.h)
|
||||
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_SOURCE_DIR}/public/")
|
||||
check_symbol_exists(XASH_64BIT "build.h" XASH_64BIT)
|
||||
check_symbol_exists(XASH_AMD64 "build.h" XASH_AMD64)
|
||||
check_symbol_exists(XASH_ANDROID "build.h" XASH_ANDROID)
|
||||
check_symbol_exists(XASH_APPLE "build.h" XASH_APPLE)
|
||||
check_symbol_exists(XASH_ARM "build.h" XASH_ARM)
|
||||
check_symbol_exists(XASH_ARM64 "build.h" XASH_ARM64)
|
||||
check_symbol_exists(XASH_ARM_HARDFP "build.h" XASH_ARM_HARDFP)
|
||||
check_symbol_exists(XASH_ARM_SOFTFP "build.h" XASH_ARM_SOFTFP)
|
||||
check_symbol_exists(XASH_ARMv4 "build.h" XASH_ARMv4)
|
||||
check_symbol_exists(XASH_ARMv5 "build.h" XASH_ARMv5)
|
||||
check_symbol_exists(XASH_ARMv6 "build.h" XASH_ARMv6)
|
||||
check_symbol_exists(XASH_ARMv7 "build.h" XASH_ARMv7)
|
||||
check_symbol_exists(XASH_BIG_ENDIAN "build.h" XASH_BIG_ENDIAN)
|
||||
check_symbol_exists(XASH_BSD "build.h" XASH_BSD)
|
||||
check_symbol_exists(XASH_E2K "build.h" XASH_E2K)
|
||||
check_symbol_exists(XASH_EMSCRIPTEN "build.h" XASH_EMSCRIPTEN)
|
||||
check_symbol_exists(XASH_FREEBSD "build.h" XASH_FREEBSD)
|
||||
check_symbol_exists(XASH_IOS "build.h" XASH_IOS)
|
||||
check_symbol_exists(XASH_JS "build.h" XASH_JS)
|
||||
check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX)
|
||||
check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN)
|
||||
check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW)
|
||||
check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS)
|
||||
check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM)
|
||||
check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC)
|
||||
check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD)
|
||||
check_symbol_exists(XASH_OPENBSD "build.h" XASH_OPENBSD)
|
||||
check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32)
|
||||
check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64)
|
||||
check_symbol_exists(XASH_X86 "build.h" XASH_X86)
|
||||
unset(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
# engine/common/build.c
|
||||
if(XASH_ANDROID)
|
||||
set(BUILDOS "android")
|
||||
elseif(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE)
|
||||
set(BUILDOS "") # no prefix for default OS
|
||||
elseif(XASH_FREEBSD)
|
||||
set(BUILDOS "freebsd")
|
||||
elseif(XASH_NETBSD)
|
||||
set(BUILDOS "netbsd")
|
||||
elseif(XASH_OPENBSD)
|
||||
set(BUILDOS "openbsd")
|
||||
elseif(XASH_EMSCRIPTEN)
|
||||
set(BUILDOS "emscripten")
|
||||
else()
|
||||
message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug")
|
||||
endif()
|
||||
|
||||
if(XASH_AMD64)
|
||||
set(BUILDARCH "amd64")
|
||||
elseif(XASH_X86)
|
||||
set(BUILDARCH "")
|
||||
elseif(XASH_ARM64)
|
||||
set(BUILDARCH "arm64")
|
||||
elseif(XASH_ARM)
|
||||
set(BUILDARCH "armv")
|
||||
if(XASH_ARMv7)
|
||||
set(BUILDARCH "${BUILDARCH}7")
|
||||
elseif(XASH_ARMv6)
|
||||
set(BUILDARCH "${BUILDARCH}6")
|
||||
elseif(XASH_ARMv5)
|
||||
set(BUILDARCH "${BUILDARCH}5")
|
||||
elseif(XASH_ARMv4)
|
||||
set(BUILDARCH "${BUILDARCH}4")
|
||||
endif()
|
||||
|
||||
if(XASH_ARM_HARDFP)
|
||||
set(BUILDARCH "${BUILDARCH}hf")
|
||||
else()
|
||||
set(BUILDARCH "${BUILDARCH}l")
|
||||
endif()
|
||||
elseif(XASH_MIPS AND XASH_BIG_ENDIAN)
|
||||
set(BUILDARCH "mips")
|
||||
elseif(XASH_MIPS AND XASH_LITTLE_ENDIAN)
|
||||
set(BUILDARCH "mipsel")
|
||||
elseif(XASH_JS)
|
||||
set(BUILDARCH "javascript")
|
||||
elseif(XASH_E2K)
|
||||
set(BUILDARCH "e2k")
|
||||
else()
|
||||
message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug")
|
||||
endif()
|
||||
|
||||
if(BUILDOS AND BUILDARCH)
|
||||
set(POSTFIX "_${BUILDOS}_${BUILDARCH}")
|
||||
elseif(BUILDARCH)
|
||||
set(POSTFIX "_${BUILDARCH}")
|
||||
else()
|
||||
set(POSTFIX "")
|
||||
endif()
|
||||
|
||||
message(STATUS "Library postfix: " ${POSTFIX})
|
||||
|
||||
set(CMAKE_RELEASE_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_DEBUG_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_MINSIZEREL_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_POSTFIX ${POSTFIX})
|
Loading…
Reference in New Issue
Block a user