From 70a519e4e514e0a950e548449aacb326e99136b7 Mon Sep 17 00:00:00 2001 From: vergeten <4006735-vergeten-x@users.noreply.gitlab.com> Date: Mon, 12 Aug 2019 13:53:23 +0000 Subject: [PATCH] Very rough update to the CMakeLists.txt adding steamclient, steamnetworkingsockets and lobby_connect targets and fallbacks defines for the protobuf libraries and protoc executable --- .gitignore | 7 +- .gitlab-ci.yml | 60 ++++++ CMakeLists.txt | 303 ++++++++++++++++++++++++++ CMakeSettings.json | 520 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 231 ++++++++++++++++++++ 5 files changed, 1120 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 CMakeSettings.json diff --git a/.gitignore b/.gitignore index 103a206..21b8995 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,17 @@ +.vs/* .vscode/* *.bin *.o net.pb.* *steam_api* release/* +/build*/ *.obj +/dll/net.pb.cc +/dll/net.pb.h base.exp base.lib rtlgenrandom* steamclient.exp -steamclient.lib \ No newline at end of file +steamclient.lib +out/* \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a65d0c..6ef8dd9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -85,6 +85,66 @@ build_windows: - release/ expire_in: 1 day +build_cmake_linux: + stage: build + image: ubuntu:disco + + before_script: + - apt update -y + - apt install build-essential cmake libprotobuf-dev protobuf-compiler ninja-build -y + + script: + - mkdir cmake-builds && cd cmake-builds + - mkdir x64-release && cd x64-release + - cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" && ninja + - cd .. +# - mkdir x64-experimental-release && cd x64-experimental-release +# - cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD:BOOL=ON && ninja +# - cd .. + + artifacts: + paths: + - cmake-builds/ + expire_in: 1 day + +build_cmake_windows: + stage: build + image: fedora + + before_script: + - dnf update -y + - dnf install 'dnf-command(config-manager)' -y + - dnf config-manager --add-repo https://dl.winehq.org/wine-builds/fedora/30/winehq.repo + - dnf install wget p7zip winehq-devel samba-winbind-clients -y + - wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/48db8f434a193aae872279dc4f5dde6a/sdk_standalone.7z' + - 7za x sdk_standalone.7z -osdk_standalone + - wget 'https://github.com/Kitware/CMake/releases/download/v3.15.0-rc1/cmake-3.15.0-rc1-win64-x64.zip' + - 7za x cmake-3.15.0-rc1-win64-x64.zip + - wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/0119304e030098b4821d73170fe52084/protobuf_x64-windows-static.7z' + - 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static + + script: + - export WINEDEBUG=-all + - wine cmd /c + - mkdir cmake-builds && cd cmake-builds + - mkdir x64-release && cd x64-release + - echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat + - echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat + - echo nmake.exe >> cmake-build.bat + - wine cmd /c cmake-build.bat + - cd .. + - mkdir x64-experimental-release && cd x64-experimental-release + - echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat + - echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat + - echo nmake.exe >> cmake-build.bat + - wine cmd /c cmake-build.bat + - cd .. + + artifacts: + paths: + - cmake-builds/ + expire_in: 1 day + deploy_all: stage: deploy image: fedora diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7c8f2a1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,303 @@ +# Based on: https://github.com/ttroy50/cmake-examples/blob/master/03-code-generation/protobuf/CMakeLists.txt +cmake_minimum_required(VERSION 3.6) + +# Set the project name +project(goldberg_emulator) + +if(MSVC) + # Set static environment (results in static compile flags) if Visual Studio is used (dynamic by default) + # Officially recommended solution: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime + # Should be replaced by a better solution in the future: https://gitlab.kitware.com/cmake/cmake/merge_requests/3211 + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) + + # Disable MSVC++ warning C4996: 'may be unsafe/disable deprecation' + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + +# Add option to enable experimental build +option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF) + +# Set CXX standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# Find the protobuf compiler and libraries +include(FindProtobuf) +find_package(Protobuf 3.1.0 REQUIRED) + +# Generate the .h and .cxx files for dll/net.proto +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS dll/net.proto) + +# Print path to generated files +message(STATUS "PROTO_SRCS = ${PROTO_SRCS}") +message(STATUS "PROTO_HDRS = ${PROTO_HDRS}") +message(STATUS "PROTOBUF_INCLUDE_DIRS = ${PROTOBUF_INCLUDE_DIRS}") +message(STATUS "PROTOBUF_LIBRARIES = ${PROTOBUF_LIBRARIES}") +message(STATUS "PROTOBUF_PROTOC_EXECUTABLE = ${PROTOBUF_PROTOC_EXECUTABLE}") + +# Setup the lib/exe names for the targets +if(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(LIB_STEAM_API steam_api64) + set(LIB_STEAMCLIENT steamclient64) + set(LIB_STEAMNETWORKINGSOCKETS steamnetworkingsockets64) + set(BIN_LOBBY_CONNECT lobby_connect64) + set(BIN_GENERATE_INTERFACES_FILE generate_interfaces_file64) + else() + set(LIB_STEAM_API steam_api) + set(LIB_STEAMCLIENT steamclient) + set(LIB_STEAMNETWORKINGSOCKETS steamnetworkingsockets) + set(BIN_LOBBY_CONNECT lobby_connect) + set(BIN_GENERATE_INTERFACES_FILE generate_interfaces_file) + endif() +elseif(UNIX AND NOT APPLE) + set(LIB_STEAM_API steam_api) + set(LIB_STEAMCLIENT steamclient) + set(LIB_STEAMNETWORKINGSOCKETS steamnetworkingsockets) + set(BIN_LOBBY_CONNECT lobby_connect) + set(BIN_GENERATE_INTERFACES_FILE generate_interfaces_file) +else() + message(FATAL_ERROR "Other platforms not supported...") +endif() + +# Gather the files that are shared between multiple targets +file(GLOB DLL_SRC_SHARED + dll/*.h + dll/*.cpp +) + +file(GLOB DETOURS_SRC_SHARED + detours/*.cpp +) + +################################################### +# Setup for the steam_api(64).dll / libsteam_api.so +################################################### + +# Setup the target +add_library(${LIB_STEAM_API} + SHARED + $<$:${DETOURS_SRC_SHARED}> + ${DLL_SRC_SHARED} + ${PROTO_SRCS} + ${PROTO_HDRS} +) + +# Include the required directories +target_include_directories(${LIB_STEAM_API} + PRIVATE + ${PROTOBUF_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} +) + +# Link the required libraries +target_link_libraries(${LIB_STEAM_API} + PRIVATE + protobuf::libprotobuf + $<$:ws2_32> + $<$:iphlpapi> +) + +# Add target compile definitions +target_compile_definitions(${LIB_STEAM_API} + PRIVATE + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_EXPERIMENTAL_BUILD> +) + +# Install the target +if(WIN32) + install(TARGETS + ${LIB_STEAM_API} + RUNTIME DESTINATION ./ + ) +else() + install(TARGETS + ${LIB_STEAM_API} + LIBRARY DESTINATION ./ + ) +endif() + +######################################################## +# Setup for the steamclient(64).dll / libsteamclient.so? +######################################################## + +# Setup the target +add_library(${LIB_STEAMCLIENT} + SHARED + steamclient.cpp +) + +# Add target compile definitions +target_compile_definitions(${LIB_STEAMCLIENT} + PRIVATE + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_EXPERIMENTAL_BUILD> +) + +# Install the target +if(WIN32) + install(TARGETS + ${LIB_STEAMCLIENT} + RUNTIME DESTINATION ./ + ) +else() + install(TARGETS + ${LIB_STEAMCLIENT} + LIBRARY DESTINATION ./ + ) +endif() + +if(NOT WIN32) + message(STATUS "Target library 'steamclient' is only suported for windows at this time... Disabling Build ALL inclusion for this target") + set_target_properties(${LIB_STEAMCLIENT} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) +endif() + +############################################################################## +# Setup for the steamnetworkingsockets(64).dll / libsteamnetworkingsockets.so? +############################################################################## + +# Setup the target +add_library(${LIB_STEAMNETWORKINGSOCKETS} + SHARED + steamnetworkingsockets.cpp +) + +# Add target compile definitions +target_compile_definitions(${LIB_STEAMNETWORKINGSOCKETS} + PRIVATE + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_EXPERIMENTAL_BUILD> +) + +# Setup install rules for the target +if(WIN32) + install(TARGETS + ${LIB_STEAMNETWORKINGSOCKETS} + RUNTIME DESTINATION ./ + ) +else() + install(TARGETS + ${LIB_STEAMNETWORKINGSOCKETS} + LIBRARY DESTINATION ./ + ) +endif() + +if(NOT WIN32) + message(STATUS "Target library 'steamnetworkingsockets' is only supported for windows at this time... Disabling Build ALL inclusion for this target") + set_target_properties(${LIB_STEAMNETWORKINGSOCKETS} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) +endif() + +########################################################################### +# Setup for the lobby_connect(64).exe / lobby_connect +########################################################################### + +# Setup the target +add_executable(${BIN_LOBBY_CONNECT} + lobby_connect.cpp + $<$:${DETOURS_SRC_SHARED}> + ${DLL_SRC_SHARED} + ${PROTO_SRCS} + ${PROTO_HDRS} +) + +target_include_directories(${BIN_LOBBY_CONNECT} + PRIVATE + ${PROTOBUF_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} +) + +# Link the required libraries +target_link_libraries(${BIN_LOBBY_CONNECT} + PRIVATE + protobuf::libprotobuf + $<$:ws2_32> + $<$:iphlpapi> + $<$:comdlg32> + -debug:none +) + +# Add target compile definitions +target_compile_definitions(${BIN_LOBBY_CONNECT} + PRIVATE + NO_DISK_WRITES + LOBBY_CONNECT + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> + $<$:EMU_EXPERIMENTAL_BUILD> +) + +# Setup install rules for the target +install(TARGETS + ${BIN_LOBBY_CONNECT} + RUNTIME DESTINATION lobby_connect/ +) + +########################################################################### +# Setup for the generate_interfaces_file(64).exe / generate_interfaces_file +########################################################################### + +# Setup the target +add_executable(${BIN_GENERATE_INTERFACES_FILE} + generate_interfaces_file.cpp +) + +# Link the required libraries +target_link_libraries(${BIN_GENERATE_INTERFACES_FILE} + PRIVATE + -debug:none +) + +# Setup install rules for the target +install(TARGETS + ${BIN_GENERATE_INTERFACES_FILE} + RUNTIME DESTINATION tools/ +) + +########################################################################### +# Installation setup for non target files and directories +########################################################################### + +install(FILES + Readme_lobby_connect.txt + DESTINATION lobby_connect/ +) + +install(FILES + scripts/find_interfaces.sh + scripts/find_interfaces.ps1 + Readme_generate_interfaces.txt + DESTINATION tools/ +) + +install(FILES + Readme_release.txt + files_example/steam_appid.EDIT_AND_RENAME.txt + files_example/steam_interfaces.EXAMPLE.txt + $<$:${PROJECT_SOURCE_DIR}/Readme_experimental.txt> + $<$:${PROJECT_SOURCE_DIR}/Readme_debug.txt> + DESTINATION ./ +) + +install(DIRECTORY + files_example/steam_settings.EXAMPLE + DESTINATION ./ +) diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000..f5a15ab --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,520 @@ +{ + "configurations": [ + { + "name": "Windows-x64-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x64-windows-static", + "type": "STRING" + } + ], + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + { + "name": "Windows-x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x64-windows-static", + "type": "STRING" + } + ], + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + { + "name": "Windows-x86-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x86-windows-static", + "type": "STRING" + } + ], + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + { + "name": "Windows-x86-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x86-windows-static", + "type": "STRING" + } + ], + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + { + "name": "Linux-x64-Release", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync", + "variables": [] + }, + { + "name": "Linux-x64-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync", + "variables": [] + }, + { + "name": "Linux-x86-Release", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync", + "variables": [] + }, + { + "name": "Linux-x86-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync", + "variables": [] + }, + { + "name": "Windows-x64-ExperimentalRelease", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x64-windows-static", + "type": "STRING" + }, + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ], + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + { + "name": "Windows-x64-ExperimentalDebug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x64-windows-static", + "type": "STRING" + }, + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ] + }, + { + "name": "Windows-x86-ExperimentalRelease", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x86-windows-static", + "type": "STRING" + }, + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ] + }, + { + "name": "Windows-x86-ExperimentalDebug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "-v", + "ctestCommandArgs": "", + "cmakeToolchain": "../vcpkg/scripts/buildsystems/vcpkg.cmake", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x86-windows-static", + "type": "STRING" + }, + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ] + }, + { + "name": "Linux-x64-ExperimentalRelease", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync" + }, + { + "name": "Linux-x64-ExperimentalDebug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync" + }, + { + "name": "Linux-x86-ExperimentalRelease", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync" + }, + { + "name": "Linux-x86-ExperimentalDebug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/local/bin/cmake", + "remoteCopySourcesExclusionList": [ ".vs", ".git" ], + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "true", + "type": "STRING" + } + ], + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", + "remoteCopySources": true, + "rsyncCommandArgs": "-t --delete --delete-excluded", + "remoteCopyBuildOutput": true, + "remoteCopySourcesMethod": "rsync" + }, + { + "name": "WSL-x64-Release", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [] + }, + { + "name": "WSL-x64-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [] + }, + { + "name": "WSL-x86-Release", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [] + }, + { + "name": "WSL-x86-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [] + }, + { + "name": "WSL-x64-ExperimentalRelease", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "WSL-x64-ExperimentalDebug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "WSL-x86-ExperimentalRelease", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "WSL-x86-ExperimentalDebug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\${workspaceHash}\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x86" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "EMU_EXPERIMENTAL_BUILD", + "value": "True", + "type": "BOOL" + } + ] + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index eec7959..e308675 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,237 @@ Run the command: git pull ``` +## Building using CMake + +The following targets are included withing the CMake configuration for this project: +- Shared Libraries: + - steam_api + - steamclient + - steamnetworkingsockets +- Executables: + - lobby_connect + - generate_interfaces + +While all targets are included for all platforms/build variants, there are a couple of points to note: +- All targets are supported for All Windows (x64 and x86) platform/build variant combinations +- Build all inclusion of 'steamclient' and 'steamnetworkingsockets' is disabled for All Linux/WSL platforms (the targets code does currently not support these platforms) +- Experimental build variants will fail on Linux/WSL platforms (this is due to the code of the target experimental 'steam_api' variant not supporting these platforms) + +The CMake configuration for this project also includes install support. Installing the project will result in a cleaner set of output files (than the raw build files) and will copy over the appropriate readmes, tools and other support files from the projects directory. +This install is structured as followed: +``` ++ install-folder +|- (lib)steam_api(64).[dll|so] +|- (lib)steamclient(64).[dll|so] +|- (lib)steamnetworkingsockets(64).[dll|so] +|- Readme_release.txt +|- Readme_debug.txt // Only for debug build's +|- Readme_experimental.txt // Only for experimental build's +|- steam_appid.EDIT_AND_RENAME.txt +|- steam_interfaces.EXAMPLE.txt +|+ lobby_connect + |- lobby_connect(64)(.exe) + |- Readme_lobby_connect.txt +|+ tools + |- generate_interfaces(64)(.exe) + |- find_interfaces.ps1 + |- find_interfaces.sh + |- Readme_generate_interfaces.txt +|+ steam_settings.EXAMPLE + |- ... // steam_settings example files +``` +Note that if no `CMAKE_INSTALL_PREFIX` define is set for CMake generation (or another method of setting a custom installation directory is used) the default OS specific install directories will be used, these are: +- On Windows `c:/Program Files/${PROJECT_NAME}` +- On Linux `/usr/local` + +Please see the ['Change the installation directory'](#change-the-installation-directory) section of this readme for more information. + +### Windows + +#### Prerequisistes +- Visual Studio 2019 Installed or Build Tools for Visual Studio 2019 + - Can both be obtained here: https://visualstudio.microsoft.com/downloads/ + - (Optional) If you are planning to use Visual Studio make sure you include the following workloads during installation: + - 'Desktop Development with C++' + - 'C++ CMake tools for Windows' (Optional of the 'Desktop Development with C++' workload) + - (Optional) If you want build for Linux from Visual studio also include the 'Linux development with C++' workload. +- CMake ^3.6 + - Can be obtained here: https://cmake.org/download/ +- VCPKG + - Can be downloaded here: https://github.com/microsoft/vcpkg/archive/master.zip + - (Optional) For ease of use I advise you to extract the contents of this zip (the vcpkg-master folder) along side your goldberg_emulator folder and rename the vcpkg-master folder to just vcpkg, resulting in the following folder structure: + ``` + + some-top-level-folder + |- vcpkg + |- goldberg_emulator + ``` + - Can be installed by running the `bootstrap-vcpkg.bat` from the installation folder +- protobuf ^3.1 && protobuf compiler + - Can be installed (via VCPKG) by running `vcpkg install protobuf --triplet x64-windows-static && vcpkg install protobuf --triplet x86-windows-static` + - Alternatively you can try to compile them from the source, for instructions see: https://github.com/protocolbuffers/protobuf ) + +#### Generate and Build using Visual Studio 2019 +This repo includes a CMakeSettings.json file which contains the configurations for the following target platforms and build variants: +- Windows-x64-Release +- Windows-x64-Debug +- Windows-x86-Release +- Windows-x86-Debug +- Windows-x64-ExperimentalRelease +- Windows-x64-ExperimentalDebug +- Windows-x86-ExperimentalRelease +- Windows-x86-ExperimentalDebug +- Linux-x64-Release +- Linux-x64-Debug +- Linux-x86-Release +- Linux-x86-Debug +- Linux-x64-ExperimentalRelease +- Linux-x64-ExperimentalDebug +- Linux-x86-ExperimentalRelease +- Linux-x86-ExperimentalDebug +- WSL-x64-Release +- WSL-x64-Debug +- WSL-x86-Release +- WSL-x86-Debug +- WSL-x64-ExperimentalRelease +- WSL-x64-ExperimentalDebug +- WSL-x86-ExperimentalRelease +- WSL-x86-ExperimentalDebug + +These configurations should be automatically loaded when opening the goldberg_emulator folder in Visual Studio. +For more information on how to use these configurations (and CMake project in Visual Studio in general) please see: +https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019 + +Visual Studio builds for Windows and WSL configurations from will be outputted to the following folder: +`${projectDir}\out\${workspaceHash}\build\` + +You can also opt to install directly from Visual Studio. Visual Studio installs for Windows configurations from will be outputted to the following folder: +`${projectDir}\out\install\` + +While using these configurations are a couple of points to note: +- If you installed VCPKG into a different folder you might need to update the 'cmakeToolchain' field for each Windows configuration in the CMakeSettings.json to reflect the new VCPKG folder location +- Linux build configurations require a connection to a target Linux system in order to work, more information on how to set this up can be found here: + https://docs.microsoft.com/en-us/cpp/linux/connect-to-your-remote-linux-computer?view=vs-2019 +- WSL build configurations require a Windows Subsystem Linux to be installed: + https://docs.microsoft.com/en-us/cpp/linux/connect-to-your-remote-linux-computer?view=vs-2019#connect-to-wsl +- Both the Linux build system and the WSL instance require the same prerequisites as a found in the 'Building using CMake - Linux' section below +- Direct installation of the project from Visual Studio is currently only supported for Windows build configuration due to limited support for remote install in Visual Studio. + +#### Generate x64 +``` +call "\2019\VC\Auxiliary\Build\vcvars64.bat" +cd "" +cmake "" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static" -DCMAKE_TOOLCHAIN_FILE:STRING="\scripts\buildsystems\vcpkg.cmake" +``` + +Note that if you are using the Build Tools for Visual Studio 2019 the path to the vcvars64.bat is slightly diffrent: +``` +call "\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" +``` + +#### Build x64 +``` +call "\2019\VC\Auxiliary\Build\vcvars64.bat" +cd "" +nmake +``` + +#### Install x64 +``` +call "\2019\VC\Auxiliary\Build\vcvars64.bat" +cd "" +nmake install +``` + +#### Generate x86 +``` +call "\2019\VC\Auxiliary\Build\vcvars86.bat" +cd "" +cmake "" -DVCPKG_TARGET_TRIPLET:STRING="x86-windows-static" -DCMAKE_TOOLCHAIN_FILE:STRING="\scripts\buildsystems\vcpkg.cmake" +``` + +Note that if you are using the Build Tools for Visual Studio 2019 the path to the vcvars86.bat is slightly different: +``` +call "\2019\BuildTools\VC\Auxiliary\Build\vcvars86.bat" +``` + +#### Build x86 +``` +call "\2019\VC\Auxiliary\Build\vcvars86.bat" +cd "" +nmake +``` + +#### Install x86 +``` +call "\2019\VC\Auxiliary\Build\vcvars86.bat" +cd "" +nmake install +``` + +### Linux + +#### Prerequisistes +- Compile tools + - Can usually be obtained via your distro's package manager (e.g. on ubuntu: `sudo apt install build-essential`) +- Cmake ^3.6 + - Can usually be obtained via your distro's package manager (e.g. on ubuntu: `sudo apt install cmake`) +- protobuf ^3.1 && protobuf compiler + - Can usually be obtained via your distro's package manager (e.g. on ubuntu(^disco): `sudo apt install libprotobuf-dev protobuf-compiler`) + - Alternatively you can try to compile them from the source, for instructions see: https://github.com/protocolbuffers/protobuf ) + +#### Generate x64/x86 +``` +cd "" +cmake "" +``` + +#### Build +``` +cd "" +make +``` + +#### Install +``` +cd "" +make install +``` + +### Additional CMake Related Options + +#### Change the target build system +To set the generator, append `-G ""` e.g. +``` +cmake .. -G "Ninja" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static" -DCMAKE_TOOLCHAIN_FILE:STRING="..\vcpkg\scripts\buildsystems\vcpkg.cmake" +``` +#### Change the target build type +To set the build type, append `-DCMAKE_BUILD_TYPE:STRING=""` e.g. +``` +cmake .. -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static" -DCMAKE_TOOLCHAIN_FILE:STRING="..\vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" +``` + +#### Enable the experimental build +To set the experimental build, append `-DEMU_EXPERIMENTAL_BUILD:BOOL=ON` e.g. +``` +cmake .. -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static" -DCMAKE_TOOLCHAIN_FILE:STRING="..\vcpkg\scripts\buildsystems\vcpkg.cmake" -DEMU_EXPERIMENTAL_BUILD:BOOL=ON +``` + +#### Build with the ninja build system +To build a cmake config generated with Ninja: +``` +cd "" +ninja +``` + +#### Change the installation directory +To use a custom installation direction, append `-DCMAKE_INSTALL_PREFIX:STRING=""` e.g. +``` +cmake .. -DCMAKE_INSTALL_PREFIX:STRING="./install/" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static" -DCMAKE_TOOLCHAIN_FILE:STRING="..\vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" +``` + +If you do not want to preset the installation directory during the generation step you can also use a build tool or OS specific overwrite, some examples of this are: +- On Windows `nmake install prefix=""` +- On Linux `make DESTDIR="" install` ## Design Choices / FAQ