From 54f5aaaa68fdd8d1c1e8a343a424f668c37566b4 Mon Sep 17 00:00:00 2001 From: Sander Niemeijer Date: Tue, 30 Jul 2024 11:49:32 +0200 Subject: [PATCH] Add compile flag to allow building R extension with R>=4.3 and MSVC --- CMakeLists.txt | 2 +- CMakeModules/FindR.cmake | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7ac40520..25fc67f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/CMakeModules/FindR.cmake b/CMakeModules/FindR.cmake index e02a7ff0e..3e258da4d 100644 --- a/CMakeModules/FindR.cmake +++ b/CMakeModules/FindR.cmake @@ -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)