Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cpp SDK. Fixed regex for version detection. Fixed mingw build. #1029

Merged
merged 3 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdks/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (Git_FOUND)
OUTPUT_VARIABLE output
)
if (${result} EQUAL 0)
string(REGEX MATCH "\\d+.\\d+.\\d+" AGONES_VERSION ${output})
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" AGONES_VERSION ${output})
endif()
else()
message(WARNING "Git was not found. Current Agones version is set to ${AGONES_VERSION}")
Expand Down
6 changes: 3 additions & 3 deletions sdks/cpp/cmake/agonesConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ if (${AGONES_OWN_GRPC})
endif()

include(CMakeFindDependencyMacro)
find_dependency(ZLIB REQUIRED)
find_dependency(Protobuf REQUIRED CONFIG)
find_dependency(gRPC REQUIRED CONFIG)
find_dependency(ZLIB)
find_dependency(Protobuf CONFIG)
find_dependency(gRPC CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/agonesTargets.cmake")

check_required_components(agones)
24 changes: 19 additions & 5 deletions sdks/cpp/cmake/prerequisites.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include(ProcessorCount)
ProcessorCount(CPU_COUNT)
if (CPU_COUNT GREATER 0 AND NOT DEFINED CMAKE_BUILD_PARALLEL_LEVEL)
set($ENV{CMAKE_BUILD_PARALLEL_LEVEL} ${CPU_COUNT})
endif(CPU_COUNT)
endif()

# gRPC repo and version
set(gRPC_GIT_REPO "https://github.com/gRPC/gRPC.git")
Expand Down Expand Up @@ -130,6 +130,9 @@ if (NOT ${OpenSSL_FOUND} AND NOT ${gRPC_FOUND})
set(OPENSSL_ROOT_DIR "${AGONES_THIRDPARTY_INSTALL_PATH}/OpenSSL" CACHE PATH "OpenSSL root directory" FORCE)
find_package(OpenSSL QUIET)
if (NOT ${OpenSSL_FOUND})
if (${WIN32} AND ${MINGW})
message(FATAL_ERROR "MinGW build for OpenSSL is not supported, please set OPENSSL_ROOT_DIR variable to OpenSSL path")
endif()
download_git_repo(openssl ${OPENSSL_GIT_REPO} ${OPENSSL_GIT_TAG})
message(STATUS "Building OpenSSL... ${AGONES_OPENSSL_CONFIG_STRING}")
if (WIN32)
Expand All @@ -156,11 +159,11 @@ if (NOT ${gRPC_FOUND})
set(ZLIB_ROOT "${zlib_DIR}" CACHE PATH "ZLIB_ROOT" FORCE)
set(ZLIB_PARAM)
if (AGONES_ZLIB_STATIC)
set(ZLIB_NAME "libz${CMAKE_STATIC_LIBRARY_SUFFIX}")
if (WIN32)
set(ZLIB_NAME "zlibstatic${CMAKE_STATIC_LIBRARY_SUFFIX}")
find_library(ZLIB_PATH zlibstatic NAMES libzlibstatic PATHS ${ZLIB_ROOT}/lib)
set(ZLIB_LIBRARY ${ZLIB_PATH} CACHE PATH "ZLIB path" FORCE)
if (ZLIB_PATH-NOTFOUND)
message(FATAL_ERROR "Could not locate static zlib path")
endif()
set(ZLIB_LIBRARY "${ZLIB_ROOT}/lib/${ZLIB_NAME}" CACHE PATH "ZLIB path" FORCE)
set(ZLIB_PARAM "-DZLIB_LIBRARY=${ZLIB_LIBRARY}")
endif()

Expand All @@ -180,6 +183,16 @@ if (NOT ${gRPC_FOUND})
if (DEFINED OPENSSL_ROOT_DIR)
set(OPENSSL_PARAM "-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}")
endif()

set(GRPC_EXTRA_FLAGS)
if (MINGW)
set(GRPC_WINVER 0x0600)
set(GRPC_EXTRA_FLAGS
"-DCMAKE_C_FLAGS=-D_WIN32_WINNT=${GRPC_WINVER}"
"-DCMAKE_CXX_FLAGS=-D_WIN32_WINNT=${GRPC_WINVER}"
)
endif()

invoke_cmake_build(gRPC ${gRPC_SOURCE_DIR}
"${OPENSSL_PARAM}"
"-DZLIB_ROOT=${zlib_DIR}"
Expand All @@ -192,6 +205,7 @@ if (NOT ${gRPC_FOUND})
"-DgRPC_ZLIB_PROVIDER=package"
"-DgRPC_CARES_PROVIDER=package"
"-DgRPC_SSL_PROVIDER=package"
${GRPC_EXTRA_FLAGS}
)
set(AGONES_OWN_GRPC TRUE CACHE BOOL "Third party is built by Agones" FORCE)
endif()
Expand Down