QMAKE : Generated VS Project and Ampersand - project

I use QMAKE to generate a Visual Studio Project which contain a path with whitespaces, ex : C:\Program Files...
I need to add the " tag (the 6 characters html tag and not the real quote, that's what VS need) before and after the path ($$quote does not work). But when i write " in my .pro , qmake translate it by ".
Is there a way to avoid that ? Using a special function, ascii code or something ?
Thanks !

I found how to add the quote tag (not directly the ampersand symbol but i don't care), simply use '"' to add " and it would work.

Related

The enviroment varoable path seems to have some paths containing the """ character

Every time when i open vs code i get this messag: The environment variable 'Path' seems to have some paths containing the '"' character. The existence of such a character is known to have caused the Python extension to not load. If the extension fails to load please modify your paths to remove this '"' character. i dont know why it comes up and how to make it disappear
i tried changing some values in the different enviroment settings the user-settings and the system-settings but it did not seem to work.

Escape "[]" characters in a semicolon-separated list in CMake

I found "[" and "]" might have special meanings in a semicolon-separated list in CMake. When I try this code in CMakeLists.txt:
set(XX "a" "b" "[" "]")
message("${XX}")
foreach(x ${XX})
message("--> ${x}")
endforeach()
I expect the result:
a;b;[;]
--> a
--> b
--> [
--> ]
However I got this:
a;b;[;]
--> a
--> b
--> [;]
I didn't find any documentation for the usage of "[" and "]". Is it possible to escape these characters so that I can get the expected result? I am using CMake 2.8.12.2. Thanks for any help :)
According to the documentation opening square bracket definitely has a special meaning:
Note: CMake versions prior to 3.0 do not support bracket arguments. They interpret the opening bracket as the start of an Unquoted Argument.
So the problem is mixing Quoted and Unquoted arguments. Possible workaround in your case is to replace opening square bracket to something else in initialization and later replace it back, like this:
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
PROJECT (HELLO NONE)
SET(XX a b BRACKET ])
MESSAGE("${XX}")
FOREACH(x ${XX})
STRING(REGEX REPLACE "BRACKET" "[" x ${x})
MESSAGE("--> ${x}")
ENDFOREACH()
As noted in another answer, the square brackets are now used to delimit "long form" arguments or long form comments, as well documented in CMake 3.0 and later.
A single pair of square brackets with ; inside have also long been used to designate registry [key;value] pairs on Windows. An example of this behavior is shown in the CMake file InstallRequiredSystemLibraries.cmake :
get_filename_component(msvc_install_dir
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE)
The way it's implemented has the unfortunate side effect of causing confusion when somebody wants to have list values containing square brackets, hence this question on SO.

Objective-C - How to convert file path to shell conform file path

I want to execute a shell command (I want to touch a file). I use system("shell command") to execute the command.
For example I want to touch the file at path /Users/username/New Folder/. Now I need to convert the NSString in a format that is conform to shell commands like /Users/username/New\ Folder.
Is there any method that does a conversion like this?
NOTE: It is NOT just replacing a whitespace with \. If you have a special character in the path like /Users/username/Folder(foo)/ the "shell path" looks like this /Users/username/Folder\(foo\)/
There is no need to convert the path, you can surround it in single quotes. Just use:
touch 'path'
You can enclose the parameters that contain spaces with " " marks.
touch "/Users/username/New Folder/"
At least this works at the shell prompt
Don't use system. It's insecure and unpredictable. Surrounding the string with quotes is not sufficient.
Use the execve style functions instead. They are simple and secure.

Using CMake's include_directories command with white spaces

I am using CMake to build my project and I have the following line:
include_directories(${LLVM_INCLUDE_DIRS})
which, after evaluating LLVM_INCLUDE_DIRS, evaluates to:
include_directories(C:\Program Files\LLVM\include)
The problem is that this is being considered two include directories, "C:\Program" and "Files\LLVM\include".
Any idea how can I solve this problem? I tried using quotation marks, but it didn't work.
EDIT: It turned out that the problem is in the file llvm-3.0\share\llvm\cmake\LLVMConfig.cmake. I enclosed the following paths with quotation marks and the problem was solved:
set(LLVM_INSTALL_PREFIX C:/Program Files/LLVM)
set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include)
set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
In CMake,
whitespace is a list separator (like ;),
evaluating variable names basically replaces the variable name with its content and
\ is an escape character (to get the symbol, it needs to be escaped as well)
So, in your example, include_directories(C:\\Pogram Files\\LLVM\\include) is the same as
include_directories( C:\\Program;Files\\LLVM\\include)
that is, a list with two items. To avoid this, either
escape the whitespace as well:
include_directories( C:\\Program\ Files\\LLVM\\include) or
surround the path with quotation marks:
include_directories( "C:\\Program Files\\LLVM\\include")
Obviously, the second option is the better choice as it is
simpler and easier to read and
can be used with variable evaluation like in your example (since the result of the evaluation is then surrounded by quotation marks and thus, treated a single item)
include_directories("${LLVM_INCLUDE_DIRS}")
This works as well, if LLVM_INCLUDE_DIRS is a list of multiple directories because the items in this list will then be explicitly separated by ; so that there is no need for unquoted whitespace as implicit list item separator.
Side note:
When using hard-coded path-names (for whatever reason) in my CMake files, I usually uses forward slashes as directory separators as this works on Windows as well and avoids the need to escape all backslashes.
This is more likely to be an error at the point where LLVM_INCLUDE_DIRS is set rather than a problem with include_directories.
To check this, try calling include_directories("C:\\Program Files\\LLVM\\include") - it should work correctly.
The problem seems to be that LLVM_INCLUDE_DIRS was constructed without using quotation marks. Try for example running this:
set(LLVM_INCLUDE_DIRS C:\\Program Files\\LLVM\\include)
message("${LLVM_INCLUDE_DIRS}")
set(LLVM_INCLUDE_DIRS "C:\\Program Files\\LLVM\\include")
message("${LLVM_INCLUDE_DIRS}")
The output is:
C:\Program;Files\LLVM\include
C:\Program Files\LLVM\include
Note the semi-colon in the first output line. This is a list with 2 items.
So the way to fix this is to modify the way in which LLVM_INCLUDE_DIRS is created.

MSBuild string that has this format $(SomeText)

in my MSBuild every text that has this pattern $(SomeText) is considered as property reference. I have an MSBuild Custom Task that writes content to some text file and the text that needs to be written is $(SomeText) thus MSBuild does not let this pass through because it is considered as properry reference.
Any workaround.
Many thanks,
Idriss
MSBuild uses same escaping as in URL. Use %24 instead of $
Here and here is a full list of ASCII character codes