mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
CMakeLists.txt: make discord-rpc and google benchmark optional (#10208)
For a package maintainer, it should be possible to disable the support for discord-rpc and google benchmark, as it currently always includes them, when the library if found.
This commit is contained in:
committed by
Michał Janiszewski
parent
9b499ea239
commit
fef1906d0d
@@ -42,6 +42,8 @@ CMAKE_DEPENDENT_OPTION(DOWNLOAD_REPLAYS "Download replays during installation."
|
|||||||
option(STATIC "Create a static build.")
|
option(STATIC "Create a static build.")
|
||||||
option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.")
|
option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.")
|
||||||
|
|
||||||
|
option(DISABLE_DISCORD_RPC "Disable Discord-RPC support." OFF)
|
||||||
|
option(DISABLE_GOOGLE_BENCHMARK "Disable Google Benchmarks support." OFF)
|
||||||
option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
|
option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
|
||||||
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
|
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
|
||||||
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
|
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
|
||||||
@@ -125,17 +127,19 @@ if (CXX_WARN_SUGGEST_FINAL_METHODS)
|
|||||||
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
if (NOT DISABLE_DISCORD_RPC)
|
||||||
# Don't build discord's examples, some of which are in C and do not honour
|
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
||||||
# the flags we set for C++. Also we don't use the provided examples.
|
# Don't build discord's examples, some of which are in C and do not honour
|
||||||
set(BUILD_EXAMPLES OFF CACHE BOOL "Build example apps")
|
# the flags we set for C++. Also we don't use the provided examples.
|
||||||
add_subdirectory("${ROOT_DIR}/discord-rpc")
|
set(BUILD_EXAMPLES OFF CACHE BOOL "Build example apps")
|
||||||
add_definitions(-D__ENABLE_DISCORD__)
|
add_subdirectory("${ROOT_DIR}/discord-rpc")
|
||||||
include_directories("${ROOT_DIR}/discord-rpc/include")
|
add_definitions(-D__ENABLE_DISCORD__)
|
||||||
set(HAVE_DISCORD_RPC TRUE)
|
include_directories("${ROOT_DIR}/discord-rpc/include")
|
||||||
message("Building with discord-rpc support")
|
set(HAVE_DISCORD_RPC TRUE)
|
||||||
else()
|
message("Building with discord-rpc support")
|
||||||
message("No discord-rpc detected, to enable clone discord-rpc to root directory: ${ROOT_DIR}")
|
else()
|
||||||
|
message("No discord-rpc detected, to enable clone discord-rpc to root directory: ${ROOT_DIR}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Copied from https://github.com/opencv/opencv/blob/dcdd6af5a856826fe62c95322145731e702e54c5/cmake/OpenCVDetectCXXCompiler.cmake#L63-L70
|
# Copied from https://github.com/opencv/opencv/blob/dcdd6af5a856826fe62c95322145731e702e54c5/cmake/OpenCVDetectCXXCompiler.cmake#L63-L70
|
||||||
|
|||||||
@@ -73,14 +73,16 @@ if (NOT DISABLE_TTF)
|
|||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
find_package(benchmark 1.4 QUIET)
|
if (NOT DISABLE_GOOGLE_BENCHMARK)
|
||||||
if (benchmark_FOUND)
|
find_package(benchmark 1.4 QUIET)
|
||||||
message("Found Google benchmark, enabling support")
|
if (benchmark_FOUND)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS USE_BENCHMARK)
|
message("Found Google benchmark, enabling support")
|
||||||
target_link_libraries(${PROJECT_NAME} benchmark::benchmark)
|
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS USE_BENCHMARK)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${benchmark_INCLUDE_DIRS})
|
target_link_libraries(${PROJECT_NAME} benchmark::benchmark)
|
||||||
else ()
|
target_include_directories(${PROJECT_NAME} PRIVATE ${benchmark_INCLUDE_DIRS})
|
||||||
message("Google benchmark not found, disabling support")
|
else ()
|
||||||
|
message("Google benchmark not found, disabling support")
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Third party libraries
|
# Third party libraries
|
||||||
|
|||||||
Reference in New Issue
Block a user