Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Windows to replace backslashes in paths #2091

Closed

Conversation

nicolaspopravka
Copy link
Contributor

Description of Change(s)

In the build script, replace backslashes in filepaths with forward slashes, before evoking cmake with -D argument.

Fixes Issue(s)

  • On Windows, downstream projects (i.e. those with find_package(pxr CONFIG REQUIRED) calls in their CMakeLists.txt files) could fail to build with the following error:
>  cmake -DCMAKE_PREFIX_PATH="C:\Users\nicolas.popravka\AppData\Local\Programs\USD" ...
...
CMake Error at C:/Users/nicolas.popravka/AppData/Local/Programs/USD/pxrConfig.cmake:26 (if):
  Syntax error in cmake code at

    C:/Users/nicolas.popravka/AppData/Local/Programs/USD/pxrConfig.cmake:26

  when parsing string

    C:\Users\nicolas.popravka\AppData\Local\Programs\Python\Python39\python.exe

  Invalid character escape '\U'.
Call Stack (most recent call first):
  CMakeLists.txt:17 (find_package)


-- Configuring incomplete, errors occurred!

This is fixed with the proposed change.

  • I have verified that all unit tests pass with the proposed changes
  • I have submitted a signed Contributor License Agreement

@spitzak
Copy link

spitzak commented Nov 15, 2022

Maybe GetPythonInfo() should be fixed instead.

@sunyab
Copy link
Contributor

sunyab commented Nov 19, 2022

Filed as internal issue #USD-7776

@sunyab
Copy link
Contributor

sunyab commented Nov 28, 2022

Hello, I just wanted to mention that I am currently testing an alternate fix that modifies pxrConfig.cmake itself. This would fix the issue for anyone building via build_usd.py as well as users running CMake and building manually. If all goes well, this fix should be available with the next push to dev.

pixar-oss pushed a commit that referenced this pull request Dec 9, 2022
- Fix broken checks for empty strings. In CMake all strings
  except for certain special constants evaluate to False.
  This caused the various Python arguments to not be set
  properly.

- Use bracket arguments for file paths to avoid string
  parsing issues. On Windows, paths with backslashes
  could cause string parsing errors since they would
  mistakenly be interpreted as containing invalid escape
  sequences. CMake does not evaluate escape sequences in
  bracket arguments, sidestepping this problem.

Fixes #2091

(Internal change: 2256678)
@sunyab
Copy link
Contributor

sunyab commented Dec 9, 2022

The fix I mentioned landed in the dev branch as a7fd465, so I'm going to close this out. Please reopen or file a new issue if this doesn't seem to fix the issue you ran into. Thanks!

@sunyab sunyab closed this Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants