CMake Windows path normalization (#47702)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47702

Use `file(TO_CMAKE_PATH` to normalize paths, and normalizing `input_SRC` as it's already a CMake path.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D66101321

fbshipit-source-id: e81af40551d2777901f9c7cf9a4175f2bce76ec8
This commit is contained in:
Blake Friedman
2024-11-19 05:33:45 -08:00
committed by Facebook GitHub Bot
parent c3091ccfed
commit 13bc4a2a43
@@ -31,10 +31,8 @@ if(CCACHE_FOUND)
endif(CCACHE_FOUND)
set(BUILD_DIR ${PROJECT_BUILD_DIR})
if(CMAKE_HOST_WIN32)
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR})
string(REPLACE "\\" "/" REACT_ANDROID_DIR ${REACT_ANDROID_DIR})
endif()
file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR)
file(TO_CMAKE_PATH "${REACT_ANDROID_DIR}" REACT_ANDROID_DIR)
if (PROJECT_ROOT_DIR)
# This empty `if` is just to silence a CMake warning and make sure the `PROJECT_ROOT_DIR`
@@ -45,11 +43,6 @@ file(GLOB input_SRC CONFIGURE_DEPENDS
${REACT_ANDROID_DIR}/cmake-utils/default-app-setup/*.cpp
${BUILD_DIR}/generated/autolinking/src/main/jni/*.cpp)
# Ensure that `input_SRC` paths use forward slashes
foreach(path IN LISTS input_SRC)
string(REPLACE "\\" "/" path "${path}")
endforeach()
add_library(${CMAKE_PROJECT_NAME} SHARED ${input_SRC})
target_include_directories(${CMAKE_PROJECT_NAME}