From c18deb2d811deaf40ede9a3771e1753192990f96 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 2 Jan 2018 15:20:30 -0600 Subject: [PATCH] test harness: Identify build host system in CMake to use for path separator. Before, would guess incorrectly if the CMake source tree was specified via a relative path (since then the path would not start with /). Now, directly asks CMake if building on Windows or something else, and sets a define. --- test/CMakeLists.txt | 4 ++++ test/harness.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 73d04406..db812bfa 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,6 +7,10 @@ foreach(pkg_config_lib CAIRO) link_directories(${${pkg_config_lib}_LIBRARY_DIRS}) endforeach() +if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") + add_definitions(-DTEST_BUILD_ON_WINDOWS) +endif() + # test suite set(testsuite_SOURCES diff --git a/test/harness.cpp b/test/harness.cpp index 522213df..ced5d6ae 100644 --- a/test/harness.cpp +++ b/test/harness.cpp @@ -21,9 +21,12 @@ namespace Platform { } } -// The paths in __FILE__ are from the build system, but defined(WIN32) returns -// the value for the host system. -#define BUILD_PATH_SEP (__FILE__[0]=='/' ? '/' : '\\') + +#ifdef TEST_BUILD_ON_WINDOWS +static char BUILD_PATH_SEP = '\\'; +#else +static char BUILD_PATH_SEP = '/'; +#endif static std::string BuildRoot() { static std::string rootDir;