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

Fix Rapidjosn CMake patching for windows #1181

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ jobs:
-DFLAMEGPU_VISUALISATION="${{ env.VISUALISATION }}"
-DFLAMEGPU_ENABLE_NVTX="ON"

# Check for bugs when cmake is reconfigured, i.e. fetch content patching
- name: Re-configure cmake
run: >
cmake . -B "${{ env.BUILD_DIR }}"

- name: Build static library
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --target flamegpu --verbose -j `nproc`
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ jobs:
-DFLAMEGPU_VISUALISATION="${{ env.VISUALISATION }}"
-DFLAMEGPU_ENABLE_NVTX="ON"

# Check for bugs when cmake is reconfigured, i.e. fetch content patching
- name: Re-configure cmake
run: >
cmake . -B "${{ env.BUILD_DIR }}"

- name: Build static library
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --config ${{ env.CONFIG }} --target flamegpu --verbose -j `nproc`
Expand Down
37 changes: 33 additions & 4 deletions cmake/dependencies/rapidjson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,47 @@ include(ExternalProject)
cmake_policy(SET CMP0079 NEW)

# a95e013b97ca6523f32da23f5095fcc9dd6067e5 is the last commit before a change which breaks our method of finding rapid json without running a cmake install first.
# but we also need to patch this to avoid a cmake >= 3.26.4 deprecation
# but we also need to patch this to avoid a cmake >= 3.26.4 deprecation, but this is handled manually post-population
FetchContent_Declare(
rapidjson
GIT_REPOSITORY /~https://github.com/Tencent/rapidjson.git
GIT_TAG a95e013b97ca6523f32da23f5095fcc9dd6067e5
GIT_PROGRESS ON
PATCH_COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/patches/rapidjson-cmake-3.5-deprecation.patch || true
# UPDATE_DISCONNECTED ON
)
FetchContent_GetProperties(rapidjson)
if(NOT rapidjson_POPULATED)
FetchContent_Populate(rapidjson)
# Manually patch Rapidjson for cmake minimum version.
# PATCH_COMMAND that works reliably on windows was problematic.
# Check if the patch is applicable
execute_process(
COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/patches/rapidjson-cmake-3.5-deprecation.patch
WORKING_DIRECTORY "${rapidjson_SOURCE_DIR}"
RESULT_VARIABLE rapidjson_patch_check_result
OUTPUT_QUIET
ERROR_QUIET
)
if (rapidjson_patch_check_result EQUAL 0)
# If applicable, apply the patch
message(CHECK_START "Patching RapidJSON")
execute_process(
COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/patches/rapidjson-cmake-3.5-deprecation.patch
WORKING_DIRECTORY "${rapidjson_SOURCE_DIR}"
RESULT_VARIABLE rapidjson_patch_result
OUTPUT_QUIET
ERROR_QUIET
)
# If the patch failed emit a Warnign but allow cmake to progress. This should not occur given the previous check.
if (rapidjson_patch_check_result EQUAL 0)
message(CHECK_PASS "done")
else()
message(CHECK_FAIL "patching failed")
endif()
unset(rapidjson_patch_result)
endif()
unset(rapidjson_patch_check_result)

# RapidJSON has custom RapidJSONConfig.cmake, generated by cmake configure/generate
execute_process(
COMMAND ${CMAKE_COMMAND} . -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF -Wno-deprecated
Expand Down Expand Up @@ -49,5 +78,5 @@ mark_as_advanced(FETCHCONTENT_SOURCE_DIR_RAPIDJSON)
mark_as_advanced(FETCHCONTENT_QUIET)
mark_as_advanced(FETCHCONTENT_BASE_DIR)
mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_RAPIDJSON)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_RAPIDJSON)
Loading