question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] CMakeToolchain user_toolchain invalid escape character on Windows

See original GitHub issue

Environment Details (include every applicable attribute)

  • Operating System+version: Windows servercore 2019
  • Compiler+version: MSVC 192
  • Conan version: 1.45.0
  • Python version: 3.10.2

Steps to reproduce (Include if Applicable)

Create a package for providing a CMake toolchain file via tool_requires and enable short_paths on Windows. When building a test package on Windows the following error occurs, which looks like it could be fixed by using forward slashes in the CMake toolchain instead of backslashes when including the user_toolchain.

Logs (Executed commands with output) (Include/Attach if Applicable)

my-conan-toolchain/c8783856@my-conan-remote/testing (test package): Calling build()
my-conan-toolchain/c8783856@my-conan-remote/testing (test package): CMake command: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:/builds/components/conan-toolchain/test_package/build/79d6417e7f7125abb0ee5e356ea18ea032664329/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/builds/components/conan-toolchain/test_package/build/79d6417e7f7125abb0ee5e356ea18ea032664329/package" "C:\builds\components\conan-toolchain\test_package"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.9
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Using Conan toolchain: C:/builds/components/conan-toolchain/test_package/build/79d6417e7f7125abb0ee5e356ea18ea032664329/conan_toolchain.cmake.
CMake Error at build/79d6417e7f7125abb0ee5e356ea18ea032664329/conan_toolchain.cmake:19 (include):
  Syntax error in cmake code at
    C:/builds/components/conan-toolchain/test_package/build/79d6417e7f7125abb0ee5e356ea18ea032664329/conan_toolchain.cmake:19
  when parsing string
    C:\.conan\193a6c\1\conan_toolchain.cmake
  Invalid character escape '\1'.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:124 (include)
  CMakeLists.txt:3 (project)
CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, Feb 9, 2022

Oh, that makes sense indeed, if you are directly providing unsanitized paths, then there is little that Conan can do (the template could try to do it too, but the template can also be overriden, so probably not worth the effort). As the solution is straightforward and is reasonable, I think we can close this, thanks for the feedback!

0reactions
SpaceImcommented, Dec 7, 2022

@ericLemanissier In all CCI recipes migrated to conan v2, I add .replace("\\", "/") to all paths injected into variables of CMakeToolchain, not sure it’s worth to expose a conan helper for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid character escape \P error when path to compiler is ...
The compiler path passed to CMake is not converted to forward slashes: set(CMAKE_C_COMPILER "C:\Program Files\LLVM/bin/clang-cl.exe").
Read more >
Invalid character escape '\U' - PlatformIO Community
For temp solution, i just change slashes in Private.txt. Example: Before: SET(CMAKE_C_COMPILER “C:\Users\Ivan.platformio\packages\toolchain- ...
Read more >
SES Nordic Edition escaping path characters, causing cmake and ...
I installed nRF Connect SDK v1.6.0 and SES Nordic Edition through the nRF Connect toolchain manager (Windows 10). I'm finding that I can't...
Read more >
[CMake] [Dev] CMake 2.5 tool chain support example
source" > > It fails with: > > -- Check size of void* > CMake Error: Invalid escape sequence \f > Syntax error...
Read more >
Support MSVC toolchain with CMake via NMake generator
It would be great to be able to compile with visual compiler instead of mingw for windows users. Attachments 10.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found