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.
pull/416/head
Ryan Pavlik 2018-01-02 15:20:30 -06:00 committed by whitequark
parent 62aba398f7
commit c18deb2d81
2 changed files with 10 additions and 3 deletions

View File

@ -7,6 +7,10 @@ foreach(pkg_config_lib CAIRO)
link_directories(${${pkg_config_lib}_LIBRARY_DIRS}) link_directories(${${pkg_config_lib}_LIBRARY_DIRS})
endforeach() endforeach()
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
add_definitions(-DTEST_BUILD_ON_WINDOWS)
endif()
# test suite # test suite
set(testsuite_SOURCES set(testsuite_SOURCES

View File

@ -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. #ifdef TEST_BUILD_ON_WINDOWS
#define BUILD_PATH_SEP (__FILE__[0]=='/' ? '/' : '\\') static char BUILD_PATH_SEP = '\\';
#else
static char BUILD_PATH_SEP = '/';
#endif
static std::string BuildRoot() { static std::string BuildRoot() {
static std::string rootDir; static std::string rootDir;