Skip to content

Commit

Permalink
Add compile flag to allow building R extension with R>=4.3 and MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
svniemeijer committed Jul 30, 2024
1 parent 1bd3353 commit 54f5aaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ if(HARP_BUILD_R)
target_link_libraries(Rharp harp ${CMAKE_CURRENT_BINARY_DIR}/R/R.lib)
add_dependencies(Rharp Rlib)
install(TARGETS Rharp DESTINATION ${R_PREFIX}/libs/x64 COMPONENT r)
set_target_properties(Rharp PROPERTIES COMPILE_FLAGS "-DLIBHARPDLL")
set_target_properties(Rharp PROPERTIES COMPILE_FLAGS "-DLIBHARPDLL -DR_LEGACY_RCOMPLEX")
string(REGEX REPLACE "\\.exe$" "script.exe" RSCRIPT_EXECUTABLE ${R_EXECUTABLE})
else()
target_link_libraries(Rharp harp ${R_LIBRARIES})
Expand Down
3 changes: 3 additions & 0 deletions CMakeModules/FindR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ if(R_EXECUTABLE)
set(R_INCLUDE_DIR "${RHOME}/include")
set(R_LIBRARY_DIR "${RHOME}/lib")
set(CMAKE_REQUIRED_INCLUDES ${R_INCLUDE_DIR})
# define needed for R>=4.3 with MSVC because of:
# syntax error: missing ';' before identifier 'private_data_c'
set(CMAKE_REQUIRED_FLAGS "-DR_LEGACY_RCOMPLEX")
endif(R_EXECUTABLE)

check_include_file(R.h HAVE_R_H)
Expand Down

0 comments on commit 54f5aaa

Please sign in to comment.