diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index d194c455eaaaa..7e98db8b154d2 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -921,11 +921,18 @@ set(EP_COMMON_TOOLCHAIN "-DCMAKE_C_COMPILER=${EP_C_COMPILER}" "-DCMAKE_CXX_COMPILER=${EP_CXX_COMPILER}") if(CMAKE_AR) - list(APPEND EP_COMMON_TOOLCHAIN -DCMAKE_AR=${CMAKE_AR}) + # Ensure using absolute path. + find_program(EP_CMAKE_AR ${CMAKE_AR} REQUIRED) + list(APPEND EP_COMMON_TOOLCHAIN -DCMAKE_AR=${EP_CMAKE_AR}) endif() -if(CMAKE_RANLIB) - list(APPEND EP_COMMON_TOOLCHAIN -DCMAKE_RANLIB=${CMAKE_RANLIB}) +# RANLIB isn't used for MSVC +if(NOT MSVC) + if(CMAKE_RANLIB) + # Ensure using absolute path. + find_program(EP_CMAKE_RANLIB ${CMAKE_RANLIB} REQUIRED) + list(APPEND EP_COMMON_TOOLCHAIN -DCMAKE_RANLIB=${EP_CMAKE_RANLIB}) + endif() endif() # External projects are still able to override the following declarations.