From bc379e92343ae52d44c152baaf176e32f8ed9765 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 23 Mar 2018 23:08:38 +0300 Subject: [PATCH] Add 64/32 bit message and a dumb check when 32 bit isn't properly enabled --- CMakeLists.txt | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 705025bf..bd7fe664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) +option(64BIT "Disable auto -m32 appending to compiler flags" OFF) set(GAMEDIR "valve" CACHE STRING "Gamedir path") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") @@ -50,25 +51,35 @@ set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows" set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") -# Build 32-bit Xash on 64-bit, because Xash3D not support this if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) - error("UNDONE: set 32 build flags") + error("UNDONE: set 32 build flags") else() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() + set(CMAKE_SIZEOF_VOID_P 4) +endif() + +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() + +if(64BIT) + message(STATUS "Building for 64 Bit") +else() + message(STATUS "Building for 32 Bit") endif() # add_compile_options for older cmake versions if(${CMAKE_VERSION} VERSION_LESS "3.0.2") -macro(add_compile_options) - set(list_var "${ARGV}") - foreach(arg IN LISTS list_var) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") - endforeach() -endmacro() + macro(add_compile_options) + set(list_var "${ARGV}") + foreach(arg IN LISTS list_var) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") + endforeach() + endmacro() endif() if(BUILD_CLIENT)