diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..eb25724 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,167 @@ +cmake_minimum_required(VERSION 3.21...3.30) + +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project( "ReVoice" + DESCRIPTION "Fix for voice chat between Steam and non-Steam clients for ReHLDS" + HOMEPAGE_URL "https://github.com/rehlds/ReVoice" + LANGUAGES "C" "CXX" +) + +#------------------------------------------------------------------------------- +# Options +#------------------------------------------------------------------------------- + +option(USE_LINKER_GOLD "Use the Gold linker when compiling with GCC" ON ) +option(USE_LINKER_LLD "Use the LLD linker when compiling with Clang" ON ) +option(LINK_STATIC_MSVC_RT "Link MSVC runtime library statically" OFF) +option(LINK_STATIC_GCC "Link libgcc library statically" OFF) +option(LINK_STATIC_STDCPP "Link C++ standard library statically" OFF) +option(LINK_LIBCPP "Link libc++ as the C++ standard library instead of libstdc++" OFF) +option(ENABLE_RTTI "Enable support for run-time type information" OFF) +option(ENABLE_EXCEPTIONS "Enable support for exception handling" OFF) +option(ENABLE_ASAN "Enable AddressSanitizer" OFF) +option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer" OFF) +option(ENABLE_LINK_TRACE "Enable linker trace flag (detailed output of the linking process)" OFF) +option(OPTIMIZE_FOR_CURRENT_CPU "Generate code optimized for the current (native) processor" OFF) + +#------------------------------------------------------------------------------- +# Output Directories +#------------------------------------------------------------------------------- + +if(NOT BIN_OUTPUT_DIR) + set(BIN_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/bin/${CMAKE_CXX_COMPILER_ID}-$") +endif() + +#------------------------------------------------------------------------------- +# System Environment +#------------------------------------------------------------------------------- + +include("ProcessorCount") +ProcessorCount(NUM_CORES) + +if(NUM_CORES EQUAL 0) + set(NUM_CORES 4) +endif() + +if(PROCESSOR_CORES GREATER 8) + set(PROCESSOR_CORES 8) +endif() + +string(TIMESTAMP CURRENT_YEAR "%Y") + +#------------------------------------------------------------------------------- +# CMake Policies +#------------------------------------------------------------------------------- + +# Honor visibility properties for all target types +set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) + +# INTERPROCEDURAL_OPTIMIZATION is enforced when enabled +set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) + +# target_sources() command converts relative paths to absolute +set(CMAKE_POLICY_DEFAULT_CMP0076 NEW) + +# option() honors normal variables +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) + +# Control generation of Position Independent Executable (PIE) +set(CMAKE_POLICY_DEFAULT_CMP0083 NEW) + +# MSVC runtime library flags are selected by an abstraction (CMAKE_MSVC_RUNTIME_LIBRARY) +set(CMAKE_POLICY_DEFAULT_CMP0091 NEW) + +# MSVC warning flags are not in CMAKE__FLAGS by default +set(CMAKE_POLICY_DEFAULT_CMP0092 NEW) + +# Link properties are transitive over private dependencies of static libraries +set(CMAKE_POLICY_DEFAULT_CMP0099 NEW) + +# Makefile generators do not repeat custom commands from target dependencies +set(CMAKE_POLICY_DEFAULT_CMP0113 NEW) + +# ExternalProject step targets fully adopt their steps +set(CMAKE_POLICY_DEFAULT_CMP0114 NEW) + +# Ninja generators transform DEPFILEs from add_custom_command() +set(CMAKE_POLICY_DEFAULT_CMP0116 NEW) + +# MSVC RTTI flag /GR is not added to CMAKE_CXX_FLAGS by default +set(CMAKE_POLICY_DEFAULT_CMP0117 NEW) + +# LANGUAGE source file property explicitly compiles as language +set(CMAKE_POLICY_DEFAULT_CMP0119 NEW) + +#------------------------------------------------------------------------------- +# Build Configuration +#------------------------------------------------------------------------------- + +# Building shared libraries instead of static by default +set(BUILD_SHARED_LIBS OFF) + +# First search using Config mode before falling back to Module mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + +# Set the possible build types +set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" "RelWithDebInfo") + +# Set the C language standard +set(CMAKE_C_STANDARD 11) + +# Enforce the use of the C language standard +set(CMAKE_C_STANDARD_REQUIRED ON) + +# Set the visibility of symbols in C object files +set(CMAKE_C_VISIBILITY_PRESET hidden) + +# Set the C++ language standard +set(CMAKE_CXX_STANDARD 14) + +# Enforce the use of the C++ language standard +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Set the visibility of symbols in C++ object files +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +# Interprocedural optimization for specified build types +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON) + +# Dependency optimization for faster builds +set(CMAKE_OPTIMIZE_DEPENDENCIES ON) + +# Position independent code generation +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Hiding of inline functions in shared libraries +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + +# Export the compile commands to a JSON file +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Enable error reporting for deprecated features +set(CMAKE_ERROR_DEPRECATED ON) + +#------------------------------------------------------------------------------- +# CMake Modules and Dependencies +#------------------------------------------------------------------------------- + +include("cmake/AppVersion.cmake") +include("cmake/CompileOptions.cmake") + +#------------------------------------------------------------------------------- +# Subdirectories +#------------------------------------------------------------------------------- + +add_subdirectory("dep/speex") +add_subdirectory("dep/silk") +add_subdirectory("dep/opus") +add_subdirectory("dep/rehlsdk") +add_subdirectory("dep/metamod") +add_subdirectory("revoice") diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..6408d61 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,404 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21 + }, + "configurePresets": [ + { + "name": "base", + "description": "Base configuration with common settings and options", + "binaryDir": "${sourceDir}/build/${presetName}", + "warnings": { + "deprecated": true, + "dev": true, + "systemVars": true, + "uninitialized": false, + "unusedCli": false + }, + "hidden": true + }, + { + "name": "ninja", + "description": "Use Ninja generator", + "generator": "Ninja", + "architecture": { + "value": "x86", + "strategy": "external" + }, + "hidden": true + }, + { + "name": "ninja-multi-config", + "description": "Use Ninja Multi-Config generator", + "generator": "Ninja Multi-Config", + "architecture": { + "value": "x86", + "strategy": "external" + }, + "hidden": true + }, + { + "name": "vs2022", + "description": "Use Visual Studio 2022 generator", + "generator": "Visual Studio 17 2022", + "architecture": { + "value": "Win32", + "strategy": "set" + }, + "hidden": true + }, + { + "name": "gcc", + "description": "Use GCC compiler", + "cacheVariables": { + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "inheritEnvironments": "linux_x86", + "intelliSenseMode": "linux-gcc-x86" + } + }, + "hidden": true + }, + { + "name": "clang", + "description": "Use Clang compiler", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + }, + "hidden": true + }, + { + "name": "msvc", + "description": "Use MSVC compiler", + "cacheVariables": { + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "inheritEnvironments": "msvc_x86_x64", + "intelliSenseMode": "windows-msvc-x86" + } + }, + "hidden": true + }, + { + "name": "clang-cl", + "description": "Use Clang-CL compiler", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl", + "CMAKE_C_COMPILER_TARGET": "i386-pc-windows-msvc", + "CMAKE_CXX_COMPILER_TARGET": "i386-pc-windows-msvc" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "inheritEnvironments": [ + "msvc_x86_x64", + "clang_cl_x86" + ], + "intelliSenseMode": "windows-clang-x86" + } + }, + "hidden": true + }, + { + "name": "linux", + "description": "Configuration for Linux", + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + }, + "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { + "copySources": true, + "copyBuildOutput": true, + "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}", + "copySourcesOptions": { + "exclusionList": [ + ".git", + ".vs", + "artifacts", + "bin", + "build", + "out", + "publish" + ] + } + } + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "hidden": true + }, + { + "name": "windows", + "description": "Configuration for Windows", + "cacheVariables": { + "CMAKE_C_SIMULATE_ID": "MSVC", + "CMAKE_CXX_SIMULATE_ID": "MSVC" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Windows" + ] + } + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "hidden": true + }, + { + "name": "ninja-gcc-linux", + "inherits": [ + "base", + "ninja-multi-config", + "gcc", + "linux" + ] + }, + { + "name": "ninja-clang-linux", + "inherits": [ + "base", + "ninja-multi-config", + "clang", + "linux" + ] + }, + { + "name": "ninja-msvc-windows", + "inherits": [ + "base", + "ninja-multi-config", + "msvc", + "windows" + ] + }, + { + "name": "vs2022-msvc-windows", + "inherits": [ + "base", + "vs2022", + "msvc", + "windows" + ] + }, + { + "name": "ninja-clang-windows", + "inherits": [ + "base", + "ninja-multi-config", + "clang-cl", + "windows" + ], + "hidden": true + } + ], + "buildPresets": [ + { + "name": "base", + "description": "Base configuration with common settings and options", + "verbose": false, + "hidden": true + }, + { + "name": "linux", + "description": "Configuration for Linux", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "hidden": true + }, + { + "name": "windows", + "description": "Configuration for Windows", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "hidden": true + }, + { + "name": "ninja-gcc-linux-debug", + "displayName": "Ninja GCC Debug", + "description": "Build using Ninja Multi-Config generator and GCC compiler with Debug configuration", + "configurePreset": "ninja-gcc-linux", + "configuration": "Debug", + "inherits": [ + "base", + "linux" + ] + }, + { + "name": "ninja-gcc-linux-release", + "displayName": "Ninja GCC Release", + "description": "Build using Ninja Multi-Config generator and GCC compiler with Release configuration", + "configurePreset": "ninja-gcc-linux", + "configuration": "Release", + "inherits": [ + "base", + "linux" + ] + }, + { + "name": "ninja-gcc-linux-reldebinfo", + "displayName": "Ninja GCC RelWithDebInfo", + "description": "Build using Ninja Multi-Config generator and GCC compiler with RelWithDebInfo configuration", + "configurePreset": "ninja-gcc-linux", + "configuration": "RelWithDebInfo", + "inherits": [ + "base", + "linux" + ] + }, + { + "name": "ninja-clang-linux-debug", + "displayName": "Ninja Clang Debug", + "description": "Build using Ninja Multi-Config generator and Clang compiler with Debug configuration", + "configurePreset": "ninja-clang-linux", + "configuration": "Debug", + "inherits": [ + "base", + "linux" + ] + }, + { + "name": "ninja-clang-linux-release", + "displayName": "Ninja Clang Release", + "description": "Build using Ninja Multi-Config generator and Clang compiler with Release configuration", + "configurePreset": "ninja-clang-linux", + "configuration": "Release", + "inherits": [ + "base", + "linux" + ] + }, + { + "name": "ninja-clang-linux-reldebinfo", + "displayName": "Ninja Clang RelWithDebInfo", + "description": "Build using Ninja Multi-Config generator and Clang compiler with RelWithDebInfo configuration", + "configurePreset": "ninja-clang-linux", + "configuration": "RelWithDebInfo", + "inherits": [ + "base", + "linux" + ] + }, + { + "name": "ninja-clang-windows-debug", + "displayName": "Ninja Clang Debug", + "description": "Build using Ninja Multi-Config generator and Clang compiler with Debug configuration", + "configurePreset": "ninja-clang-windows", + "configuration": "Debug", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "ninja-clang-windows-release", + "displayName": "Ninja Clang Release", + "description": "Build using Ninja Multi-Config generator and Clang compiler with Release configuration", + "configurePreset": "ninja-clang-windows", + "configuration": "Release", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "ninja-clang-windows-reldebinfo", + "displayName": "Ninja Clang RelWithDebInfo", + "description": "Build using Ninja Multi-Config generator and Clang compiler with RelWithDebInfo configuration", + "configurePreset": "ninja-clang-windows", + "configuration": "RelWithDebInfo", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "ninja-msvc-windows-debug", + "displayName": "Ninja MSVC Debug", + "description": "Build using Ninja Multi-Config generator and MSVC compiler with Debug configuration", + "configurePreset": "ninja-msvc-windows", + "configuration": "Debug", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "ninja-msvc-windows-release", + "displayName": "Ninja MSVC Release", + "description": "Build using Ninja Multi-Config generator and MSVC compiler with Release configuration", + "configurePreset": "ninja-msvc-windows", + "configuration": "Release", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "ninja-msvc-windows-reldebinfo", + "displayName": "Ninja MSVC RelWithDebInfo", + "description": "Build using Ninja Multi-Config generator and MSVC compiler with RelWithDebInfo configuration", + "configurePreset": "ninja-msvc-windows", + "configuration": "RelWithDebInfo", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "vs2022-msvc-windows-debug", + "displayName": "VS 2022 MSVC Debug", + "description": "Build using Visual Studio 17 2022 generator and MSVC compiler with Debug configuration", + "configurePreset": "vs2022-msvc-windows", + "configuration": "Debug", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "vs2022-msvc-windows-release", + "displayName": "VS 2022 MSVC Release", + "description": "Build using Visual Studio 17 2022 generator and MSVC compiler with Release configuration", + "configurePreset": "vs2022-msvc-windows", + "configuration": "Release", + "inherits": [ + "base", + "windows" + ] + }, + { + "name": "vs2022-msvc-windows-reldebinfo", + "displayName": "VS 2022 MSVC RelWithDebInfo", + "description": "Build using Visual Studio 17 2022 generator and MSVC compiler with RelWithDebInfo configuration", + "configurePreset": "vs2022-msvc-windows", + "configuration": "RelWithDebInfo", + "inherits": [ + "base", + "windows" + ] + } + ] +} diff --git a/cmake/AppVersion.cmake b/cmake/AppVersion.cmake new file mode 100644 index 0000000..a54f894 --- /dev/null +++ b/cmake/AppVersion.cmake @@ -0,0 +1,103 @@ +# Set the main version numbers +set(CMAKE_PROJECT_VERSION_MAJOR 1) +set(CMAKE_PROJECT_VERSION_MINOR 0) +set(SVN_OLD_NUMBER 664) # Base commit count offset + +# Search for Git on the system +find_package(Git QUIET) + +if(GIT_FOUND) + # Get the current branch name + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Get the total number of commits in the current branch + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-list --count ${GIT_BRANCH} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_COMMIT_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Add the base commit count offset to the total commit count + math(EXPR GIT_COMMIT_COUNT "${GIT_COMMIT_COUNT} + ${SVN_OLD_NUMBER}") + + # Get the full SHA hash of the current commit + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse --verify HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_SHA_FULL + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Extract the first 7 characters of the SHA + string(SUBSTRING "${GIT_SHA_FULL}" 0 7 GIT_COMMIT_SHA) + + # Get the date of the last commit + execute_process( + COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=format:%Y-%m-%d + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Get the time of the last commit + execute_process( + COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cd --date=format:%H:%M:%S + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_COMMIT_TIME + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Check if there are any local modifications (uncommitted changes) + execute_process( + COMMAND "${GIT_EXECUTABLE}" ls-files -m + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_MODIFIED + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # If there are modified files, mark the version as modified + if(GIT_MODIFIED) + set(VERSION_MODIFIED "+m") + else() + set(VERSION_MODIFIED "") + endif() + + # Get the repository's remote URL + execute_process( + COMMAND "${GIT_EXECUTABLE}" config --get remote.origin.url + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_URL + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # Remove the ".git" suffix from the URL if it exists + string(REGEX REPLACE "\\.git$" "" GIT_URL "${GIT_URL}") + + # Format the commit URL based on the hosting platform + if(GIT_URL MATCHES "bitbucket.org") + set(GIT_COMMIT_URL "${GIT_URL}/commits/") + else() + set(GIT_COMMIT_URL "${GIT_URL}/commit/") + endif() +else() + message(WARNING "Git not found, auto-versioning disabled") + set(GIT_COMMIT_COUNT 0) + set(GIT_COMMIT_SHA "unknown") + set(VERSION_MODIFIED "") + set(GIT_COMMIT_URL "unknown") + set(GIT_COMMIT_DATE "unknown") + set(GIT_COMMIT_TIME "unknown") +endif() + +# Format the project version +set(CMAKE_PROJECT_VERSION_PATCH "${GIT_COMMIT_COUNT}") +set(CMAKE_PROJECT_VERSION_TWEAK "0") +set(CMAKE_PROJECT_VERSION + "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}${VERSION_MODIFIED}" +) diff --git a/cmake/CompileOptions.cmake b/cmake/CompileOptions.cmake new file mode 100644 index 0000000..9806b60 --- /dev/null +++ b/cmake/CompileOptions.cmake @@ -0,0 +1,57 @@ +#------------------------------------------------------------------------------- +# Platform-specific compile options +#------------------------------------------------------------------------------- + +set(PLATFORM_OPTIONS_FILE "CompileOptions${CMAKE_SYSTEM_NAME}.cmake") +set(PLATFORM_OPTIONS_PATH "${CMAKE_SOURCE_DIR}/cmake/${PLATFORM_OPTIONS_FILE}") + +include("${PLATFORM_OPTIONS_PATH}" + OPTIONAL + RESULT_VARIABLE IS_PLATFORM_OPTIONS_INCLUDED +) + +if(IS_PLATFORM_OPTIONS_INCLUDED) + message(STATUS "Applied platform-specific compile options.") +else() + message(STATUS "No platform-specific compile options found. Using defaults.") +endif() + +#------------------------------------------------------------------------------- +# Compiler-specific options +#------------------------------------------------------------------------------- + +get_property(ENABLED_LANG_LIST GLOBAL PROPERTY ENABLED_LANGUAGES) + +if(ENABLED_LANG_LIST) + foreach(lang IN LISTS ENABLED_LANG_LIST) + string(TOUPPER "${lang}" lang_prefix) + + if(DEFINED CMAKE_${lang_prefix}_COMPILER_ID) + list(APPEND COMPILER_LIST "${CMAKE_${lang_prefix}_COMPILER_ID}") + endif() + endforeach() + + list(REMOVE_DUPLICATES COMPILER_LIST) + + foreach(compiler_id IN LISTS COMPILER_LIST) + if(NOT compiler_id OR "${compiler_id}" STREQUAL "") + continue() + endif() + + set(COMPILER_OPTIONS_FILE "CompileOptions${CMAKE_SYSTEM_NAME}${compiler_id}.cmake") + set(COMPILER_OPTIONS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${COMPILER_OPTIONS_FILE}") + + include("${COMPILER_OPTIONS_PATH}" + OPTIONAL + RESULT_VARIABLE IS_COMPILER_OPTIONS_INCLUDED + ) + + if(IS_COMPILER_OPTIONS_INCLUDED) + message(STATUS "Applied ${compiler_id} compiler options.") + else() + message(STATUS "No ${compiler_id} compiler options found. Using defaults.") + endif() + endforeach() +else() + message(WARNING "No enabled languages found - skipping applying compiler-specific options.") +endif() diff --git a/cmake/CompileOptionsLinux.cmake b/cmake/CompileOptionsLinux.cmake new file mode 100644 index 0000000..cc31553 --- /dev/null +++ b/cmake/CompileOptionsLinux.cmake @@ -0,0 +1,126 @@ +#------------------------------------------------------------------------------- +# C/CXX Flags +#------------------------------------------------------------------------------- + +set(CMAKE_C_FLAGS_DEBUG + "-g -fno-omit-frame-pointer" +) + +set(CMAKE_C_FLAGS_RELEASE + "-O3 -fno-stack-protector -fomit-frame-pointer -DNDEBUG" +) + +set(CMAKE_C_FLAGS_MINSIZEREL + "-Os -fno-stack-protector -fomit-frame-pointer -DNDEBUG" +) + +set(CMAKE_C_FLAGS_RELWITHDEBINFO + "-O2 -g -DNDEBUG" +) + +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + +#------------------------------------------------------------------------------- +# Machine Architecture Flag +#------------------------------------------------------------------------------- + +function(set_march_flag lang compiler_id compiler_version) + if(NOT compiler_id OR "${compiler_id}" STREQUAL "") + return() + endif() + + if(OPTIMIZE_FOR_CURRENT_CPU) + set(march_flag "-march=native") + elseif("${compiler_id}" STREQUAL "GNU" AND "${compiler_version}" VERSION_LESS "11") + set(march_flag "-march=nehalem") # nehalem is close to x86-64-v2 + elseif("${compiler_id}" STREQUAL "Clang" AND "${compiler_version}" VERSION_LESS "12") + set(march_flag "-march=nehalem") + else() + set(march_flag "-march=x86-64-v2") + endif() + + string(STRIP "${CMAKE_${lang}_FLAGS} ${march_flag}" march_flag) + set(CMAKE_${lang}_FLAGS "${march_flag}" PARENT_SCOPE) +endfunction() + +set_march_flag("C" "${CMAKE_C_COMPILER_ID}" "${CMAKE_C_COMPILER_VERSION}") +set_march_flag("CXX" "${CMAKE_CXX_COMPILER_ID}" "${CMAKE_CXX_COMPILER_VERSION}") + +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +add_compile_options( + -m32 # Generate 32-bit code + -mmmx # Enable MMX instruction set + -msse # Enable SSE instruction set + -msse2 # Enable SSE2 instruction set + -msse3 # Enable SSE3 instruction set + -mssse3 # Enable SSSE3 instruction set + -msse4 # Enable SSE4 instruction set + -msse4.1 # Enable SSE4.1 instruction set + -msse4.2 # Enable SSE4.2 instruction set + -mfpmath=sse # Use SSE for floating-point math + -pipe # Use pipes rather than intermediate files + -fdata-sections # Place data items in separate sections + -ffunction-sections # Place each function in its own section + + # Link libc++ as the C++ standard library + $<$:-stdlib=libc++> + + # Enable AddressSanitizer instrumentation + $<$:-fsanitize=address> + + # Enable UndefinedBehaviorSanitizer instrumentation + $<$:-fsanitize=undefined> + + # Enable/disable Run-Time Type Information + $<$:$,-frtti,-fno-rtti>> + + # Enable/disable exception handling + $<$:$,-fexceptions,-fno-exceptions>> +) + +#------------------------------------------------------------------------------- +# Link Options +#------------------------------------------------------------------------------- + +add_link_options( + -m32 # Generate 32-bit code + -Wl,--as-needed # Only link libraries that are actually used + -Wl,--gc-sections # Remove unused code sections during linking + -Wl,--no-undefined # Report undefined symbols as errors + + # ASAN is disabled: Warn about common symbols + $<$>:-Wl,--warn-common> + + # RelWithDebInfo: Compress debug sections using zlib + # $<$:-Wl,--compress-debug-sections=zlib> + + # Release and MinSizeRel: Strip all symbols + $<$,$>:-Wl,--strip-all> + + # Non-Debug: Discard local symbols + $<$>:-Wl,--discard-all> + + # Link libc++ as the C++ standard library + $<$:-stdlib=libc++> + + # Enable AddressSanitizer instrumentation + $<$:-fsanitize=address> + + # Enable UndefinedBehaviorSanitizer instrumentation + $<$:-fsanitize=undefined> + + # Link libgcc statically + $<$:-static-libgcc> + + # Link libstdc++ statically + $<$:-static-libstdc++> + + # Enable linker trace output + $<$:-Wl,--trace> +) diff --git a/cmake/CompileOptionsLinuxClang.cmake b/cmake/CompileOptionsLinuxClang.cmake new file mode 100644 index 0000000..ec5c035 --- /dev/null +++ b/cmake/CompileOptionsLinuxClang.cmake @@ -0,0 +1,53 @@ +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +add_compile_options( + # Debug: Optimize for debugging experience + $<$:-Og> + + # Debug and RelWithDebInfo: Generate debug information for GDB + $<$,$>:-ggdb> +) + +# Enable full Link-Time Optimization for C +set(CMAKE_C_COMPILE_OPTIONS_IPO -flto=full) + +# Enable full Link-Time Optimization for C++ +set(CMAKE_CXX_COMPILE_OPTIONS_IPO -flto=full) + +#------------------------------------------------------------------------------- +# Link Options +#------------------------------------------------------------------------------- + +if(USE_LINKER_LLD) + add_link_options( + -fuse-ld=lld # Use the LLVM LLD linker + -Wl,--check-sections # Check section address conflicts + -Wl,--icf=safe # Enable safe identical code folding + -Wl,--warn-backrefs # Warn about backward references in the symbol table + -Wl,--warn-ifunc-textrel # Warn about text relocations in indirect functions + -Wl,--warn-symbol-ordering # Warn when symbol ordering is not as expected + + #-Wl,--print-gc-sections # Print removed unused sections + #-Wl,--print-icf-sections # Print folded identical sections + + # Non-Debug: Set linker optimization level + $<$>:-Wl,-O2> + + # Release and MinSizeRel: Set LTO optimization level + $<$,$>:-Wl,--lto-O3> + ) +else() + add_link_options( + -Wl,--check-sections # Check section address conflicts + -Wl,--no-allow-shlib-undefined # Do not allow undefined symbols in shared libraries + -Wl,--warn-alternate-em # Warn about ELF machine type mismatches + + # Non-Debug: Set linker optimization level + $<$>:-Wl,-O3> + + # Non-Debug: Enable linker relaxation optimizations + $<$>:-Wl,--relax> + ) +endif() diff --git a/cmake/CompileOptionsLinuxGNU.cmake b/cmake/CompileOptionsLinuxGNU.cmake new file mode 100644 index 0000000..9bca6a8 --- /dev/null +++ b/cmake/CompileOptionsLinuxGNU.cmake @@ -0,0 +1,76 @@ +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +add_compile_options( + # Debug: Optimize for debugging experience + $<$:-Og> + + # Debug and RelWithDebInfo: Generate debug information for GDB + $<$,$>:-ggdb> +) + +# Check if the GCC compiler version is greater than or equal to 12 +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + set(CMAKE_C_COMPILE_OPTIONS_IPO + -flto=auto # Enable Link Time Optimization with automatic parallelization + -fno-fat-lto-objects # Disable generation of fat LTO objects + ) +endif() + +# Check if the G++ compiler version is greater than or equal to 12 +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + set(CMAKE_CXX_COMPILE_OPTIONS_IPO + -flto=auto + -fno-fat-lto-objects + ) +endif() + +#------------------------------------------------------------------------------- +# Link Options +#------------------------------------------------------------------------------- + +if(USE_LINKER_GOLD) + add_link_options( + -fuse-ld=gold # Use the Gold linker + -Wl,--icf=safe # Enable safe identical code folding + -Wl,--icf-iterations=5 # Set identical code folding iterations + -Wl,--no-whole-archive # Do not force inclusion of entire static libraries + -Wl,--unresolved-symbols=report-all # Report all unresolved symbols + -Wl,--warn-execstack # Warn if an executable stack is detected + -Wl,--warn-search-mismatch # Warn about mismatches in library search paths + -Wl,--warn-shared-textrel # Warn about text relocations in shared objects + #-Wl,--warn-drop-version # Warn when version information is dropped + + #-Wl,--print-gc-sections # Print removed unused sections + #-Wl,--print-icf-sections # Print folded identical sections + #-Wl,--stats # Print statistics about the linking process + + # Non-Debug: Set linker optimization level + $<$>:-Wl,-O3> + + # Non-Debug: Enable linker relaxation optimizations + $<$>:-Wl,--relax> + + # Non-Debug: Disable incremental linking + $<$>:-Wl,--no-incremental> + + # ASAN is disabled: Detect One Definition Rule violations + $<$>:-Wl,--detect-odr-violations> + + # Release and MinSizeRel: Disable generation of unwind info + $<$,$>:-Wl,--no-ld-generated-unwind-info> + ) +else() + add_link_options( + -Wl,--check-sections # Check section address conflicts + -Wl,--no-allow-shlib-undefined # Do not allow undefined symbols in shared libraries + -Wl,--warn-alternate-em # Warn about ELF machine type mismatches + + # Non-Debug: Set linker optimization level + $<$>:-Wl,-O3> + + # Non-Debug: Enable linker relaxation optimizations + $<$>:-Wl,--relax> + ) +endif() diff --git a/cmake/CompileOptionsWindows.cmake b/cmake/CompileOptionsWindows.cmake new file mode 100644 index 0000000..e6bb0f5 --- /dev/null +++ b/cmake/CompileOptionsWindows.cmake @@ -0,0 +1,157 @@ +#------------------------------------------------------------------------------- +# C/CXX Flags +#------------------------------------------------------------------------------- + +set(CMAKE_C_FLAGS + "/DWIN32 /D_WINDOWS" +) + +set(CMAKE_C_FLAGS_DEBUG + "/Ob0 /Oi- /Od /Oy- /RTC1 /D_DEBUG" +) + +set(CMAKE_C_FLAGS_RELEASE + "/O2 /Oi /Ob2 /Ot /Oy /DNDEBUG" +) + +set(CMAKE_C_FLAGS_MINSIZEREL + "/O1 /Oi- /Ob1 /Os /Oy /DNDEBUG" +) + +set(CMAKE_C_FLAGS_RELWITHDEBINFO + "/O2 /Oi /Ob1 /Ot /DNDEBUG" +) + +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + +#------------------------------------------------------------------------------- +# Compile Definitions +#------------------------------------------------------------------------------- + +add_compile_definitions( + # Shared library definitions + $<$,SHARED_LIBRARY>:_USRDLL> + $<$,SHARED_LIBRARY>:_WINDLL> + $<$,SHARED_LIBRARY>:_WINDOWS> + + # Static library definitions + $<$,STATIC_LIBRARY>:_LIB> + + # Enable/disable exception support + $<$:_HAS_EXCEPTIONS=1> + $<$>:_HAS_EXCEPTIONS=0> +) + +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +# Code generation +add_compile_options( + /QIntel-jcc-erratum # Mitigate performance impact of the Intel JCC erratum microcode update + /Gy # Enable function-level linking + + # Non-Debug: Enable string pooling + $,/GF-,/GF> + + # Non-Debug: Enable whole-program global data optimization + $,/Gw-,/Gw> + + # Non-Debug executables: Optimize for Windows applications + $<$>,$,EXECUTABLE>>:/GA> + + # Enable/disable standard exception handling + $<$:/EHsc> + $<$>:/EHs-c-> + + # Enable/disable Run-Time Type Information + $<$:$,/GR,/GR->> + + # Enable AddressSanitizer instrumentation + $<$:/fsanitize=address> +) + +# Language +add_compile_options( + # Non-Debug: Strip unreferenced COMDAT + $<$>:/Zc:inline> +) + +# Miscellaneous +add_compile_options( + /cgthreads${NUM_CORES} # Thread count for code generation + /utf-8 # Set source and execution character sets to UTF-8 + /validate-charset # Validate the source file charset + + # Debug and RelWithDebInfo: Enable concurrent PDB writes for shared access + $<$,$>:/FS> +) + +# Diagnostics +add_compile_options( + /diagnostics:caret # Display error diagnostics with caret indicators + /external:W0 # Suppress warnings from external headers +) + +# Debug: Enable Just My Code debugging in Visual Studio +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING $) + +#------------------------------------------------------------------------------- +# Link Options +#------------------------------------------------------------------------------- + +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO") +set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/INCREMENTAL:NO") +set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO") + +set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") +set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") +set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") + +set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") +set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}") +set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}") + +add_link_options( + # Debug and RelWithDebInfo: Generate debug information in PDB files + $<$,$>:/DEBUG> + + # Release and MinSizeRel: Disable debug information generation + $<$,$>:/DEBUG:NONE> + + # Non-Debug: Enable Link Time Code Generation + $<$>:/LTCG> + + # Non-Debug: Apply link-time optimizations + $<$>:/OPT:REF,ICF,LBR> + + # Non-Debug: Treat warnings as errors + $<$>:/WX> + + # Enable/disable Safe Exception Handlers + $<$:/SAFESEH> + $<$>:/SAFESEH:NO> + + # Enable AddressSanitizer instrumentation + $<$:/fsanitize=address> + $<$:/INFERASANLIBS> + + # Enable/disable Output detailed linking info + $<$:/VERBOSE:LIB> +) + +#------------------------------------------------------------------------------- +# Link Libraries +#------------------------------------------------------------------------------- + +# Set the MSVC runtime library variant (debug/release, static/dynamic) +set(CMAKE_MSVC_RUNTIME_LIBRARY + "MultiThreaded$<$:Debug>$<$>:DLL>" +) diff --git a/cmake/CompileOptionsWindowsClang.cmake b/cmake/CompileOptionsWindowsClang.cmake new file mode 100644 index 0000000..804e718 --- /dev/null +++ b/cmake/CompileOptionsWindowsClang.cmake @@ -0,0 +1,28 @@ +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +add_compile_options( + -mmmx # Enable MMX extended instruction set + -msse # Enable SSE extended instruction set + -msse2 # Enable SSE2 extended instruction set + -msse3 # Enable SSE3 extended instruction set + -mssse3 # Enable SSSE3 extended instruction set + -msse4.1 # Enable SSE4.1 extended instruction set + -msse4.2 # Enable SSE4.2 extended instruction set + -fcf-protection=none # Instrument control-flow architecture protection + + # Debug and RelWithDebInfo: Generate complete debug information in PDB files + $<$,$>:/Zi> + + # Non-Debug: Enable automatic parallelization of loops + $<$>:/Qvec> + + # Generate instructions for a specified machine type + $,-march=native,-march=x86-64-v2> +) + +# Set the MSVC debug information format (/Zi (ProgramDatabase)) +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT + "$<$,$>:ProgramDatabase>" +) diff --git a/cmake/CompileOptionsWindowsMSVC.cmake b/cmake/CompileOptionsWindowsMSVC.cmake new file mode 100644 index 0000000..364bdf3 --- /dev/null +++ b/cmake/CompileOptionsWindowsMSVC.cmake @@ -0,0 +1,51 @@ +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +if(ENABLE_ASAN) + set(DEBUG_FORMAT_FLAG "/Zi") + set(MSVC_DEBUG_INFORMATION_FORMAT "$<$,$>:ProgramDatabase>") +else() + set(DEBUG_FORMAT_FLAG "/ZI") + set(MSVC_DEBUG_INFORMATION_FORMAT "$<$:EditAndContinue>$<$:ProgramDatabase>") +endif() + +add_compile_options( + /MP # Multi-processor compilation + /arch:SSE2 # Minimum required instruction set + /fpcvt:BC # Floating-point to integer conversion compatibility + /Qspectre- # Disable Spectre variant 1 mitigations + /external:anglebrackets # Treat headers included with angle brackets < > as external + + # Debug: Ensure distinct function addresses + $<$:/Gu> + + # Debug: Zero initialize padding for stack based class types + $<$:/presetPadding> + + # Debug: Generate enhanced debug info with 'Edit and Continue' support + $<$:${DEBUG_FORMAT_FLAG}> + + # RelWithDebInfo: Generate complete debug information in PDB files + $<$:/Zi> + + # Debug and RelWithDebInfo: Enable faster PDB generation + $<$,$>:/Zf> + + # Non-Debug: Enable whole program optimization + $,/GL-,/GL> + + # Non-Debug: Enable automatic parallelization of loops + $<$>:/Qpar> +) + +# Set the MSVC debug information format (/ZI (EditAndContinue), /Zi (ProgramDatabase)) +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "${MSVC_DEBUG_INFORMATION_FORMAT}") + +#------------------------------------------------------------------------------- +# Link Options +#------------------------------------------------------------------------------- + +add_link_options( + /CGTHREADS:${NUM_CORES} # Thread count for parallel linking +) diff --git a/dep/metamod/CMakeLists.txt b/dep/metamod/CMakeLists.txt new file mode 100644 index 0000000..d5a480c --- /dev/null +++ b/dep/metamod/CMakeLists.txt @@ -0,0 +1,54 @@ +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project("MetamodSDK") + +#------------------------------------------------------------------------------- +# Target Definition +#------------------------------------------------------------------------------- + +set(TARGET_NAME "metamod") +set(TARGET_ALIAS "Metamod::${TARGET_NAME}") + +add_library("${TARGET_NAME}" INTERFACE) +add_library("${TARGET_ALIAS}" ALIAS "${TARGET_NAME}") + +#------------------------------------------------------------------------------- +# Source Files +#------------------------------------------------------------------------------- + +target_sources("${TARGET_NAME}" + INTERFACE + "dllapi.h" + "engine_api.h" + "enginecallbacks.h" + "h_export.h" + "log_meta.h" + "meta_api.h" + "mhook.h" + "mreg.h" + "mutil.h" + "osdep.h" + "plinfo.h" + "sdk_util.h" + "types_meta.h" +) + +#------------------------------------------------------------------------------- +# Include Directories +#------------------------------------------------------------------------------- + +target_include_directories("${TARGET_NAME}" + INTERFACE + "${PROJECT_SOURCE_DIR}" +) + +#------------------------------------------------------------------------------- +# Link Libraries +#------------------------------------------------------------------------------- + +target_link_libraries("${TARGET_NAME}" + INTERFACE + "ReHLSDK::rehlsdk" +) diff --git a/dep/opus/CMakeLists.txt b/dep/opus/CMakeLists.txt new file mode 100644 index 0000000..7a797b7 --- /dev/null +++ b/dep/opus/CMakeLists.txt @@ -0,0 +1,280 @@ +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project("Opus") + +#------------------------------------------------------------------------------- +# Target Definition +#------------------------------------------------------------------------------- + +set(TARGET_NAME "opus") +set(TARGET_ALIAS "Opus::${TARGET_NAME}") + +add_library("${TARGET_NAME}") +add_library("${TARGET_ALIAS}" ALIAS "${TARGET_NAME}") + +#------------------------------------------------------------------------------- +# Source Files +#------------------------------------------------------------------------------- + +target_sources("${TARGET_NAME}" + PUBLIC + "include/opus_custom.h" + "include/opus_defines.h" + "include/opus_multistream.h" + "include/opus_types.h" + "include/opus.h" + + PRIVATE + "src/analysis.c" + "src/analysis.h" + "src/mlp_data.c" + "src/mlp.c" + "src/mlp.h" + "src/opus_decoder.c" + "src/opus_encoder.c" + "src/opus_multistream_decoder.c" + "src/opus_multistream_encoder.c" + "src/opus_multistream.c" + "src/opus_private.h" + "src/opus.c" + "src/repacketizer.c" + "src/tansig_table.h" + + "celt/_kiss_fft_guts.h" + "celt/arch.h" + "celt/bands.c" + "celt/bands.h" + "celt/celt_decoder.c" + "celt/celt_encoder.c" + "celt/celt_lpc.c" + "celt/celt_lpc.h" + "celt/celt.c" + "celt/celt.h" + "celt/cpu_support.h" + "celt/cwrs.c" + "celt/cwrs.h" + "celt/ecintrin.h" + "celt/entcode.c" + "celt/entcode.h" + "celt/entdec.c" + "celt/entdec.h" + "celt/entenc.c" + "celt/entenc.h" + "celt/fixed_debug.h" + "celt/fixed_generic.h" + "celt/float_cast.h" + "celt/kiss_fft.c" + "celt/kiss_fft.h" + "celt/laplace.c" + "celt/laplace.h" + "celt/mathops.c" + "celt/mathops.h" + "celt/mdct.c" + "celt/mdct.h" + "celt/mfrngcod.h" + "celt/modes.c" + "celt/modes.h" + "celt/os_support.h" + "celt/pitch.c" + "celt/pitch.h" + "celt/quant_bands.c" + "celt/quant_bands.h" + "celt/rate.c" + "celt/rate.h" + "celt/stack_alloc.h" + "celt/static_modes_fixed_arm_ne10.h" + "celt/static_modes_fixed.h" + "celt/static_modes_float_arm_ne10.h" + "celt/static_modes_float.h" + "celt/vq.c" + "celt/vq.h" + "celt/x86/celt_lpc_sse.c" + "celt/x86/celt_lpc_sse.h" + "celt/x86/pitch_sse.c" + "celt/x86/pitch_sse.h" + "celt/x86/pitch_sse2.c" + "celt/x86/pitch_sse4_1.c" + "celt/x86/x86_celt_map.c" + "celt/x86/x86cpu.c" + "celt/x86/x86cpu.h" + + "silk/A2NLSF.c" + "silk/ana_filt_bank_1.c" + "silk/API.h" + "silk/biquad_alt.c" + "silk/bwexpander_32.c" + "silk/bwexpander.c" + "silk/check_control_input.c" + "silk/CNG.c" + "silk/code_signs.c" + "silk/control_audio_bandwidth.c" + "silk/control_codec.c" + "silk/control_SNR.c" + "silk/control.h" + "silk/debug.c" + "silk/debug.h" + "silk/dec_API.c" + "silk/decode_core.c" + "silk/decode_frame.c" + "silk/decode_indices.c" + "silk/decode_parameters.c" + "silk/decode_pitch.c" + "silk/decode_pulses.c" + "silk/decoder_set_fs.c" + "silk/define.h" + "silk/enc_API.c" + "silk/encode_indices.c" + "silk/encode_pulses.c" + "silk/errors.h" + "silk/gain_quant.c" + "silk/HP_variable_cutoff.c" + "silk/init_decoder.c" + "silk/init_encoder.c" + "silk/Inlines.h" + "silk/inner_prod_aligned.c" + "silk/interpolate.c" + "silk/lin2log.c" + "silk/log2lin.c" + "silk/LP_variable_cutoff.c" + "silk/LPC_analysis_filter.c" + "silk/LPC_inv_pred_gain.c" + "silk/MacroCount.h" + "silk/MacroDebug.h" + "silk/macros.h" + "silk/main.h" + "silk/NLSF_decode.c" + "silk/NLSF_del_dec_quant.c" + "silk/NLSF_encode.c" + "silk/NLSF_stabilize.c" + "silk/NLSF_unpack.c" + "silk/NLSF_VQ_weights_laroia.c" + "silk/NLSF_VQ.c" + "silk/NLSF2A.c" + "silk/NSQ_del_dec.c" + "silk/NSQ.c" + "silk/NSQ.h" + "silk/pitch_est_defines.h" + "silk/pitch_est_tables.c" + "silk/PLC.c" + "silk/PLC.h" + "silk/process_NLSFs.c" + "silk/quant_LTP_gains.c" + "silk/resampler_down2_3.c" + "silk/resampler_down2.c" + "silk/resampler_private_AR2.c" + "silk/resampler_private_down_FIR.c" + "silk/resampler_private_IIR_FIR.c" + "silk/resampler_private_up2_HQ.c" + "silk/resampler_private.h" + "silk/resampler_rom.c" + "silk/resampler_rom.h" + "silk/resampler_structs.h" + "silk/resampler.c" + "silk/shell_coder.c" + "silk/sigm_Q15.c" + "silk/SigProc_FIX.h" + "silk/sort.c" + "silk/stereo_decode_pred.c" + "silk/stereo_encode_pred.c" + "silk/stereo_find_predictor.c" + "silk/stereo_LR_to_MS.c" + "silk/stereo_MS_to_LR.c" + "silk/stereo_quant_pred.c" + "silk/structs.h" + "silk/sum_sqr_shift.c" + "silk/table_LSF_cos.c" + "silk/tables_gain.c" + "silk/tables_LTP.c" + "silk/tables_NLSF_CB_NB_MB.c" + "silk/tables_NLSF_CB_WB.c" + "silk/tables_other.c" + "silk/tables_pitch_lag.c" + "silk/tables_pulses_per_block.c" + "silk/tables.h" + "silk/tuning_parameters.h" + "silk/typedef.h" + "silk/VAD.c" + "silk/VQ_WMat_EC.c" + "silk/float/apply_sine_window_FLP.c" + "silk/float/autocorrelation_FLP.c" + "silk/float/burg_modified_FLP.c" + "silk/float/bwexpander_FLP.c" + "silk/float/corrMatrix_FLP.c" + "silk/float/encode_frame_FLP.c" + "silk/float/energy_FLP.c" + "silk/float/find_LPC_FLP.c" + "silk/float/find_LTP_FLP.c" + "silk/float/find_pitch_lags_FLP.c" + "silk/float/find_pred_coefs_FLP.c" + "silk/float/inner_product_FLP.c" + "silk/float/k2a_FLP.c" + "silk/float/levinsondurbin_FLP.c" + "silk/float/LPC_analysis_filter_FLP.c" + "silk/float/LPC_inv_pred_gain_FLP.c" + "silk/float/LTP_analysis_filter_FLP.c" + "silk/float/LTP_scale_ctrl_FLP.c" + "silk/float/main_FLP.h" + "silk/float/noise_shape_analysis_FLP.c" + "silk/float/pitch_analysis_core_FLP.c" + "silk/float/prefilter_FLP.c" + "silk/float/process_gains_FLP.c" + "silk/float/regularize_correlations_FLP.c" + "silk/float/residual_energy_FLP.c" + "silk/float/scale_copy_vector_FLP.c" + "silk/float/scale_vector_FLP.c" + "silk/float/schur_FLP.c" + "silk/float/SigProc_FLP.h" + "silk/float/solve_LS_FLP.c" + "silk/float/sort_FLP.c" + "silk/float/structs_FLP.h" + "silk/float/warped_autocorrelation_FLP.c" + "silk/float/wrappers_FLP.c" +) + +#------------------------------------------------------------------------------- +# Include Directories +#------------------------------------------------------------------------------- + +target_include_directories("${TARGET_NAME}" + PUBLIC + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_SOURCE_DIR}/celt" + "${PROJECT_SOURCE_DIR}/silk" + "${PROJECT_SOURCE_DIR}/silk/float" +) + +#------------------------------------------------------------------------------- +# Target Properties +#------------------------------------------------------------------------------- + +if(NOT WIN32) + set_target_properties("${TARGET_NAME}" + PROPERTIES + # Disable IPO as it causes some warnings + INTERPROCEDURAL_OPTIMIZATION OFF + INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL OFF + INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF + INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO OFF + ) +endif() + +#------------------------------------------------------------------------------- +# Compile Definitions +#------------------------------------------------------------------------------- + +target_compile_definitions("${TARGET_NAME}" + PRIVATE + OPUS_BUILD + USE_ALLOCA +) + +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +target_compile_options("${TARGET_NAME}" + PRIVATE + $,/W0,-w> +) diff --git a/dep/rehlsdk/CMakeLists.txt b/dep/rehlsdk/CMakeLists.txt new file mode 100644 index 0000000..f840892 --- /dev/null +++ b/dep/rehlsdk/CMakeLists.txt @@ -0,0 +1,177 @@ +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project("ReHLSDK") + +#------------------------------------------------------------------------------- +# Target Definition +#------------------------------------------------------------------------------- + +set(TARGET_NAME "rehlsdk") +set(TARGET_ALIAS "ReHLSDK::${TARGET_NAME}") + +add_library("${TARGET_NAME}" INTERFACE) +add_library("${TARGET_ALIAS}" ALIAS "${TARGET_NAME}") + +#------------------------------------------------------------------------------- +# Source Files +#------------------------------------------------------------------------------- + +target_sources("${TARGET_NAME}" + INTERFACE + "common/BaseSystemModule.h" + "common/beamdef.h" + "common/cl_entity.h" + "common/com_model.h" + "common/con_nprint.h" + "common/const.h" + "common/crc.h" + "common/cvardef.h" + "common/demo_api.h" + "common/director_cmds.h" + "common/dlight.h" + "common/dll_state.h" + "common/entity_state.h" + "common/entity_types.h" + "common/enums.h" + "common/event_api.h" + "common/event_args.h" + "common/event_flags.h" + "common/hltv.h" + "common/IAdminServer.h" + "common/IBaseSystem.h" + "common/IDemoPlayer.h" + "common/IEngineWrapper.h" + "common/IGameServerData.h" + "common/in_buttons.h" + "common/IObjectContainer.h" + "common/ISystemModule.h" + "common/IVGuiModule.h" + "common/ivoicetweak.h" + "common/kbutton.h" + "common/mathlib.h" + "common/md5.h" + "common/net_api.h" + "common/netadr.h" + "common/netapi.h" + "common/nowin.h" + "common/ObjectDictionary.h" + "common/ObjectList.h" + "common/parsemsg.h" + "common/particledef.h" + "common/pmtrace.h" + "common/port.h" + "common/qfont.h" + "common/qlimits.h" + "common/quakedef.h" + "common/r_efx.h" + "common/r_studioint.h" + "common/ref_params.h" + "common/screenfade.h" + "common/Sequence.h" + "common/SteamAppStartUp.h" + "common/SteamCommon.h" + "common/studio_event.h" + "common/textconsole.h" + "common/TextConsoleUnix.h" + "common/TextConsoleWin32.h" + "common/TokenLine.h" + "common/triangleapi.h" + "common/usercmd.h" + "common/vmodes.h" + "common/weaponinfo.h" + "common/winsani_in.h" + "common/winsani_out.h" + + "dlls/activity.h" + "dlls/activitymap.h" + "dlls/animation.h" + "dlls/basemonster.h" + "dlls/cbase.h" + "dlls/cdll_dll.h" + "dlls/client.h" + "dlls/decals.h" + "dlls/doors.h" + "dlls/effects.h" + "dlls/enginecallback.h" + "dlls/explode.h" + "dlls/extdll.h" + "dlls/func_break.h" + "dlls/game.h" + "dlls/gamerules.h" + "dlls/hornet.h" + "dlls/items.h" + "dlls/maprules.h" + "dlls/monsterevent.h" + "dlls/monsters.h" + "dlls/nodes.h" + "dlls/plane.h" + "dlls/player.h" + "dlls/saverestore.h" + "dlls/schedule.h" + "dlls/scriptevent.h" + "dlls/skill.h" + "dlls/soundent.h" + "dlls/spectator.h" + "dlls/talkmonster.h" + "dlls/teamplay_gamerules.h" + "dlls/trains.h" + "dlls/util.h" + "dlls/vector.h" + "dlls/weapons.h" + + "engine/archtypes.h" + "engine/bspfile.h" + "engine/cmd_rehlds.h" + "engine/common_rehlds.h" + "engine/crc32c.h" + "engine/custom.h" + "engine/customentity.h" + "engine/d_local.h" + "engine/edict.h" + "engine/eiface.h" + "engine/FlightRecorder.h" + "engine/hookchains.h" + "engine/keydefs.h" + "engine/maintypes.h" + "engine/model.h" + "engine/modelgen.h" + "engine/osconfig.h" + "engine/pr_dlls.h" + "engine/progdefs.h" + "engine/progs.h" + "engine/rehlds_api.h" + "engine/rehlds_interfaces.h" + "engine/Sequence.h" + "engine/shake.h" + "engine/spritegn.h" + "engine/static_map.h" + "engine/studio.h" + "engine/sys_shared.h" + "engine/userid_rehlds.h" + + "pm_shared/pm_debug.h" + "pm_shared/pm_defs.h" + "pm_shared/pm_info.h" + "pm_shared/pm_materials.h" + "pm_shared/pm_movevars.h" + "pm_shared/pm_shared.h" + + "public/commonmacros.h" + "public/FileSystem.h" + "public/interface.h" +) + +#------------------------------------------------------------------------------- +# Include Directories +#------------------------------------------------------------------------------- + +target_include_directories("${TARGET_NAME}" SYSTEM + INTERFACE + "${PROJECT_SOURCE_DIR}/common" + "${PROJECT_SOURCE_DIR}/dlls" + "${PROJECT_SOURCE_DIR}/engine" + "${PROJECT_SOURCE_DIR}/pm_shared" + "${PROJECT_SOURCE_DIR}/public" +) diff --git a/dep/silk/CMakeLists.txt b/dep/silk/CMakeLists.txt new file mode 100644 index 0000000..2dee328 --- /dev/null +++ b/dep/silk/CMakeLists.txt @@ -0,0 +1,210 @@ +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project("Silk") + +#------------------------------------------------------------------------------- +# Target Definition +#------------------------------------------------------------------------------- + +set(TARGET_NAME "silk") +set(TARGET_ALIAS "Silk::${TARGET_NAME}") + +add_library("${TARGET_NAME}") +add_library("${TARGET_ALIAS}" ALIAS "${TARGET_NAME}") + +#------------------------------------------------------------------------------- +# Source Files +#------------------------------------------------------------------------------- + +target_sources("${TARGET_NAME}" + PUBLIC + "include/SKP_Silk_control.h" + "include/SKP_Silk_errors.h" + "include/SKP_Silk_SDK_API.h" + "include/SKP_Silk_typedef.h" + + PRIVATE + "src/SKP_Silk_A2NLSF.c" + "src/SKP_Silk_allpass_int_FLP.c" + "src/SKP_Silk_allpass_int.c" + "src/SKP_Silk_ana_filt_bank_1.c" + "src/SKP_Silk_apply_sine_window_FLP.c" + "src/SKP_Silk_autocorrelation_FLP.c" + "src/SKP_Silk_biquad_alt.c" + "src/SKP_Silk_biquad.c" + "src/SKP_Silk_burg_modified_FLP.c" + "src/SKP_Silk_bwexpander_32.c" + "src/SKP_Silk_bwexpander_FLP.c" + "src/SKP_Silk_bwexpander.c" + "src/SKP_Silk_CNG.c" + "src/SKP_Silk_code_signs.c" + "src/SKP_Silk_common_pitch_est_defines.h" + "src/SKP_Silk_control_audio_bandwidth.c" + "src/SKP_Silk_control_codec_FLP.c" + "src/SKP_Silk_corrMatrix_FLP.c" + "src/SKP_Silk_create_init_destroy.c" + "src/SKP_Silk_dec_API.c" + "src/SKP_Silk_decimate2_coarse_FLP.c" + "src/SKP_Silk_decimate2_coarsest_FLP.c" + "src/SKP_Silk_decode_core.c" + "src/SKP_Silk_decode_frame.c" + "src/SKP_Silk_decode_parameters.c" + "src/SKP_Silk_decode_pitch.c" + "src/SKP_Silk_decode_pulses.c" + "src/SKP_Silk_decoder_set_fs.c" + "src/SKP_Silk_define.h" + "src/SKP_Silk_detect_SWB_input.c" + "src/SKP_Silk_enc_API.c" + "src/SKP_Silk_encode_frame_FLP.c" + "src/SKP_Silk_encode_parameters.c" + "src/SKP_Silk_encode_pulses.c" + "src/SKP_Silk_energy_FLP.c" + "src/SKP_Silk_find_LPC_FLP.c" + "src/SKP_Silk_find_LTP_FLP.c" + "src/SKP_Silk_find_pitch_lags_FLP.c" + "src/SKP_Silk_find_pred_coefs_FLP.c" + "src/SKP_Silk_gain_quant.c" + "src/SKP_Silk_HP_variable_cutoff_FLP.c" + "src/SKP_Silk_init_encoder_FLP.c" + "src/SKP_Silk_Inlines.h" + "src/SKP_Silk_inner_product_FLP.c" + "src/SKP_Silk_interpolate.c" + "src/SKP_Silk_k2a_FLP.c" + "src/SKP_Silk_LBRR_reset.c" + "src/SKP_Silk_levinsondurbin_FLP.c" + "src/SKP_Silk_lin2log.c" + "src/SKP_Silk_log2lin.c" + "src/SKP_Silk_lowpass_int.c" + "src/SKP_Silk_lowpass_short.c" + "src/SKP_Silk_LP_variable_cutoff.c" + "src/SKP_Silk_LPC_analysis_filter_FLP.c" + "src/SKP_Silk_LPC_inv_pred_gain_FLP.c" + "src/SKP_Silk_LPC_inv_pred_gain.c" + "src/SKP_Silk_LPC_synthesis_filter.c" + "src/SKP_Silk_LPC_synthesis_order16.c" + "src/SKP_Silk_LSF_cos_table.c" + "src/SKP_Silk_LTP_analysis_filter_FLP.c" + "src/SKP_Silk_LTP_scale_ctrl_FLP.c" + "src/SKP_Silk_MA.c" + "src/SKP_Silk_macros.h" + "src/SKP_Silk_main_FLP.h" + "src/SKP_Silk_main.h" + "src/SKP_Silk_NLSF_MSVQ_decode_FLP.c" + "src/SKP_Silk_NLSF_MSVQ_decode.c" + "src/SKP_Silk_NLSF_MSVQ_encode_FLP.c" + "src/SKP_Silk_NLSF_stabilize.c" + "src/SKP_Silk_NLSF_VQ_rate_distortion_FLP.c" + "src/SKP_Silk_NLSF_VQ_sum_error_FLP.c" + "src/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c" + "src/SKP_Silk_NLSF2A_stable.c" + "src/SKP_Silk_NLSF2A.c" + "src/SKP_Silk_noise_shape_analysis_FLP.c" + "src/SKP_Silk_NSQ_del_dec.c" + "src/SKP_Silk_NSQ.c" + "src/SKP_Silk_pitch_analysis_core_FLP.c" + "src/SKP_Silk_pitch_est_defines_FLP.h" + "src/SKP_Silk_pitch_est_defines.h" + "src/SKP_Silk_pitch_est_tables.c" + "src/SKP_Silk_PLC.c" + "src/SKP_Silk_PLC.h" + "src/SKP_Silk_prefilter_FLP.c" + "src/SKP_Silk_process_gains_FLP.c" + "src/SKP_Silk_process_NLSFs_FLP.c" + "src/SKP_Silk_quant_LTP_gains_FLP.c" + "src/SKP_Silk_range_coder.c" + "src/SKP_Silk_regularize_correlations_FLP.c" + "src/SKP_Silk_resampler_down2_3.c" + "src/SKP_Silk_resampler_down2.c" + "src/SKP_Silk_resampler_down3.c" + "src/SKP_Silk_resampler_private_AR2.c" + "src/SKP_Silk_resampler_private_ARMA4.c" + "src/SKP_Silk_resampler_private_copy.c" + "src/SKP_Silk_resampler_private_down_FIR.c" + "src/SKP_Silk_resampler_private_down4.c" + "src/SKP_Silk_resampler_private_IIR_FIR.c" + "src/SKP_Silk_resampler_private_up2_HQ.c" + "src/SKP_Silk_resampler_private_up4.c" + "src/SKP_Silk_resampler_private.h" + "src/SKP_Silk_resampler_rom.c" + "src/SKP_Silk_resampler_rom.h" + "src/SKP_Silk_resampler_structs.h" + "src/SKP_Silk_resampler_up2.c" + "src/SKP_Silk_resampler.c" + "src/SKP_Silk_residual_energy_FLP.c" + "src/SKP_Silk_scale_copy_vector_FLP.c" + "src/SKP_Silk_scale_vector_FLP.c" + "src/SKP_Silk_schur_FLP.c" + "src/SKP_Silk_setup_complexity.h" + "src/SKP_Silk_shell_coder.c" + "src/SKP_Silk_sigm_Q15.c" + "src/SKP_Silk_SigProc_FIX.h" + "src/SKP_Silk_SigProc_FLP.h" + "src/SKP_Silk_solve_LS_FLP.c" + "src/SKP_Silk_sort_FLP.c" + "src/SKP_Silk_sort.c" + "src/SKP_Silk_structs_FLP.h" + "src/SKP_Silk_structs.h" + "src/SKP_Silk_sum_sqr_shift.c" + "src/SKP_Silk_tables_FLP.h" + "src/SKP_Silk_tables_gain.c" + "src/SKP_Silk_tables_LTP.c" + "src/SKP_Silk_tables_NLSF_CB0_10_FLP.c" + "src/SKP_Silk_tables_NLSF_CB0_10.c" + "src/SKP_Silk_tables_NLSF_CB0_10.h" + "src/SKP_Silk_tables_NLSF_CB0_16_FLP.c" + "src/SKP_Silk_tables_NLSF_CB0_16.c" + "src/SKP_Silk_tables_NLSF_CB0_16.h" + "src/SKP_Silk_tables_NLSF_CB1_10_FLP.c" + "src/SKP_Silk_tables_NLSF_CB1_10.c" + "src/SKP_Silk_tables_NLSF_CB1_10.h" + "src/SKP_Silk_tables_NLSF_CB1_16_FLP.c" + "src/SKP_Silk_tables_NLSF_CB1_16.c" + "src/SKP_Silk_tables_NLSF_CB1_16.h" + "src/SKP_Silk_tables_other_FLP.c" + "src/SKP_Silk_tables_other.c" + "src/SKP_Silk_tables_pitch_lag.c" + "src/SKP_Silk_tables_pulses_per_block.c" + "src/SKP_Silk_tables_sign.c" + "src/SKP_Silk_tables_type_offset.c" + "src/SKP_Silk_tables.h" + "src/SKP_Silk_tuning_parameters.h" + "src/SKP_Silk_VAD.c" + "src/SKP_Silk_VQ_nearest_neighbor_FLP.c" + "src/SKP_Silk_warped_autocorrelation_FLP.c" + "src/SKP_Silk_wrappers_FLP.c" +) + +#------------------------------------------------------------------------------- +# Include Directories +#------------------------------------------------------------------------------- + +target_include_directories("${TARGET_NAME}" + PUBLIC + "${PROJECT_SOURCE_DIR}/include" +) + +#------------------------------------------------------------------------------- +# Target Properties +#------------------------------------------------------------------------------- + +if(NOT WIN32) + set_target_properties("${TARGET_NAME}" + PROPERTIES + # Disable IPO as it causes some warnings + INTERPROCEDURAL_OPTIMIZATION OFF + INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL OFF + INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF + INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO OFF + ) +endif() + +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +target_compile_options("${TARGET_NAME}" + PRIVATE + $,/W0,-w> +) diff --git a/dep/speex/CMakeLists.txt b/dep/speex/CMakeLists.txt new file mode 100644 index 0000000..72004ca --- /dev/null +++ b/dep/speex/CMakeLists.txt @@ -0,0 +1,93 @@ +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project("Speex") + +#------------------------------------------------------------------------------- +# Target Definition +#------------------------------------------------------------------------------- + +set(TARGET_NAME "speex") +set(TARGET_ALIAS "Speex::${TARGET_NAME}") + +add_library("${TARGET_NAME}") +add_library("${TARGET_ALIAS}" ALIAS "${TARGET_NAME}") + +#------------------------------------------------------------------------------- +# Source Files +#------------------------------------------------------------------------------- + +target_sources("${TARGET_NAME}" + PUBLIC + "include/cb_search.h" + "include/filters_sse.h" + "include/filters.h" + "include/lpc.h" + "include/lsp.h" + "include/ltp_sse.h" + "include/ltp.h" + "include/math_approx.h" + "include/misc.h" + "include/modes.h" + "include/nb_celp.h" + "include/quant_lsp.h" + "include/sb_celp.h" + "include/speex_bits.h" + "include/speex_callbacks.h" + "include/speex_header.h" + "include/speex_stereo.h" + "include/speex.h" + "include/stack_alloc.h" + "include/vbr.h" + "include/vq.h" + + PRIVATE + "src/bits.c" + "src/cb_search.c" + "src/exc_10_16_table.c" + "src/exc_10_32_table.c" + "src/exc_20_32_table.c" + "src/exc_5_256_table.c" + "src/exc_5_64_table.c" + "src/exc_8_128_table.c" + "src/filters.c" + "src/gain_table_lbr.c" + "src/gain_table.c" + "src/hexc_10_32_table.c" + "src/hexc_table.c" + "src/high_lsp_tables.c" + "src/lpc.c" + "src/lsp_tables_nb.c" + "src/lsp.c" + "src/ltp.c" + "src/math_approx.c" + "src/misc.c" + "src/modes.c" + "src/nb_celp.c" + "src/quant_lsp.c" + "src/sb_celp.c" + "src/speex_callbacks.c" + "src/speex_header.c" + "src/stereo.c" + "src/vbr.c" + "src/vq.c" +) + +#------------------------------------------------------------------------------- +# Include Directories +#------------------------------------------------------------------------------- + +target_include_directories("${TARGET_NAME}" + PUBLIC + "${PROJECT_SOURCE_DIR}/include" +) + +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +target_compile_options("${TARGET_NAME}" + PRIVATE + $,/W0,-w> +) diff --git a/revoice/CMakeLists.txt b/revoice/CMakeLists.txt new file mode 100644 index 0000000..2d8b702 --- /dev/null +++ b/revoice/CMakeLists.txt @@ -0,0 +1,196 @@ +#------------------------------------------------------------------------------- +# Project Definition +#------------------------------------------------------------------------------- + +project("${CMAKE_PROJECT_NAME}") + +#------------------------------------------------------------------------------- +# Target Definition +#------------------------------------------------------------------------------- + +set(TARGET_NAME "revoice") +set(TARGET_ALIAS "ReVoice::${TARGET_NAME}") + +add_library("${TARGET_NAME}" SHARED) +add_library("${TARGET_ALIAS}" ALIAS "${TARGET_NAME}") + +if(WIN32) + set(BIN_OUTPUT_NAME "${TARGET_NAME}_mm") +else() + set(BIN_OUTPUT_NAME "${TARGET_NAME}_mm_i386") +endif() + +#------------------------------------------------------------------------------- +# Source Files +#------------------------------------------------------------------------------- + +# Generate appversion.h +set(APP_VERSION_FILE "${PROJECT_BINARY_DIR}/appversion.h") +configure_file("src/appversion.h.in" "${APP_VERSION_FILE}" @ONLY) + +# Define the precompiled headers +target_precompile_headers("${TARGET_NAME}" + PRIVATE + "src/precompiled.h" +) + +# Define the source files +target_sources("${TARGET_NAME}" + PRIVATE + "${APP_VERSION_FILE}" + + "include/dllapi.h" + "include/engine_api.h" + "include/enginecallbacks.h" + "include/h_export.h" + "include/log_meta.h" + "include/meta_api.h" + "include/mhook.h" + "include/mreg.h" + "include/mutil.h" + "include/osdep.h" + "include/plinfo.h" + "include/sdk_util.h" + "include/types_meta.h" + + "public/IVoiceCodec.h" + "public/reunion_api.h" + "public/utlbuffer.cpp" + "public/utlbuffer.h" + "public/utlmemory.h" + + "src/dllapi.cpp" + "src/engine_api.cpp" + "src/h_export.cpp" + "src/iframeencoder.h" + "src/meta_api.cpp" + "src/osconf.h" + "src/precompiled.cpp" + "src/precompiled.h" + "src/public_amalgamation.cpp" + "src/revoice_cfg.cpp" + "src/revoice_cfg.h" + "src/revoice_main.cpp" + "src/revoice_main.h" + "src/revoice_player.cpp" + "src/revoice_player.h" + "src/revoice_rehlds_api.cpp" + "src/revoice_rehlds_api.h" + "src/revoice_reunion_api.cpp" + "src/revoice_reunion_api.h" + "src/revoice_shared.h" + "src/revoice_utils.cpp" + "src/sdk_util.cpp" + "src/SteamP2PCodec.cpp" + "src/SteamP2PCodec.h" + "src/voice_codec_frame.cpp" + "src/voice_codec_frame.h" + "src/VoiceEncoder_Opus.cpp" + "src/VoiceEncoder_Opus.h" + "src/VoiceEncoder_Silk.cpp" + "src/VoiceEncoder_Silk.h" + "src/VoiceEncoder_Speex.cpp" + "src/VoiceEncoder_Speex.h" +) + +if(WIN32) + set(RESOURCE_FILENAME "${BIN_OUTPUT_NAME}.dll.rc") + set(MODULE_DEFINITION_FILENAME "${BIN_OUTPUT_NAME}.dll.def") + + configure_file( + "platform/windows/${RESOURCE_FILENAME}.in" + "${PROJECT_BINARY_DIR}/${RESOURCE_FILENAME}" + @ONLY + ) + + target_sources("${TARGET_NAME}" + PRIVATE + "${PROJECT_BINARY_DIR}/${RESOURCE_FILENAME}" + "platform/windows/${MODULE_DEFINITION_FILENAME}" + ) +endif() + +#------------------------------------------------------------------------------- +# Include Directories +#------------------------------------------------------------------------------- + +target_include_directories("${TARGET_NAME}" + PRIVATE + "$" + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_SOURCE_DIR}/public" + "${PROJECT_SOURCE_DIR}/src" +) + +#------------------------------------------------------------------------------- +# Target Properties +#------------------------------------------------------------------------------- + +set_target_properties("${TARGET_NAME}" + PROPERTIES + PREFIX "" + OUTPUT_NAME "${BIN_OUTPUT_NAME}" + LIBRARY_OUTPUT_DIRECTORY "${BIN_OUTPUT_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${BIN_OUTPUT_DIR}" + PDB_OUTPUT_DIRECTORY "${BIN_OUTPUT_DIR}" +) + +#------------------------------------------------------------------------------- +# Compile Definitions +#------------------------------------------------------------------------------- + +target_compile_definitions("${TARGET_NAME}" + PRIVATE + $<$: + _MBCS + _CRT_SECURE_NO_WARNINGS + > + + $<$>: + __int16=int16_t + _stricmp=strcasecmp + > +) + +#------------------------------------------------------------------------------- +# Compile Options +#------------------------------------------------------------------------------- + +target_compile_options("${TARGET_NAME}" + PRIVATE + $<$>: + -Wno-write-strings + > +) + +#------------------------------------------------------------------------------- +# Link Libraries +#------------------------------------------------------------------------------- + +target_link_libraries("${TARGET_NAME}" + PRIVATE + "Speex::speex" + "Silk::silk" + "Opus::opus" + "Metamod::metamod" + + $<$>: + "c" + "m" + "${CMAKE_DL_LIBS}" + > +) + +#------------------------------------------------------------------------------- +# Post-Build Actions +#------------------------------------------------------------------------------- + +if(MSVC) + set(ILK_FILE_PATH "$\\${BIN_OUTPUT_NAME}.ilk") + set(ILK_OUTPUT_DIR "${PROJECT_BINARY_DIR}/$") + + add_custom_command(TARGET "${TARGET_NAME}" POST_BUILD + COMMAND cmd /C "if exist \"${ILK_FILE_PATH}\" move \"${ILK_FILE_PATH}\" \"${ILK_OUTPUT_DIR}\\\"" + COMMENT "Moving '${ILK_FILE_PATH}' file to '${ILK_OUTPUT_DIR}' if it exists" + ) +endif() diff --git a/revoice/include/osdep.h b/revoice/include/osdep.h index e11a8b7..3666cb2 100644 --- a/revoice/include/osdep.h +++ b/revoice/include/osdep.h @@ -81,7 +81,7 @@ extern mBOOL dlclose_handle_invalid; // WINAPI should be provided in the windows compiler headers. // It's usually defined to something like "__stdcall". #elif defined(__linux__) - #define DLLEXPORT /* */ + #define DLLEXPORT __attribute__((visibility("default"))) #define WINAPI /* */ #endif /* linux */ diff --git a/revoice/platform/windows/revoice_mm.dll.def b/revoice/platform/windows/revoice_mm.dll.def new file mode 100644 index 0000000..5fcdb13 --- /dev/null +++ b/revoice/platform/windows/revoice_mm.dll.def @@ -0,0 +1,2 @@ +EXPORTS + GiveFnptrsToDll diff --git a/revoice/platform/windows/revoice_mm.dll.rc.in b/revoice/platform/windows/revoice_mm.dll.rc.in new file mode 100644 index 0000000..15dc775 --- /dev/null +++ b/revoice/platform/windows/revoice_mm.dll.rc.in @@ -0,0 +1,36 @@ +#include "winres.h" +#pragma code_page(65001) + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@ +PRODUCTVERSION @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@ +FILEFLAGSMASK 0x3fL +#ifdef _DEBUG +FILEFLAGS 0x1L +#else +FILEFLAGS 0x0L +#endif +FILEOS 0x40004L +FILETYPE 0x2L +FILESUBTYPE 0x0L + +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "CompanyName", "ReHLDS Team" + VALUE "ProductName", "@CMAKE_PROJECT_NAME@" + VALUE "InternalName", "@BIN_OUTPUT_NAME@" + VALUE "OriginalFilename", "@BIN_OUTPUT_NAME@.dll" + VALUE "FileVersion", "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@" + VALUE "ProductVersion", "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@" + VALUE "FileDescription", "@CMAKE_PROJECT_DESCRIPTION@" + VALUE "LegalCopyright", "Copyright © 2015-@CURRENT_YEAR@ ReHLDS Team" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/revoice/public/utlbuffer.cpp b/revoice/public/utlbuffer.cpp index c9f4508..59fca19 100644 --- a/revoice/public/utlbuffer.cpp +++ b/revoice/public/utlbuffer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ // // The copyright to the contents herein is the property of Valve, L.L.C. // The contents may be used and/or copied only with the written permission of @@ -416,4 +416,4 @@ void CUtlBuffer::SeekPut(SeekType_t type, int offset) m_Put = m_Memory.NumAllocated() - offset; break; } -} \ No newline at end of file +} diff --git a/revoice/public/utlbuffer.h b/revoice/public/utlbuffer.h index 9d7a55d..33682f8 100644 --- a/revoice/public/utlbuffer.h +++ b/revoice/public/utlbuffer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ // // The copyright to the contents herein is the property of Valve, L.L.C. // The contents may be used and/or copied only with the written permission of diff --git a/revoice/src/appversion.h.in b/revoice/src/appversion.h.in new file mode 100644 index 0000000..e5fdc4d --- /dev/null +++ b/revoice/src/appversion.h.in @@ -0,0 +1,22 @@ +#ifndef __APPVERSION_H__ +#define __APPVERSION_H__ + +// +// This file is generated automatically. +// Don't edit it. +// + +// Version defines +#define APP_VERSION "@CMAKE_PROJECT_VERSION@" +#define APP_VERSION_C @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@ +#define APP_VERSION_STRD "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@" +#define APP_VERSION_FLAGS 0x0L + +#define APP_COMMIT_DATE "@GIT_COMMIT_DATE@" +#define APP_COMMIT_TIME "@GIT_COMMIT_TIME@" + +#define APP_COMMIT_SHA "@GIT_COMMIT_SHA@" +#define APP_COMMIT_URL "@GIT_COMMIT_URL@" + +#endif //__APPVERSION_H__ + diff --git a/revoice/version/appversion.vm b/revoice/version/appversion.vm deleted file mode 100644 index d17386a..0000000 --- a/revoice/version/appversion.vm +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __APPVERSION_H__ -\#define __APPVERSION_H__ - -// -// This file is generated automatically. -// Don't edit it. -// - -// Version defines -\#define APP_VERSION "$verInfo.asMavenVersion()" -\#define APP_VERSION_C $verInfo.asMavenVersion(false, ",") -\#define APP_VERSION_STRD "$verInfo.asMavenVersion(false)" -\#define APP_VERSION_FLAGS 0x0L - -\#define APP_COMMIT_DATE "$verInfo.asCommitDate("yyyy-MM-dd")" -\#define APP_COMMIT_TIME "$verInfo.asCommitTime()" - -\#define APP_COMMIT_SHA "$verInfo.commitSHA" -\#define APP_COMMIT_URL "$verInfo.commitURL" - -#endif //__APPVERSION_H__ diff --git a/revoice/version/version.cpp b/revoice/version/version.cpp deleted file mode 100644 index 5089a5f..0000000 --- a/revoice/version/version.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* -* Version declaration dependency file -* -*/ - -// -// This file needed just to add the dependency and appversion.h -// -#include "precompiled.h" -