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

Complete quoting for parameters of some CMake commands #24

Closed
elfring opened this issue Oct 27, 2013 · 2 comments
Closed

Complete quoting for parameters of some CMake commands #24

elfring opened this issue Oct 27, 2013 · 2 comments
Assignees

Comments

@elfring
Copy link

elfring commented Oct 27, 2013

Some parameters (like "${CMAKE_INSTALL_PREFIX}/bin" and "${CMAKE_CURRENT_SOURCE_DIR}") are passed to CMake commands in your build scripts without enclosing them by quotation marks. I see that these places will result in build difficulties if the contents of the used variables will contain special characters like spaces.

I would recommend to apply advices from a Wiki article.

@ghost ghost assigned mosra Oct 27, 2013
@mosra
Copy link
Owner

mosra commented Oct 28, 2013

Sorry, but can't reproduce the issue. Actually I did start to quote every variable which might contain a path, but soon realized that none of that is necessary. I tried doing build, running tests and installing in path with spaces and it ran flawlessly. I also did some testing:

set(prefix "/path with spaces")
set(file ${prefix}/file.txt)

foreach(f ${file})
    message(STATUS ${f})
endforeach()

I assumed this would print three lines (containing /path, with, spaces/file.txt), but it actually behaved correctly and printed just one line containing /path with spaces/file.txt. So I conclude as long as the original variable (prefix) is created as string (quoted) and not as a list of strings (unquoted), all following variable replacements will treat it as whole string and not split it again. And all CMAKE_*_PREFIX and CMAKE_*_DIR are presented to the scripts as string values.

This is actually pretty awesome (unlike in shell, which would go haywire in this case).

@mosra mosra closed this as completed Oct 28, 2013
@elfring
Copy link
Author

elfring commented Apr 7, 2014

Would you also like to consider the handling of semicolons?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants