Repository navigation
Fix RSTUDIO_USE_SYSTEM_DEPENDENCIES - #19239
Conversation
When `RSTUDIO_USE_SYSTEM_DEPENDENCIES` is set all dependencies must be found. `Hunspell` doesn't provide CMake targets and Rstudio uses the sources directly. Websocket++ doesn't provide a CMake config either Add a flag to always download those and fix the names for RapidJSON and ZLIB find commands
This allows overriding the location by the caller
gtritchie
left a comment
There was a problem hiding this comment.
Thanks for working on this. As it stands, a configure with RSTUDIO_USE_SYSTEM_DEPENDENCIES=ON still fails. The new REQUIRED flag is never read, and several other dependencies (dtl, utfcpp, websocketpp, gtest) hit the same kind of find_package failure. Details are inline. I checked package names and versions against the upstream sources at the revisions pinned in this file.
The broader issue: every CUSTOM dependency (DTL, HUNSPELL, RAPIDJSON, UTFCPP, WEBSOCKETPP, ZLIB) builds its rstudio-* target from ${PREFIX}_SOURCE_DIR, and only the fetch path sets that. A system package therefore can't satisfy any of them as written, whatever name find_package is given. Handling this once in fetch() (L184) would cover all of them, rather than tagging deps one at a time. For example: always fetch CUSTOM deps, or have the system path populate the include dirs. See the comment on L366.
gtritchie
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. ALWAYS_FETCH is now applied, and the GTest and utf8cpp names plus the imported targets look right. I checked utf8cpp's exported include dir (include/utf8cpp, so <utf8.h> resolves) and its SameMajorVersion compatibility, and that the alias resolves from src/cpp/core. The Windows system-zlib issue is deferred to #19245.
One new problem: the zlib include-dir change at L451 breaks the default Windows build on a fresh configure (inline). Plus three small things inline: a RapidJSON gap with the 1.1.0 release, a stray-space typo, and indentation.
…` and show error when it conflicts with ALWAYS_FETCH This allows to enable all SYSTEM dependencies and select some that shall NOT be used which catches later additions.
|
Thanks for the review. Done all changes in the web editor, so should be fine but couldn't test them yet. I also addressed your earlier comment about adding an error when |
RapidJSON 1.1.0's config sets RAPIDJSON_INCLUDE_DIRS and exports no target. find_package() runs inside fetch(), so the variable was gone by the time rstudio-rapidjson checked it, and the target fell back to "/include". Addresses rstudio#15965.
dtl, Hunspell and websocketpp can never come from the system, so with RSTUDIO_USE_SYSTEM_DEPENDENCIES=ON the warning fired on every configure for expected behavior. Addresses rstudio#15965.
|
Thanks for the quick iterations. Since maintainer edits are enabled, I've pushed the remaining changes to your branch rather than send another round:
I've also linked this PR to #15965 (partially, since Hunspell is fetched rather than taken from the system, so that issue stays open) and #15996. The pre-existing Windows system-zlib problem is tracked in #19245. We'll approve once CI passes. Please take a look at the changes and make sure it looks okay to you as well! |
With RSTUDIO_USE_SYSTEM_DEPENDENCIES=ON no 'gtest' target exists, so the test targets fell back to add_subdirectory() on src/cpp/tests/cpp/tests/vendor/gtest, which is not in the repo, and configure failed. Addresses rstudio#15965.
libgit2's installed config exports its target under the libgit2:: namespace, so with RSTUDIO_USE_SYSTEM_DEPENDENCIES=ON rsession's 'libgit2package' became -llibgit2package and failed to link. Addresses rstudio#15965.
The entry said configuring with RSTUDIO_USE_SYSTEM_DEPENDENCIES=ON was fixed outright; Windows system zlib is still broken (rstudio#19245). List the dependencies that were fixed instead. Addresses rstudio#15965.
|
A few more commits on top, for two problems that come up after the ones fixed here when building with
Both aliases are no-ops when the dependencies are fetched. Same plan as before: we'll approve once CI passes. |
gtritchie
left a comment
There was a problem hiding this comment.
Approving, but will ping another reviewer to give it a fresh once-over before we merge.
kevinushey
left a comment
There was a problem hiding this comment.
Thanks for working through this! A few issues inline. The first two (Windows zlib, GTest version) would still break -DRSTUDIO_USE_SYSTEM_DEPENDENCIES=ON for some setups; the rest are smaller.
One more outside the diff: the Windows hunspell include at L578 uses HUNSPELL_PREFIX_DIR, which is never defined, so it resolves to /msvc. That's pre-existing (it's on main too) and hunspell builds without it today, but since hunspell is now always fetched it'd be a good moment to change it to HUNSPELL_SOURCE_DIR.
gtritchie
left a comment
There was a problem hiding this comment.
Thanks, the libgit2 fix works: configure now passes. The Linux and macOS builds then fail at:
ninja: error: 'src/cpp/ext/rstudio-zlib.lib', needed by 'src/cpp/session/rsession',
missing and no known rule to make it
This comes from 104bd51 removing PLATFORMS WIN32 from the zlib dependency: zlib is now fetched and built on every platform, using the Windows file name at L483. Beyond the file name, though, we want default Linux and macOS builds to keep linking the system zlib, as they do on main, rather than a bundled static copy. Before that commit CI found /usr/lib/x86_64-linux-gnu/libz.so; now it builds zlib 1.3.1 itself.
So rather than fixing the name, could you make the fetch Windows-only again while keeping rstudio-zlib available everywhere for core (from 5c4f9f0)?
- Put
PLATFORMS WIN32back ondependency(ZLIB ...). - Find the system zlib in the not-fetched branch, since
fetch()now skips zlib entirely off Windows:
if(NOT ZLIB_FETCHED)
if(NOT TARGET ZLIB::ZLIB)
find_package(ZLIB REQUIRED GLOBAL)
endif()
add_library(rstudio-zlib ALIAS ZLIB::ZLIB)
else()On macOS this gives no zlib fetch, and rstudio-zlib resolves to the system libz. With the fetch Windows-only again, the .lib name at L483 and the "Windows only" comments at L476 and L490 are correct as they are.
|
Another idea:
That would keep the handling uniform. Btw: It might be good to switch to namespace targets, i.e. |
|
Thanks. Right, core needs zlib on Unix too ( Routing zlib through the same Main's core uses So the uniform approach would need a zlib-specific exception to the version in On namespaced targets: agreed it's nicer. A missing |
This reverts commit 104bd51.
It is only fetched on WIN32 and conditions at that point might be confusing given the far-away usage. So add it back here.
True, that might be undesirable if any zlib version is fine on UNIX. |
|
Okay, I think we're close. I've merged your other PR so please merge main into this one again and we'll get another CI run. |
|
Done, diff is much smaller despite the many commits. I can rebase instead if desired to squash/remove the reverts, but might be good too to have the history. One more thing I noticed when verifying the diff: I'd remove the |
|
We squash when we merge PRs so don't worry about the commit history. |
gtritchie
left a comment
There was a problem hiding this comment.
Thanks for the merge. The merge commit (f608e90) dropped one line in fetch(), though, and all four builds now fail at configure:
CMake Error at src/cpp/ext/CMakeLists.txt:568 (target_include_directories):
Cannot specify include directories for target "libgit2package" which is not
built by this project.
Before the merge there were two lines here:
set(${_PREFIX}_FETCHED ${do_fetch})
set(${_PREFIX}_FETCHED ${do_fetch} PARENT_SCOPE)Only the PARENT_SCOPE one is left. That doesn't set the variable inside the function itself, so the if(${_PREFIX}_FETCHED) check in the second loop (L240) is false for every dependency and nothing is fetched. Could you add the first line back? Removing the duplicate fetch(GTest GTEST) block in the same merge was right; keep that.
On moving fetch(ZLIB ZLIB) into the if(WIN32) block and dropping PLATFORMS: either way works. PLATFORMS is how dependency() is documented to limit a dependency to some platforms, and the if(WIN32) around the target setup is needed regardless, so we'd leave it as it is.
gtritchie
left a comment
There was a problem hiding this comment.
LGTM! Thanks for all your work on this. I'll merge once CI passes.
kevinushey
left a comment
There was a problem hiding this comment.
Reviewed 45b4c3e. Thanks for working through the dependency handling. I found two remaining issues, detailed inline: mixed-case RapidJSON include directories are lost across fetch(), and switching an existing Windows build to system zlib retains the bundled-library cache entries.
Both are reproduced with focused CMake checks. A Windows compile-and-run check using this revision's bundled libgit2, zlib, RapidJSON, and utf8cpp configuration passed, as did a clean build using the same system-zlib installation that fails after switching modes. Validation used CMake 4.2 and MSVC 19.51; I did not run a full RStudio build.
Configs from RapidJSON snapshots between 2017 and 2020 set only the mixed-case variable and export no target, so the mixed-case branch in the rstudio-rapidjson setup never saw it and configure failed.
|
Unfortunately we're about to hit code freeze for the 2026.11 release, so this needs to wait until we've branched for that release before we merge this PR (i.e. Monday at the soonest). So close! |
Intent
When
RSTUDIO_USE_SYSTEM_DEPENDENCIESis set all dependencies must be found.Hunspelldoesn't provide CMake targets and Rstudio uses the sources directly. Websocket++ doesn't provide a CMake config eitherApproach
Add a flag to always download those and fix the names for RapidJSON and ZLIB find commands
Automated Tests
If desired a CI job could be added
Addresses #15965 (partially; see also #15996).