Use cross-compilation docker images.

merge-requests/35/head
Nemirtingas 2020-10-14 06:44:04 +02:00
parent 7ad4fc1fdf
commit 0a4fdf1f69
8 changed files with 582 additions and 227 deletions

View File

@ -4,6 +4,204 @@ stages:
- deploy
- page_deploy
static:linux:deps:
stage: dependencies
image: nemirtingas/linux_vcpkg:ubuntu18
#when: manual
script:
- apt update && apt -y install libgl1-mesa-dev libgl1-mesa-dev:i386
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TRIPLET=x86-linux-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- TRIPLET=x64-linux-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- exit 0
cache:
key: static-linux-deps-cache
paths:
- vcpkg
artifacts:
paths:
- vcpkg
expire_in: 1 day
static:windows:deps:
stage: dependencies
image: nemirtingas/windowscross_vcpkg:msvc2019
#when: manual
script:
- VCPKG_PATH=$(pwd)/vcpkg
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- TRIPLET=x64-linux
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf:${TRIPLET} || exit 1
- TRIPLET=x86-windows-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[winssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- TRIPLET=x64-windows-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[winssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- exit 0
cache:
key: static-windows-deps-cache
paths:
- vcpkg
artifacts:
paths:
- vcpkg
expire_in: 1 day
static:macosx:deps:
stage: dependencies
image: nemirtingas/osxcross_vcpkg:SDK10.13
#when: manual
script:
- VCPKG_PATH=$(pwd)/vcpkg
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- TRIPLET=x64-linux
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf:${TRIPLET} || exit 1
- TRIPLET=x86-macosx-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- TRIPLET=x64-macosx-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- exit 0
cache:
key: static-macosx-deps-cache
paths:
- vcpkg/
artifacts:
paths:
- vcpkg/
expire_in: 1 day
build:linux:
stage: build
image: nemirtingas/linux_vcpkg:ubuntu18
dependencies:
- static:linux:deps
needs:
- static:linux:deps
script:
- apt update && apt -y install libgl1-mesa-dev libgl1-mesa-dev:i386
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TOOLCHAIN="/vcpkg/scripts/buildsystems/vcpkg.cmake"
- TRIPLET=x86-linux-goldberg
- OUT=linux32/Release
- cmake -G Ninja -Wno-dev -DX86=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- TRIPLET=x64-linux-goldberg
- OUT=linux64/Release
- cmake -G Ninja -Wno-dev -DX64=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- exit 0
artifacts:
paths:
- release/
- debug/
expire_in: 1 day
build:windows:
stage: build
image: nemirtingas/windowscross_vcpkg:msvc2019
dependencies:
- static:windows:deps
needs:
- static:windows:deps
script:
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TOOLCHAIN="/vcpkg/scripts/buildsystems/vcpkg.cmake"
- CHAINLOAD="/clang_windows_sdk/clang-cl-msvc.cmake"
- export HOST_ARCH=x86
- TRIPLET=x86-windows-goldberg
- OUT=win32/Release
- cmake -G Ninja -Wno-dev -DX86=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- export HOST_ARCH=x64
- TRIPLET=x64-windows-goldberg
- OUT=win64/Release
- cmake -G Ninja -Wno-dev -DX64=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
artifacts:
paths:
- release/
- debug/
expire_in: 1 day
build:macosx:
stage: build
image: nemirtingas/osxcross_vcpkg:SDK10.13
dependencies:
- static:macosx:deps
needs:
- static:macosx:deps
script:
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TOOLCHAIN="/vcpkg/scripts/buildsystems/vcpkg.cmake"
- CHAINLOAD="/osxcross/target/toolchain.cmake"
- export OSXCROSS_HOST=i386-apple-${OSXCROSS_TARGET}
- TRIPLET=x86-macosx-goldberg
- OUT=macosx32/Release
- cmake -G Ninja -Wno-dev -DX86=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- export OSXCROSS_HOST=x86_64-apple-${OSXCROSS_TARGET}
- TRIPLET=x64-macosx-goldberg
- OUT=macosx64/Release
- cmake -G Ninja -Wno-dev -DX64=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- mkdir release/macosx
- x86_64-apple-${OSXCROSS_TARGET}-lipo -create release/macosx*/steamclient.dylib -output release/macosx/steamclient.dylib
artifacts:
paths:
- release/
- debug/
expire_in: 1 day
protobuf_static_steamos:
stage: dependencies
image: tianon/steamos
@ -39,6 +237,8 @@ build_steamos:
image: tianon/steamos
dependencies:
- protobuf_static_steamos
needs:
- protobuf_static_steamos
before_script:
- apt update && apt -y install gcc-4.9 g++-4.9 git libtool g++-4.9-multilib gcc-4.9-multilib
@ -57,6 +257,8 @@ build_steamos:
build_windows:
stage: build
image: fedora:29
needs:
- protobuf_static_steamos
script:
- dnf -y install wine wget p7zip sed dos2unix
@ -94,66 +296,6 @@ build_windows:
- release/
expire_in: 1 day
build_cmake_linux:
stage: build
image: ubuntu
when: manual
before_script:
- export DEBIAN_FRONTEND=noninteractive
- 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:29
when: manual
before_script:
- dnf -y install wine wget p7zip sed dos2unix unzip
- 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" -DEMU_EXPERIMENTAL_BUILD=ON -DEMU_OVERLAY=ON -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

View File

@ -4,33 +4,182 @@ 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)
# Workaround because cross-compiling with CMake + vcpkg fucks up this variable
# making the 'find_*' functions/macros somehow fail to find the right arch.
# There are conditions like
# CMAKE_SIZEOF_VOID_P = "4" then look for i386 libraries...
# or
# CMAKE_SIZEOF_VOID_P = "8" then look for x86_64 libraries...
if(X86 AND NOT X64)
set(CMAKE_SIZEOF_VOID_P "4")
elseif(X64 AND NOT X86)
set(CMAKE_SIZEOF_VOID_P "8")
else()
message(FATAL_ERROR "Please define either -DX86=ON or -DX64=ON")
endif()
# Add option to enable experimental build
option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF)
if(WIN32) # Setup some variables for Windows build
if(MSVC) # If building with MSVC
add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Disable warning about strncpy_s and his friends
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"msvcrtd.lib\"") # Disable this linkage
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:\"msvcrtd.lib\"") # Disable this linkage
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) # Force to only build Debug & Release projects
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
if(X64)
set(LIB_STEAM_API steam_api64)
set(LIB_STEAMCLIENT steamclient64)
set(OUT_DIR win64)
elseif(X86)
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
set(OUT_DIR win32)
else()
message(FATAL_ERROR "Arch unknown")
endif()
file(
GLOB
OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/windows/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/windows/*.cpp
)
set(overlay_includes
overlay/
overlay/windows/
)
elseif(APPLE)
if(X64)
# Global flags for building steamapi (64bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m64")
set(OUT_DIR macosx64)
elseif(X86)
# Global flags for building steamapi (32bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32")
set(OUT_DIR macosx32)
else()
message(FATAL_ERROR "Arch unknown")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
file(
GLOB
OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay/*.cpp
)
set(overlay_includes
overlay/
)
elseif(UNIX)
if(X64)
# Global flags for building steamapi (64bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m64")
set(OUT_DIR linux64)
elseif(X86)
# Global flags for building steamapi (32bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32")
set(OUT_DIR linux32)
else()
message(FATAL_ERROR "Arch unknown")
endif()
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
file(
GLOB
OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/linux/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/linux/*.cpp
)
set(overlay_includes
overlay/
overlay/linux/
)
else()
message(FATAL_ERROR "No CMake for other platforms")
endif()
# 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
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Add option to enable experimental build
option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF)
if(EMU_EXPERIMENTAL_BUILD)
if(APPLE)
set(EMU_OVERLAY OFF)
else()
option(EMU_OVERLAY "Enable the emulator overlay" ON)
endif()
else()
set(EMU_OVERLAY OFF)
endif()
set(Protobuf_USE_STATIC_LIBS ON)
include(FindProtobuf)
find_package(Protobuf 3.1.0 REQUIRED)
find_package(Threads REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(nlohmann-fifo-map CONFIG REQUIRED)
find_path(STB_INCLUDE_DIRS "stb.h")
if(NOT WIN32)
find_package(OpenSSL REQUIRED)
endif()
if(NOT APPLE)
find_package(GLEW REQUIRED)
endif()
# Generate the .h and .cxx files for dll/net.proto
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS dll/net.proto)
@ -38,34 +187,6 @@ 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
@ -77,26 +198,6 @@ file(GLOB DETOURS_SRC_SHARED
detours/*.cpp
)
if(WIN32)
file(GLOB OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/windows/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/windows/*.cpp
glew/glew.c
)
elseif(UNIX)
file(GLOB OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/linux/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/linux/*.cpp
glew/glew.c
)
endif()
###################################################
# Setup for the steam_api(64).dll / libsteam_api.so
###################################################
@ -112,99 +213,134 @@ add_library(${LIB_STEAM_API}
)
# Include the required directories
target_include_directories(${LIB_STEAM_API}
target_include_directories(
${LIB_STEAM_API}
PRIVATE
${PROTOBUF_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/ImGui
${CMAKE_CURRENT_SOURCE_DIR}/glew/include
${STB_INCLUDE_DIRS}
overlay_experimental
)
# Link the required libraries
target_link_libraries(${LIB_STEAM_API}
PRIVATE
protobuf::libprotobuf
Threads::Threads
protobuf::libprotobuf-lite
#nlohmann_json::nlohmann_json doesn't work
nlohmann-fifo-map::nlohmann-fifo-map
$<$<NOT:$<BOOL:${APPLE}>>:GLEW::GLEW>
$<$<BOOL:${WIN32}>:comdlg32>
$<$<BOOL:${WIN32}>:advapi32>
$<$<BOOL:${WIN32}>:shell32>
$<$<BOOL:${WIN32}>:user32>
$<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:opengl32.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:Winmm.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:winmm.lib>
# For library UNIX loading
$<$<NOT:$<BOOL:${WIN32}>>:dl>
# For overlay opengl
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:GL>
)
# Add target compile definitions
target_compile_definitions(${LIB_STEAM_API}
PRIVATE
GLEW_NO_GLU
STBI_NO_SIMD
$<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD>
$<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD>
$<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD>
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
$<$<BOOL:${EMU_OVERLAY}>:EMU_OVERLAY>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:GLEW_STATIC>
)
# 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?
########################################################
if(UNIX)
SET_TARGET_PROPERTIES(${LIB_STEAMCLIENT} PROPERTIES PREFIX "")
endif()
# Setup the target
add_library(${LIB_STEAMCLIENT}
SHARED
steamclient.cpp
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}>
$<$<AND:$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}>
${DLL_SRC_SHARED}
${PROTO_SRCS}
${PROTO_HDRS}
)
# Include the required directories
target_include_directories(
${LIB_STEAMCLIENT}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${STB_INCLUDE_DIRS}
overlay_experimental
)
# Link the required libraries
target_link_libraries(${LIB_STEAMCLIENT}
PRIVATE
Threads::Threads
protobuf::libprotobuf-lite
#nlohmann_json::nlohmann_json doesn't work
nlohmann-fifo-map::nlohmann-fifo-map
$<$<NOT:$<BOOL:${APPLE}>>:GLEW::GLEW>
$<$<BOOL:${WIN32}>:comdlg32>
$<$<BOOL:${WIN32}>:advapi32>
$<$<BOOL:${WIN32}>:shell32>
$<$<BOOL:${WIN32}>:user32>
$<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:opengl32.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:winmm.lib>
# For library UNIX loading
$<$<NOT:$<BOOL:${WIN32}>>:dl>
# For overlay opengl
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:GL>
)
# Add target compile definitions
target_compile_definitions(${LIB_STEAMCLIENT}
PRIVATE
GLEW_NO_GLU
STBI_NO_SIMD
STEAMCLIENT_DLL
$<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD>
$<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD>
$<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD>
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
$<$<BOOL:${EMU_OVERLAY}>:EMU_OVERLAY>
)
# 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}
add_library(steamnetworkingsockets
SHARED
steamnetworkingsockets.cpp
)
# Add target compile definitions
target_compile_definitions(${LIB_STEAMNETWORKINGSOCKETS}
target_compile_definitions(steamnetworkingsockets
PRIVATE
$<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD>
@ -213,30 +349,14 @@ target_compile_definitions(${LIB_STEAMNETWORKINGSOCKETS}
$<$<BOOL:${EMU_EXPERIMENTAL_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()
set_target_properties(steamnetworkingsockets PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
###########################################################################
# Setup for the lobby_connect(64).exe / lobby_connect
###########################################################################
# Setup the target
add_executable(${BIN_LOBBY_CONNECT}
add_executable(lobby_connect
lobby_connect.cpp
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}>
${DLL_SRC_SHARED}
@ -244,25 +364,34 @@ add_executable(${BIN_LOBBY_CONNECT}
${PROTO_HDRS}
)
target_include_directories(${BIN_LOBBY_CONNECT}
target_include_directories(lobby_connect
PRIVATE
${PROTOBUF_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)
# Link the required libraries
target_link_libraries(${BIN_LOBBY_CONNECT}
target_link_libraries(lobby_connect
PRIVATE
protobuf::libprotobuf
Threads::Threads
protobuf::libprotobuf-lite
#nlohmann_json::nlohmann_json doesn't work
nlohmann-fifo-map::nlohmann-fifo-map
$<$<BOOL:${WIN32}>:comdlg32>
$<$<BOOL:${WIN32}>:advapi32>
$<$<BOOL:${WIN32}>:shell32>
$<$<BOOL:${WIN32}>:user32>
$<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi>
$<$<BOOL:${WIN32}>:comdlg32>
${CMAKE_DL_LIBS}
# For library UNIX loading
$<$<NOT:$<BOOL:${WIN32}>>:dl>
-debug:none
)
# Add target compile definitions
target_compile_definitions(${BIN_LOBBY_CONNECT}
target_compile_definitions(lobby_connect
PRIVATE
NO_DISK_WRITES
LOBBY_CONNECT
@ -273,47 +402,63 @@ target_compile_definitions(${BIN_LOBBY_CONNECT}
$<$<BOOL:${EMU_EXPERIMENTAL_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}
add_executable(
generate_interfaces
generate_interfaces_file.cpp
)
# Link the required libraries
target_link_libraries(${BIN_GENERATE_INTERFACES_FILE}
target_link_libraries(
generate_interfaces
PRIVATE
-debug:none
)
# Setup install rules for the target
###########################################################################
# Installation setup
###########################################################################
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(OUT_DIR debug/${OUT_DIR})
else()
set(OUT_DIR release/${OUT_DIR})
endif()
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
# emulators
install(
TARGETS ${LIB_STEAM_API} ${LIB_STEAMCLIENT}
RUNTIME DESTINATION ${OUT_DIR}
LIBRARY DESTINATION ${OUT_DIR}
)
# generate_interfaces
install(TARGETS
${BIN_GENERATE_INTERFACES_FILE}
RUNTIME DESTINATION tools/
generate_interfaces
RUNTIME DESTINATION ${OUT_DIR}/tools/generate_interfaces
)
###########################################################################
# 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/
DESTINATION ${OUT_DIR}/tools/generate_interfaces
)
# lobby_connect
install(TARGETS
lobby_connect
RUNTIME DESTINATION ${OUT_DIR}/tools/lobby_connect
)
install(FILES
Readme_lobby_connect.txt
DESTINATION ${OUT_DIR}/tools/lobby_connect
)
install(FILES
@ -322,10 +467,10 @@ install(FILES
files_example/steam_interfaces.EXAMPLE.txt
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${PROJECT_SOURCE_DIR}/Readme_experimental.txt>
$<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/Readme_debug.txt>
DESTINATION ./
DESTINATION ${OUT_DIR}
)
install(DIRECTORY
files_example/steam_settings.EXAMPLE
DESTINATION ./
DESTINATION ${OUT_DIR}
)

View File

@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

View File

@ -0,0 +1,16 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(ENV{OSXCROSS_HOST} "x86_64-apple-$ENV{OSXCROSS_TARGET}")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /osxcross/target/toolchain.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/osx.cmake")
set(VCPKG_C_FLAGS "-stdlib=libc++")
set(VCPKG_CXX_FLAGS "-stdlib=libc++")

View File

@ -0,0 +1,11 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(ENV{HOST_ARCH} ${VCPKG_TARGET_ARCHITECTURE})
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /clang_windows_sdk/clang-cl-msvc.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/windows.cmake")

View File

@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

View File

@ -0,0 +1,16 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(ENV{OSXCROSS_HOST} "i386-apple-$ENV{OSXCROSS_TARGET}")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /osxcross/target/toolchain.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/osx.cmake")
set(VCPKG_C_FLAGS "-stdlib=libc++")
set(VCPKG_CXX_FLAGS "-stdlib=libc++")

View File

@ -0,0 +1,11 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(ENV{HOST_ARCH} ${VCPKG_TARGET_ARCHITECTURE})
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /clang_windows_sdk/clang-cl-msvc.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/windows.cmake")