Normalize dir separators in CMAKE_TOOLCHAIN_FILE when forwarded to CTest

This fixes an issue where, on Windows, 'ninja test' will error out:

[0/1] Running tests...
Test project C:/dev/qt/dev/cmake-msvc-2019-amd64/qttools
CMake Warning (dev) at C:/dev/qt/dev/cmake-msvc-2019-amd64/qttools/tests/auto/cmake/CTestTestfile.cmake:7 (add_test):
  Syntax error in cmake code at

    C:/dev/qt/dev/cmake-msvc-2019-amd64/qttools/tests/auto/cmake/CTestTestfile.cmake:7

  when parsing string

    -DCMAKE_TOOLCHAIN_FILE=C:\dev\qt\dev\cmake-msvc-2019-amd64\qtbase\bin\/../lib/cmake/Qt6/qt.toolchain.cmake

  Invalid escape sequence \d

Change-Id: Ifc727e44b20b899b44c7c1398d4273d73b7519ca
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Kai Koehne 2020-11-04 12:31:39 +01:00
parent ff55b6ed48
commit 501f27b5c6

View File

@ -32,7 +32,8 @@ if (CMAKE_BUILD_TYPE)
endif()
if (CMAKE_TOOLCHAIN_FILE)
list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
file(TO_CMAKE_PATH "${CMAKE_TOOLCHAIN_FILE}" _CMAKE_TOOLCHAIN_FILE)
list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_TOOLCHAIN_FILE=${_CMAKE_TOOLCHAIN_FILE}")
endif()
if (CMAKE_VERBOSE_MAKEFILE)