Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ endif(CCACHE_FOUND)

set(BUILD_DIR ${PROJECT_BUILD_DIR})
if(CMAKE_HOST_WIN32)
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR})
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR})
string(REPLACE "\\" "/" REACT_ANDROID_DIR ${REACT_ANDROID_DIR})
Comment on lines +35 to +36
Copy link
Contributor Author

@FouadMagdy01 FouadMagdy01 Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Problem: The variables REACT_ANDROID_DIR and BUILD_DIR might also contain backslashes if they are set on a Windows system. These backslashes need to be replaced to avoid similar issues.

  • Solution: Check if the script is running on Windows using if(CMAKE_HOST_WIN32). If it is, replace backslashes with forward slashes for these variables as well:

endif()

if (PROJECT_ROOT_DIR)
Expand All @@ -44,6 +45,11 @@ 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()

Comment on lines +48 to +52
Copy link
Contributor Author

@FouadMagdy01 FouadMagdy01 Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Problem: On Windows, backslashes () in file paths are often interpreted by CMake as escape characters, which can lead to invalid sequences like \S. CMake and many other tools can understand forward slashes (/) as directory separators, even on Windows.

  • Solution: Use string(REPLACE "\" "/" path "${path}") to convert all backslashes in the input_SRC file paths to forward slashes. This ensures CMake correctly interprets the paths without treating them as escape sequences.

add_library(${CMAKE_PROJECT_NAME} SHARED ${input_SRC})

target_include_directories(${CMAKE_PROJECT_NAME}
Expand Down
Loading