Skip to content

Commit af853f2

Browse files
author
Andrew Savonichev
committed
Fix backslashes again
Signed-off-by: Andrew Savonichev <[email protected]>
1 parent 213d9cf commit af853f2

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

sycl/unittests/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ function(add_sycl_unittest test_dirname)
99
# Enable exception handling for these unit tests
1010
set(LLVM_REQUIRES_EH 1)
1111

12+
if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug")
13+
set(sycl_lib "sycld")
14+
else()
15+
set(sycl_lib "sycl")
16+
endif()
17+
1218
add_unittest(SYCLUnitTests ${test_dirname} ${ARGN})
1319
target_link_libraries(${test_dirname}
1420
PRIVATE
15-
sycl
21+
${sycl_lib}
1622
LLVMTestingSupport
1723
OpenCL-Headers
1824
)

sycl/unittests/misc/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
set(CMAKE_CXX_EXTENSIONS OFF)
2-
3-
set(sycl_lib_dir $<SHELL_PATH:$<TARGET_FILE_DIR:sycl>>)
1+
set(sycl_lib_dir $<TARGET_FILE_DIR:sycl>)
42
add_definitions(-DSYCL_LIB_DIR="${sycl_lib_dir}")
53
add_sycl_unittest(MiscTests
64
OsUtils.cpp

sycl/unittests/misc/OsUtils.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,29 @@
99
#include <CL/sycl/detail/os_util.hpp>
1010
#include <gtest/gtest.h>
1111

12-
#ifdef __unix__
12+
#ifdef _WIN32
13+
/// Compare for string equality, but ignore difference between forward slash (/)
14+
/// and backward slash (\).
15+
///
16+
/// This difference can be tricky to avoid, because CMake operates with forward
17+
/// slashes even on Windows, and it can be problematic to convert them when
18+
/// CMake generator expressions are involved. It's easier to handle slashes
19+
/// here in the test itself.
20+
bool isSameDir(const char* LHS, const char* RHS) {
21+
char L = 0, R = 0;
22+
do {
23+
L = *LHS++;
24+
R = *RHS++;
25+
if (L != R) {
26+
if (!((L == '\\' || L == '/') && (R == '\\' || R == '/'))) {
27+
return false;
28+
}
29+
}
30+
} while (L != '\0' && R != '\0');
31+
bool SameLen = (L == '\0' && R == '\0');
32+
return SameLen;
33+
}
34+
#else
1335
#include <sys/stat.h>
1436
#include <stdlib.h>
1537
/// Check with respect to symbolic links
@@ -27,10 +49,6 @@ bool isSameDir(const char* LHS, const char* RHS) {
2749
ino_t InodeRHS = StatBuf.st_ino;
2850
return InodeRHS == InodeLHS;
2951
}
30-
#else
31-
bool isSameDir(const char* LHS, const char* RHS) {
32-
return 0 == strcmp(LHS, RHS);
33-
}
3452
#endif
3553

3654
class OsUtilsTest : public ::testing::Test {

0 commit comments

Comments
 (0)