Browse Source

Add 64/32 bit message and a dumb check when 32 bit isn't properly enabled

caseclosed
Alibek Omarov 7 years ago
parent
commit
bc379e9234
  1. 33
      CMakeLists.txt

33
CMakeLists.txt

@ -39,6 +39,7 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF)
option(BUILD_CLIENT "Build client dll" ON) option(BUILD_CLIENT "Build client dll" ON)
option(BUILD_SERVER "Build server dll" ON) option(BUILD_SERVER "Build server dll" ON)
option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) 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(GAMEDIR "valve" CACHE STRING "Gamedir path")
set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll")
set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client 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/") 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(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT)
if(MSVC) if(MSVC)
error("UNDONE: set 32 build flags") error("UNDONE: set 32 build flags")
else() else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
endif() 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() endif()
# add_compile_options for older cmake versions # add_compile_options for older cmake versions
if(${CMAKE_VERSION} VERSION_LESS "3.0.2") if(${CMAKE_VERSION} VERSION_LESS "3.0.2")
macro(add_compile_options) macro(add_compile_options)
set(list_var "${ARGV}") set(list_var "${ARGV}")
foreach(arg IN LISTS list_var) foreach(arg IN LISTS list_var)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}")
endforeach() endforeach()
endmacro() endmacro()
endif() endif()
if(BUILD_CLIENT) if(BUILD_CLIENT)

Loading…
Cancel
Save