Skip to content

Commit

Permalink
Compatible to cmake 3.14 (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coldwings committed Apr 18, 2024
1 parent ca267b1 commit 87ffa0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(PHOTON_FSTACK_SOURCE "" CACHE STRING "")
set(PHOTON_E2FS_SOURCE "" CACHE STRING "")
set(PHOTON_GFLAGS_SOURCE "https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz" CACHE STRING "")
set(PHOTON_GOOGLETEST_SOURCE "https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz" CACHE STRING "")
set(PHOTON_RAPIDJSON_SOURCE "https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.zip" CACHE STRING "")
set(PHOTON_RAPIDJSON_GIT "https://github.com/Tencent/rapidjson.git" CACHE STRING "")
set(PHOTON_RAPIDXML_SOURCE "https://sourceforge.net/projects/rapidxml/files/rapidxml/rapidxml%201.13/rapidxml-1.13.zip/download" CACHE STRING "")
set(PHOTON_RAPIDYAML_SOURCE "https://github.com/biojppm/rapidyaml/releases/download/v0.5.0/rapidyaml-0.5.0.hpp" CACHE STRING "")
set(PHOTON_CPP_REDIS_SOURCE "https://github.com/cpp-redis/cpp_redis/archive/refs/tags/4.3.1.tar.gz" CACHE STRING "")
Expand Down
20 changes: 14 additions & 6 deletions ecosystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

include(FetchContent)

if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
# set DOWNLOAD_EXTRACT_TIMESTAMP ON cmake 3.24 or above
cmake_policy(SET CMP0135 NEW)
endif()

# Rapidjson
FetchContent_Declare(
rapidjson
URL ${PHOTON_RAPIDJSON_SOURCE}
URL_HASH SHA256=8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/patches/rapidjson.patch
DOWNLOAD_EXTRACT_TIMESTAMP ON
GIT_REPOSITORY ${PHOTON_RAPIDJSON_GIT}
GIT_TAG v1.1.0
PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/patches/rapidjson.patch
UPDATE_DISCONNECTED 1)
# Pre-set rapidjson build option, prevent building docs, examples and tests
set(RAPIDJSON_BUILD_DOC OFF CACHE BOOL "Build rapidjson documentation.")
Expand All @@ -24,7 +28,6 @@ FetchContent_Declare(
URL ${PHOTON_RAPIDXML_SOURCE}
URL_HASH
SHA256=c3f0b886374981bb20fabcf323d755db4be6dba42064599481da64a85f5b3571
DOWNLOAD_EXTRACT_TIMESTAMP ON
UPDATE_DISCONNECTED 1)
FetchContent_MakeAvailable(rapidxml)
message(STATUS "Rapidxml source dir: ${rapidxml_SOURCE_DIR}")
Expand All @@ -39,6 +42,12 @@ FetchContent_Declare(
DOWNLOAD_NO_EXTRACT 1
UPDATE_DISCONNECTED 1)
FetchContent_MakeAvailable(rapidyaml)
if (CMAKE_VERSION VERSION_LESS "3.18.0")
# Before 3.18, CMake will not copy single header file to src directory
file(COPY
${FETCHCONTENT_BASE_DIR}/rapidyaml-subbuild/rapidyaml-populate-prefix/src/rapidyaml-0.5.0.hpp
DESTINATION ${rapidyaml_SOURCE_DIR})
endif()
message(STATUS "Rapidyaml source dir: ${rapidyaml_SOURCE_DIR}")

# cpp-redis
Expand All @@ -47,7 +56,6 @@ FetchContent_Declare(
URL ${PHOTON_CPP_REDIS_SOURCE}
URL_HASH
SHA256=3859289d8254685fc775bda73de03dad27df923423b8ceb375b02d036c03b02f
DOWNLOAD_EXTRACT_TIMESTAMP ON
UPDATE_DISCONNECTED 1)
# uses only a simple header, so do not add sub directory to avoid unnecessary build
# do not use FetchContent_MakeAvailable, just populate it.
Expand Down

0 comments on commit 87ffa0b

Please sign in to comment.