Skip to content

presets: setting CMAKE_MODULE_PATH using env variable is not working on Windows

Example when using presets to setup my module_path the following error is raised on Windows because the $env{CONDA_PREFIX} variable has a path which does not escape the "\" and you end up with a mix "\" path which causes the error.

      "cacheVariables": {
        "CMAKE_MODULE_PATH": "${sourceDir}/cmake-build-${presetName};$env{CONDA_PREFIX}/share/cmake"
      }
(toolchain_msvc) PS C:\Users\xxx\Source\Repos\xxx> cmake --preset="win64-configure-debug"
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_CXX_COMPILER="cl"
  CMAKE_CXX_COMPILER_VERSION="16"
  CMAKE_MODULE_PATH="C:/Users/xxx/source/repos/xxx/cmake-build-win64-configure-debug;C:\Users\xxx\micromamba\envs\toolchain_msvc/share/cmake"

Error

-- The C compiler identification is MSVC 19.31.31104.0
-- The CXX compiler identification is MSVC 19.31.31104.0
-- Detecting C compiler ABI info
CMake Error at C:/Users/xxx/source/repos/xxx/cmake-build-win64-configure-debug/CMakeFiles/CMakeScratch/TryCompile-gqyye5/CMakeLists.txt:2 (set):
  Syntax error in cmake code at

    C:/Users/xxx/source/repos/xxx/cmake-build-win64-configure-debug/CMakeFiles/CMakeScratch/TryCompile-gqyye5/CMakeLists.txt:2

  when parsing string

    C:/Users/xxx/source/repos/xxx/cmake-build-win64-configure-debug;C:\Users\xxx\micromamba\envs\toolchain_msvc/share/cmake
Edited by Alex Shagiev
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information