Update FindR to detect R.dll on windows.#2542
Merged
blowekamp merged 1 commit intoSimpleITK:mainfrom Mar 26, 2026
Merged
Conversation
240cbcf to
9ca0d4b
Compare
Closed
Improve finding R executables with registry keys. Fix finding and using the R.dll for linking with mingw on windows. Co-authored-by: Bradley Lowekamp <[email protected]>
9ca0d4b to
6e7e35f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s FindR.cmake module to improve how R is discovered on Windows (via registry hints) and to better support MinGW/Rtools by allowing detection/linking against R.dll.
Changes:
- Add Windows registry-based
HINTSfor locatingR/Rscript. - Add MinGW-specific logic to allow
find_library()to locateR.dllby temporarily extendingCMAKE_FIND_LIBRARY_SUFFIXES. - Adjust which R variables are treated as required for
find_package_handle_standard_args().
Comments suppressed due to low confidence (1)
CMake/FindR.cmake:154
LINUXis not a standard CMake platform variable and it’s not defined anywhere else in this repo. As written,if(NOT LINUX)will evaluate true on Linux too, makingR_LIBRARIES/R_LIBRARY_BASErequired even on Linux—contradicting the comment and likely breaking configurations wherelibR.sois absent. Use a reliable check likeif(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")(orif(NOT (UNIX AND NOT APPLE))) instead.
if(NOT LINUX)
# On Linux the libR.so is sometimes not available; on all other platforms
# a link error results if the library is not found.
list(
APPEND
_REQUIRED_R_VARIABLES
R_LIBRARIES
R_LIBRARY_BASE
)
endif()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zivy
approved these changes
Mar 26, 2026
| DOC "R library (example libR.a, libR.dylib, R.dll, etc.)." | ||
| ) | ||
|
|
||
| if(MINGW) |
Member
There was a problem hiding this comment.
Possibly add a comment, just because this is a bit far in the code from the documentation above:
# Removing the .dll from list, see above.
dave3d
approved these changes
Mar 26, 2026
This was referenced Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve finding R executables with registry keys. Fix finding and using the R.dll for linking with mingw on windows.