2016-08-08 09:27:59 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 2016 Alibek Omarov
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
#
|
|
|
|
|
2021-06-18 04:41:38 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2018-03-03 22:12:44 +01:00
|
|
|
|
2021-10-28 19:23:12 +02:00
|
|
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.15.0")
|
|
|
|
cmake_policy(SET CMP0091 NEW)
|
2021-08-27 10:04:15 +02:00
|
|
|
endif()
|
|
|
|
|
2018-03-03 22:12:44 +01:00
|
|
|
# Install custom module path
|
2021-10-12 13:26:22 +02:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
2018-03-03 22:12:44 +01:00
|
|
|
|
|
|
|
include(VSForceXPToolchain) # Force XP toolchain for Visual Studio
|
|
|
|
|
2016-08-08 09:27:59 +02:00
|
|
|
project (HLSDK-XASH3D)
|
|
|
|
|
|
|
|
#--------------
|
|
|
|
# USER DEFINES \
|
|
|
|
################\
|
2021-10-27 03:35:11 +02:00
|
|
|
option(USE_VGUI "Enable VGUI1." OFF)
|
2016-08-08 09:27:59 +02:00
|
|
|
option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF)
|
2021-10-27 03:35:11 +02:00
|
|
|
option(USE_NOVGUI_MOTD "Prefer non-VGUI MOTD when USE_VGUI is enabled" OFF)
|
|
|
|
option(USE_NOVGUI_SCOREBOARD "Prefer non-VGUI Scoreboard when USE_VGUI is enabled" OFF)
|
2016-08-08 09:27:59 +02:00
|
|
|
option(USE_VOICEMGR "Enable VOICE MANAGER." OFF)
|
|
|
|
option(BUILD_CLIENT "Build client dll" ON)
|
|
|
|
option(BUILD_SERVER "Build server dll" ON)
|
2016-11-17 23:05:05 +01:00
|
|
|
option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF)
|
2022-06-04 19:23:41 +02:00
|
|
|
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 4 OR
|
2022-06-04 19:49:11 +02:00
|
|
|
((WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
2022-06-04 19:23:41 +02:00
|
|
|
AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x64"
|
|
|
|
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
|
2022-06-04 19:49:11 +02:00
|
|
|
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")))
|
2022-06-04 19:23:41 +02:00
|
|
|
option(64BIT "Disable auto -m32 appending to compiler flags" OFF)
|
|
|
|
else()
|
|
|
|
option(64BIT "Disable auto -m32 appending to compiler flags" ON)
|
|
|
|
endif()
|
|
|
|
|
2022-06-14 23:03:25 +02:00
|
|
|
set(GAMEDIR "biglolly" CACHE STRING "Gamedir path")
|
2017-12-18 22:27:56 +01:00
|
|
|
set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll")
|
|
|
|
set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll")
|
2022-06-14 23:03:25 +02:00
|
|
|
set(SERVER_LIBRARY_NAME "bl" CACHE STRING "Library name for PC platforms")
|
2016-08-08 09:27:59 +02:00
|
|
|
|
|
|
|
#-----------------
|
|
|
|
# MAIN BUILD CODE \
|
|
|
|
###################\
|
|
|
|
|
2018-03-22 13:23:34 +01:00
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT)
|
2016-08-08 09:27:59 +02:00
|
|
|
if(MSVC)
|
2018-03-23 21:08:38 +01:00
|
|
|
error("UNDONE: set 32 build flags")
|
2016-08-08 09:27:59 +02:00
|
|
|
else()
|
2018-03-23 21:08:38 +01:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
2021-10-27 20:22:32 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
2018-03-23 21:08:38 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
|
2016-08-08 09:27:59 +02:00
|
|
|
endif()
|
2018-03-23 21:08:38 +01:00
|
|
|
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()
|
|
|
|
|
2019-11-10 23:06:52 +01:00
|
|
|
# Xash3D FWGS Library Naming Scheme compliance
|
|
|
|
# see documentation: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/library-naming.md
|
|
|
|
include(LibraryNaming)
|
|
|
|
|
2021-10-27 20:22:32 +02:00
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2018-03-23 21:08:38 +01:00
|
|
|
message(STATUS "Building for 64 Bit")
|
|
|
|
else()
|
|
|
|
message(STATUS "Building for 32 Bit")
|
2016-08-08 09:27:59 +02:00
|
|
|
endif()
|
|
|
|
|
2018-04-03 20:39:07 +02:00
|
|
|
if (MINGW)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--add-stdcall-alias")
|
|
|
|
endif()
|
|
|
|
|
2018-01-15 00:43:57 +01:00
|
|
|
# add_compile_options for older cmake versions
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.0.2")
|
2018-03-23 21:08:38 +01:00
|
|
|
macro(add_compile_options)
|
|
|
|
set(list_var "${ARGV}")
|
|
|
|
foreach(arg IN LISTS list_var)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}")
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
2018-01-15 00:43:57 +01:00
|
|
|
endif()
|
|
|
|
|
2019-08-27 16:00:53 +02:00
|
|
|
if(NOT MSVC)
|
2019-11-10 23:06:52 +01:00
|
|
|
#add_compile_options(-Wempty-body) # GCC/Clang flag
|
2019-08-27 16:00:53 +02:00
|
|
|
add_compile_options(-Wreturn-type) # GCC/Clang flag
|
2021-06-18 04:42:43 +02:00
|
|
|
else()
|
|
|
|
add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H)
|
2019-08-27 16:00:53 +02:00
|
|
|
endif()
|
|
|
|
|
2019-11-10 23:06:52 +01:00
|
|
|
|
2016-08-08 09:27:59 +02:00
|
|
|
if(BUILD_CLIENT)
|
|
|
|
add_subdirectory(cl_dll)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(BUILD_SERVER)
|
|
|
|
add_subdirectory(dlls)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT BUILD_SERVER AND NOT BUILD_CLIENT)
|
|
|
|
error("Nothing to build")
|
2016-11-17 23:05:05 +01:00
|
|
|
endif()
|