cmake-conan
cmake-conan copied to clipboard
ENV treats ; as a delimiter for multiple variables
# Get the path to the current cmake binary
string(REGEX REPLACE "[/|\\]cmake(\\.exe)?$" "" CMAKE_PATH "${CMAKE_COMMAND}")
# escape Windows path
string(REPLACE "\\" "/" ESCAPED_PATH "$ENV{PATH}")
conan_cmake_run(CONANFILE "conanfile.txt"
ENV "PATH=${CMAKE_PATH};${ESCAPED_PATH}"
BUILD missing)
Results in:
Conan executing: C:/Program Files/Conan/conan/conan.exe install V:/QtTest/conanfile.txt -s arch=x86_64 -s build_type=Debug -s compiler=Visual Studio -s compiler.version=16 -s compiler.runtime=MDd -e=PATH=V:/JetBrains/apps/CLion/ch-0/212.4746.93/bin/cmake/win/bin -e=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE//Extensions/Microsoft/IntelliCode/CLI -e=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/HostX64/x64
With this error:
ERROR: Invalid input 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE//Extensions/Microsoft/IntelliCode/CLI', use 'name=value'
This is a CMake thing. The semicolon is a special character that delimits list elements. You must look at how your argument is used and apply the appropriate amount of backslashes to escape the semicolon. Every unquoted variable substitution does a list expansion, which strips a backslash from semicolons.
From what I counted, cmake-conan does 5 unquoted variable substitutions:
get_filename_component(cmake_path "${CMAKE_COMMAND}" DIRECTORY)
set(esc [[\\\\\]])
string(REPLACE "\\" "/" escaped_path "$ENV{PATH}")
string(REPLACE ";" "${esc};" escaped_path "${escaped_path}")
conan_cmake_run(
CONANFILE "conanfile.txt"
ENV "PATH=${cmake_path}${esc};${escaped_path}"
BUILD missing
)
Tried this today with the same results, also tried escaping up to 7 times to see if it made a difference, it did not.
You are right, I just tested things and it seems you need 26 escapes: set(esc [[\\\\\\\\\\\\\\\\\\\\\\\\\]])
Kinda crazy! This script should improve its argument handling a lot.