Skip to content

Commit

Permalink
Added PACKAGE_MODE option
Browse files Browse the repository at this point in the history
1. Allow to build against miniupnpc dynamically
2. Use dynamic boost libraries
3. Make optimization CFLAGS optional
  • Loading branch information
nE0sIghT committed Jan 5, 2022
1 parent e4c9c29 commit c4f1d57
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.0)

project(Sunshine)

option(PACKAGE_MODE "Use external dependencies when possible" OFF)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

if(WIN32)
Expand All @@ -14,16 +16,24 @@ endif()
add_subdirectory(third-party/moonlight-common-c/enet)
add_subdirectory(third-party/Simple-Web-Server)

set(UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc")
set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc")
set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc")
add_subdirectory(third-party/miniupnp/miniupnpc)
include_directories(third-party/miniupnp)
if(NOT PACKAGE_MODE)
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc")
set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc")
set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc")
add_subdirectory(third-party/miniupnp/miniupnpc)
include_directories(third-party/miniupnp)
else(NOT PACKAGE_MODE)
find_library(MINIUPNPC miniupnpc REQUIRED)
message(STATUS "Found miniupnpc: ${MINIUPNPC}")
endif(NOT PACKAGE_MODE)

find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
set(Boost_USE_STATIC_LIBS ON)

if(NOT PACKAGE_MODE)
set(Boost_USE_STATIC_LIBS ON)
endif(NOT PACKAGE_MODE)
find_package(Boost COMPONENTS log filesystem REQUIRED)

list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
Expand Down Expand Up @@ -327,7 +337,9 @@ if("${BUILD_TYPE}" STREQUAL "XDEBUG")
endif()
else()
add_definitions(-DNDEBUG)
list(APPEND SUNSHINE_COMPILE_OPTIONS -O3)
if(NOT PACKAGE_MODE)
list(APPEND SUNSHINE_COMPILE_OPTIONS -O3)
endif(NOT PACKAGE_MODE)
endif()

if(NOT SUNSHINE_ASSETS_DIR)
Expand All @@ -346,7 +358,6 @@ list(APPEND CBS_EXTERNAL_LIBRARIES
cbs)

list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
libminiupnpc-static
${CBS_EXTERNAL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
stdc++fs
Expand All @@ -357,6 +368,14 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${OPENSSL_LIBRARIES}
${PLATFORM_LIBRARIES})

if(NOT PACKAGE_MODE)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
libminiupnpc-static)
else(NOT PACKAGE_MODE)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${MINIUPNPC})
endif(NOT PACKAGE_MODE)

if (NOT WIN32)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES Boost::log)
endif()
Expand Down

0 comments on commit c4f1d57

Please sign in to comment.