microsoft / microsoft/vscode-cmake-tools

Windows: environmentSetupScript in kits doesn't seem to properly work with .bat

Open
#1,463 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: configure help wanted investigation needed
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

Brief Issue Summary

On Windows, I'm trying to configure CMake tools in order to call a file activate_run.bat generated by conan in my build folder. This file is required because:

  • I build qt from source with all libraries shared, so rcc.exe (executed at configure time in CMake if using AUTORCC ON) is linked to shared zlib and zstd.
  • activate_run.bat adds to PATH all the bin folders where dll's dependencies are stored, so that rcc.exe can find dll.

I've added this line in kits:

    "environmentSetupScript": "${workspaceRoot}/build/${buildKit}_${buildType}/activate_run.bat"

(${workspaceRoot}/build/${buildKit}_${buildType} is the custom value of my cmake.buildDirectory, but I've also tried with an hardcoded absolute path like "environmentSetupScript": "D:/projects/test/build/msvc2019_x64_x64_Release/activate_run.bat").

But it doesn't work, rcc.exe fails at execution time during CMake configuration, meaning that dll files are not in PATH.

If I run the following commands in x64 Native Tools Command Prompt for VS 2019, everything works like a charm:

activate.bat
cmake <path_to_project> -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja
cmake --build .

Here is the content of activate_run.bat:

@echo off
SET "CONAN_OLD_PATH=%PATH%"

FOR /F "usebackq tokens=1,* delims==" %%i IN ("D:\projects\test\build\msvc2019_x64_x64_Release\environment_run.bat.env") DO (
    CALL SET "%%i=%%j"
)

SET "CONAN_OLD_PROMPT=%PROMPT%"
SET "PROMPT=(conanrunenv) %PROMPT%"

Content of environment_run.bat.env read by activate_run.bat to fill PATH:

DYLD_LIBRARY_PATH=C:\Users\spaceim\.conan_short\994123\1\lib;C:\Users\spaceim\.conan\data\openssl\1.1.1h\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\pcre2\10.35\_\_\package\8bc288d2784f289a68c2ea581aafbd73175420bc\lib;C:\Users\spaceim\.conan\data\double-conversion\3.1.5\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan_short\58dd1a\1\lib;C:\Users\spaceim\.conan\data\libjpeg\9d\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\sqlite3\3.32.3\_\_\package\7a7477667b10f0b354850d1a3113f5d4789f003a\lib;C:\Users\spaceim\.conan\data\libpq\12.2\_\_\package\b6a3102ceb095836e46dfe6e808357a0ab56add0\lib;C:\Users\spaceim\.conan\data\openal\1.20.1\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\zstd\1.4.5\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan_short\1de1d2\1\lib;C:\Users\spaceim\.conan\data\freetype\2.10.2\_\_\package\412dc72636204b0105b06e8bdf82bea56745e97a\lib;C:\Users\spaceim\.conan\data\libffi\3.3\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\pcre\8.44\_\_\package\d879a71a35337d973b717f678160d4186548c443\lib;C:\Users\spaceim\.conan\data\libelf\0.8.13\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\libgettext\0.20.1\_\_\package\f4e0c673d7bfae69373d80fb47d91343225e2cc9\lib;C:\Users\spaceim\.conan\data\libpng\1.6.37\_\_\package\3144a0c6dc18aae2e8b769f92faa8398f2022a4b\lib;C:\Users\spaceim\.conan\data\brotli\1.0.9\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\zlib\1.2.11\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\bzip2\1.0.8\_\_\package\4528437567062bbbdabe0f12323b342a14f38892\lib;C:\Users\spaceim\.conan\data\libiconv\1.16\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;%DYLD_LIBRARY_PATH%
LD_LIBRARY_PATH=C:\Users\spaceim\.conan_short\994123\1\lib;C:\Users\spaceim\.conan\data\openssl\1.1.1h\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\pcre2\10.35\_\_\package\8bc288d2784f289a68c2ea581aafbd73175420bc\lib;C:\Users\spaceim\.conan\data\double-conversion\3.1.5\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan_short\58dd1a\1\lib;C:\Users\spaceim\.conan\data\libjpeg\9d\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\sqlite3\3.32.3\_\_\package\7a7477667b10f0b354850d1a3113f5d4789f003a\lib;C:\Users\spaceim\.conan\data\libpq\12.2\_\_\package\b6a3102ceb095836e46dfe6e808357a0ab56add0\lib;C:\Users\spaceim\.conan\data\openal\1.20.1\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\zstd\1.4.5\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan_short\1de1d2\1\lib;C:\Users\spaceim\.conan\data\freetype\2.10.2\_\_\package\412dc72636204b0105b06e8bdf82bea56745e97a\lib;C:\Users\spaceim\.conan\data\libffi\3.3\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\pcre\8.44\_\_\package\d879a71a35337d973b717f678160d4186548c443\lib;C:\Users\spaceim\.conan\data\libelf\0.8.13\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\libgettext\0.20.1\_\_\package\f4e0c673d7bfae69373d80fb47d91343225e2cc9\lib;C:\Users\spaceim\.conan\data\libpng\1.6.37\_\_\package\3144a0c6dc18aae2e8b769f92faa8398f2022a4b\lib;C:\Users\spaceim\.conan\data\brotli\1.0.9\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\zlib\1.2.11\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;C:\Users\spaceim\.conan\data\bzip2\1.0.8\_\_\package\4528437567062bbbdabe0f12323b342a14f38892\lib;C:\Users\spaceim\.conan\data\libiconv\1.16\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\lib;%LD_LIBRARY_PATH%
PATH=C:\Users\spaceim\.conan_short\994123\1\bin;C:\Users\spaceim\.conan\data\openssl\1.1.1h\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\pcre2\10.35\_\_\package\8bc288d2784f289a68c2ea581aafbd73175420bc\bin;C:\Users\spaceim\.conan\data\double-conversion\3.1.5\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan_short\58dd1a\1\bin;C:\Users\spaceim\.conan\data\libjpeg\9d\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\sqlite3\3.32.3\_\_\package\7a7477667b10f0b354850d1a3113f5d4789f003a\bin;C:\Users\spaceim\.conan\data\libpq\12.2\_\_\package\b6a3102ceb095836e46dfe6e808357a0ab56add0\bin;C:\Users\spaceim\.conan\data\openal\1.20.1\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\zstd\1.4.5\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan_short\1de1d2\1\bin;C:\Users\spaceim\.conan\data\freetype\2.10.2\_\_\package\412dc72636204b0105b06e8bdf82bea56745e97a\bin;C:\Users\spaceim\.conan\data\libffi\3.3\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\pcre\8.44\_\_\package\d879a71a35337d973b717f678160d4186548c443\bin;C:\Users\spaceim\.conan\data\libelf\0.8.13\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\libgettext\0.20.1\_\_\package\f4e0c673d7bfae69373d80fb47d91343225e2cc9\bin;C:\Users\spaceim\.conan\data\libpng\1.6.37\_\_\package\3144a0c6dc18aae2e8b769f92faa8398f2022a4b\bin;C:\Users\spaceim\.conan\data\brotli\1.0.9\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\zlib\1.2.11\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;C:\Users\spaceim\.conan\data\bzip2\1.0.8\_\_\package\4528437567062bbbdabe0f12323b342a14f38892\bin;C:\Users\spaceim\.conan\data\libiconv\1.16\_\_\package\127af201a4cdf8111e2e08540525c245c9b3b99e\bin;%PATH%
Expected:
  1. run conan install outside of CMake tools with virtualrunenv generator.
  2. add absolute path to activate_run.bat (generated by step 1) in environmentSetupScript of kits
  3. configure CMake successfully
Apparent Behavior:
  1. run conan install outside of CMake tools with virtualrunenv generator
  2. add absolute path to activate_run.bat (generated by step 1) in environmentSetupScript of kits
  3. configure CMake fails
CMake Tools Log
[proc] Exécution de la commande : "C:/Program Files/CMake/bin/cmake" --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE=conan_paths.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -Hd:/projects/test -Bd:/projects/test/build/msvc2019_x64_x64_Release -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is MSVC 19.27.29111.0
[cmake] -- The CXX compiler identification is MSVC 19.27.29111.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Configuring done
[cmake] CMake Error: AUTORCC for target test-qt-conan: Test run of "rcc" executable "C:/Users/spaceim/.conan_short/994123/1/bin/rcc.exe" failed.
[cmake] C:/Users/spaceim/.conan_short/994123/1/bin/rcc.exe -h
[cmake] 
[cmake] Exit code 0xc0000135
[cmake] 
[cmake] CMake Generate step failed.  Build files cannot be regenerated correctly.
Platform and Versions
  • Operating System: Windows 10
  • CMake Version: 3.18.3
  • VSCode Version: 1.49.2
  • CMake Tools Extension Version: 1.4.2
  • Compiler/Toolchain: Visual Studio 2019 + conan + ninja
Other Notes/Information

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Windows case using conan's virtualrunenv generator, the kit's environmentSetupScript, and the provided activate_run.bat, then inspect how CMake Tools launches the configuration command. Done means configuring the project succeeds and rcc.exe can find its DLL dependencies through the batch-script environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.