From 21e5afc8d8c5374ad4997c959d19614c34748adb Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Wed, 15 Jun 2022 00:45:42 +0500 Subject: [PATCH 1/7] cmake: change gamedir and server library name. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 123cd838..b64aa7c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,10 +55,10 @@ else() option(64BIT "Disable auto -m32 appending to compiler flags" ON) endif() -set(GAMEDIR "valve" CACHE STRING "Gamedir path") +set(GAMEDIR "Spirit" 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") -set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for PC platforms") +set(SERVER_LIBRARY_NAME "spirit" CACHE STRING "Library name for PC platforms") #----------------- # MAIN BUILD CODE \ From 1397f3ab4f43da5dc6f472e86d2bbaf44ddb25be Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 16 Jun 2022 10:50:14 +0500 Subject: [PATCH 2/7] cmake: use "lib" prefixe only for Android. --- cl_dll/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 5402372a..0869467d 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -204,7 +204,7 @@ endif() set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) -if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(CLDLL_NAME "client") set_target_properties(${CLDLL_LIBRARY} PROPERTIES OUTPUT_NAME ${CLDLL_NAME} From d8b05d12d52ba390b1b8dceca784f35a13f42934 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 16 Jun 2022 11:54:55 +0500 Subject: [PATCH 3/7] cmake: better tgmath.h check. --- CMakeLists.txt | 11 +++++++++++ cl_dll/CMakeLists.txt | 6 ------ dlls/CMakeLists.txt | 6 ------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 123cd838..0a8c657c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ endif() # Install custom module path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") +include(CheckIncludeFile) +include(CheckCSourceCompiles) include(VSForceXPToolchain) # Force XP toolchain for Visual Studio project (HLSDK-XASH3D) @@ -111,6 +113,15 @@ else() add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H) endif() +check_include_file("tgmath.h" HAVE_TGMATH_H) +if(HAVE_TGMATH_H) + check_c_source_compiles("#include + const float val = 2, val2 = 3; + int main(){ return (int)(-asin(val) + cos(val2));" HAVE_VALID_TGMATH_H ) + if(${HAVE_VALID_TGMATH_H}) + add_definitions(-DHAVE_TGMATH_H) + endif() +endif() if(BUILD_CLIENT) add_subdirectory(cl_dll) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 0869467d..ae4a47cc 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,12 +25,6 @@ project (CLDLL) set (CLDLL_LIBRARY client) -include(CheckIncludeFile) -check_include_file("tgmath.h" HAVE_TGMATH_H) -if(HAVE_TGMATH_H) - add_definitions(-DHAVE_TGMATH_H) -endif() - add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) if(NOT MSVC) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 77cd47e6..ba828008 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,12 +25,6 @@ project (SVDLL) set (SVDLL_LIBRARY server) -include(CheckIncludeFile) -check_include_file("tgmath.h" HAVE_TGMATH_H) -if(HAVE_TGMATH_H) - add_definitions(-DHAVE_TGMATH_H) -endif() - add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) From d8dea3cc2be15fff98d4095d74cfe5d4008ab9e3 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:04:30 +0500 Subject: [PATCH 4/7] cmake: add missing bracket. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a8c657c..11667593 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,7 @@ check_include_file("tgmath.h" HAVE_TGMATH_H) if(HAVE_TGMATH_H) check_c_source_compiles("#include const float val = 2, val2 = 3; - int main(){ return (int)(-asin(val) + cos(val2));" HAVE_VALID_TGMATH_H ) + int main(){ return (int)(-asin(val) + cos(val2)); }" HAVE_VALID_TGMATH_H ) if(${HAVE_VALID_TGMATH_H}) add_definitions(-DHAVE_TGMATH_H) endif() From 7431c7a717c778e2e50061ebd9d4f3e7ba8d5b6a Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:19:33 +0500 Subject: [PATCH 5/7] cmake: try to link libm. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11667593..d88bf8e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,7 @@ endif() check_include_file("tgmath.h" HAVE_TGMATH_H) if(HAVE_TGMATH_H) + set(CMAKE_REQUIRED_LIBRARIES "m") check_c_source_compiles("#include const float val = 2, val2 = 3; int main(){ return (int)(-asin(val) + cos(val2)); }" HAVE_VALID_TGMATH_H ) From 2363a8ff218c320fe7838dea741e0974b8cb5d14 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:30:17 +0500 Subject: [PATCH 6/7] cmake: do not link libm for MSVC. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d88bf8e5..3472f33c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,9 @@ endif() check_include_file("tgmath.h" HAVE_TGMATH_H) if(HAVE_TGMATH_H) - set(CMAKE_REQUIRED_LIBRARIES "m") + if(NOT MSVC) + set(CMAKE_REQUIRED_LIBRARIES "m") + endif() check_c_source_compiles("#include const float val = 2, val2 = 3; int main(){ return (int)(-asin(val) + cos(val2)); }" HAVE_VALID_TGMATH_H ) From 987ea07ce1f73098bed2f4ed271ef565d117b011 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Fri, 17 Jun 2022 03:59:39 +0500 Subject: [PATCH 7/7] cmake: add more options and show more diagnostic messages. --- CMakeLists.txt | 58 ++++++++++++++++++++++++++++++++++++++++++- cl_dll/CMakeLists.txt | 2 +- dlls/CMakeLists.txt | 2 -- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3472f33c..fe344cdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,15 +57,29 @@ else() option(64BIT "Disable auto -m32 appending to compiler flags" ON) endif() +option(BARNACLE_FIX_VISIBILITY "Enable barnacle tongue length fix" OFF) +option(CLIENT_WEAPONS "Enable client local weapons prediction" ON) +option(CROWBAR_IDLE_ANIM "Enable crowbar idle animation" OFF) +option(CROWBAR_DELAY_FIX "Enable crowbar attack delay fix" OFF) +option(CROWBAR_FIX_RAPID_CROWBAR "Enable rapid crowbar fix" OFF) +option(GAUSS_OVERCHARGE_FIX "Enable gauss overcharge fix" OFF) +option(OEM_BUILD "Enable OEM Build" OFF) +option(HLDEMO_BUILD "Enable Demo Build" 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") set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for PC platforms") +message(STATUS "Half-Life") #----------------- # MAIN BUILD CODE \ ###################\ +if(HLDEMO_BUILD AND OEM_BUILD) + message(FATAL_ERROR "Don't mix Demo and OEM builds!") +endif() + if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) error("UNDONE: set 32 build flags") @@ -91,6 +105,46 @@ else() message(STATUS "Building for 32 Bit") endif() +if(CLIENT_WEAPONS) + message(STATUS "Client weapons enabled.") + add_definitions(-DCLIENT_WEAPONS) +endif() + +if(BARNACLE_FIX_VISIBILITY) + message(STATUS "Barnacle tongue fix enabled") + add_definitions(-DBARNACLE_FIX_VISIBILITY) +endif() + +if(CROWBAR_IDLE_ANIM) + message(STATUS "Crowbar idle animation enabled") + add_definitions(-DCROWBAR_IDLE_ANIM) +endif() + +if(CROWBAR_DELAY_FIX) + message(STATUS "Crowbar attack delay fix enabled") + add_definitions(-DCROWBAR_DELAY_FIX) +endif() + +if(CROWBAR_FIX_RAPID_CROWBAR) + message(STATUS "Rapid crowbar fix enabled") + add_definitions(-DCROWBAR_FIX_RAPID_CROWBAR) +endif() + +if(GAUSS_OVERCHARGE_FIX) + message(STATUS "Gauss overcharge fix enabled") + add_definitions(-DGAUSS_OVERCHARGE_FIX) +endif() + +if(OEM_BUILD) + message(STATUS "OEM build enabled") + add_definitions(-DOEM_BUILD) +endif() + +if(HLDEMO_BUILD) + message(STATUS "Demo build enabled") + add_definitions(-DHLDEMO_BUILD) +endif() + 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") @@ -127,13 +181,15 @@ if(HAVE_TGMATH_H) endif() if(BUILD_CLIENT) + message(STATUS "Building client enabled") add_subdirectory(cl_dll) endif() if(BUILD_SERVER) + message(STATUS "Building server enabled") add_subdirectory(dlls) endif() if(NOT BUILD_SERVER AND NOT BUILD_CLIENT) - error("Nothing to build") + message(FATAL_ERROR "Nothing to build") endif() diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index ae4a47cc..6486cc9d 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,7 +25,7 @@ project (CLDLL) set (CLDLL_LIBRARY client) -add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) +add_definitions(-DCLIENT_DLL) if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index ba828008..7e5378e1 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,8 +25,6 @@ project (SVDLL) set (SVDLL_LIBRARY server) -add_definitions(-DCLIENT_WEAPONS) - if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag