Skip to content

Commit

Permalink
Fix Rapidjosn CMake patching for windows (#1181)
Browse files Browse the repository at this point in the history
* Add re-configuration to CI to check for fetch content apply bugs

* RapidJSON: Manually apply cmake version patch instead of using PATCH_COMMAND

PATCH_COMMAND was problematic on windows, preventing re-configuration.

* Trim trailing whitespace
  • Loading branch information
ptheywood authored Feb 2, 2024
1 parent 25a3716 commit 6dd19b1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
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)

0 comments on commit 6dd19b1

Please sign in to comment.