Skip to content

Commit

Permalink
build moonlight common c
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 19, 2024
1 parent fd4d160 commit 8ecd2c1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_RELEASE "-O2")

# submodules
# moonlight common library
# find_package(OpenSSL REQUIRED)
include(GetOpenSSL REQUIRED)
set(ENET_NO_INSTALL ON CACHE BOOL "Don't install any libraries built for enet")
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c")

set(MOONLIGHT_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
)
Expand Down
33 changes: 33 additions & 0 deletions cmake/modules/GetOpenSSL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include_guard(GLOBAL)

set(OPENSSL_VERSION 3.3.2)
set(OPENSSL_URL "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz")

find_package(OpenSSL ${OPENSSL_VERSION})
if(NOT OpenSSL_FOUND OR NOT TARGET OpenSSL::Crypto)
message(STATUS "OpenSSL v${OPENSSL_VERSION} package not found in the system or incomplete. Falling back to FetchContent.")
include(FetchContent)

# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

FetchContent_Declare(
OpenSSL
URL ${OPENSSL_URL}
SYSTEM
OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(openssl)

set(OpenSSL_FOUND TRUE)
set(OPENSSL_INCLUDE_DIR ${OpenSSL_SOURCE_DIR}/include)
set(OPENSSL_CRYPTO_LIBRARY ${OpenSSL_BINARY_DIR}/lib/libcrypto.a)
set(OPENSSL_SSL_LIBRARY ${OpenSSL_BINARY_DIR}/lib/libssl.a)
set(OPENSSL_LIBRARIES OpenSSL::Crypto OpenSSL::SSL)
endif()

message(STATUS "OpenSSL include dirs: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL libraries: ${OPENSSL_LIBRARIES}")

0 comments on commit 8ecd2c1

Please sign in to comment.