Wrong environment variable enconcoding on Windows after reading it from console output and calling set() command for it
Updated: CMake change encoding for environment variables when you try reading it from console output and then set it back. My username contain Unicode symbols (Cyrillic), so USERNAME
is also contains.
execute_process(COMMAND cmd /C set USERNAME
OUTPUT_VARIABLE contents)
message(STATUS "contents ${contents}")
message(STATUS "$ENV{USERNAME}")
if(contents MATCHES "^([^=]+)=(.+)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
message(STATUS "$ENV{USERNAME}")
After that my Windows app called from CMake doesn't work, because it uses SHGetKnownFolderPath
(that use some of that environment variables) and it fails.
cmake version 3.6.0