Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake.configureSettings does not distinguish PATH and STRING #1457

Closed
cdowen opened this issue Sep 25, 2020 · 4 comments · Fixed by #2868
Closed

cmake.configureSettings does not distinguish PATH and STRING #1457

cdowen opened this issue Sep 25, 2020 · 4 comments · Fixed by #2868
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure Feature: settings
Milestone

Comments

@cdowen
Copy link

cdowen commented Sep 25, 2020

Brief Issue Summary

CMake tool treats "cmake.configureSettings" as strings and append ":STRING" in generated commandlines. This causes passing path in the command line impossible.

Expected:

  1. Set a path in cmake.configureSettings to tell CMake where to look for a particular library;
  2. Generated CMake command should be like "-DXXX_PATH=/aaa/bbb/..." and CMake finds the library.

Apparent Behavior:

Generated CMake command be like "-DXXX_PATH:STRING=/aaa/bbb/..." and CMake tells it cannot find the library.

CMake Tools Log

[proc] Executing command: /home/lz/.local/bin/cmake --no-warn-unused-cli -DOPENSSL_ROOT_DIR:STRING=/home/lz/.local/lib/ -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -H/home/lz/workspace/trojan -B/home/lz/workspace/trojan/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The CXX compiler identification is GNU 5.5.0
[cmake] -- Check for working CXX compiler: /usr/bin/c++
[cmake] -- Check for working CXX compiler: /usr/bin/c++ -- works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Looking for C++ include pthread.h
[cmake] -- Looking for C++ include pthread.h - found
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
[cmake] -- Check if compiler accepts -pthread
[cmake] -- Check if compiler accepts -pthread - yes
[cmake] -- Found Threads: TRUE  
[cmake] -- Found Boost: /home/lz/.local/lib/cmake/Boost-1.74.0/BoostConfig.cmake (found suitable version "1.74.0", minimum required is "1.66.0") found components: system program_options 
[cmake] CMake Error at /home/lz/.local/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
[cmake]   Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
[cmake]   system variable OPENSSL_ROOT_DIR: Found unsuitable version "1.0.2g", but
[cmake]   required is at least "1.1.0" (found /home/lz/.local/lib/libcrypto.so)
[cmake] Call Stack (most recent call first):
[cmake]   /home/lz/.local/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:391 (_FPHSA_FAILURE_MESSAGE)
[cmake]   /home/lz/.local/share/cmake-3.16/Modules/FindOpenSSL.cmake:449 (find_package_handle_standard_args)
[cmake]   CMakeLists.txt:46 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!

Platform and Versions

  • Operating System: Windows as client, ubuntu as remote
  • CMake Version: 3.16.1
  • VSCode Version: 1.49.2
  • CMake Tools Extension Version: 1.4.2
  • Compiler/Toolchain: GCC 5.5.0
@bobbrow
Copy link
Member

bobbrow commented Oct 12, 2020

This may be a limitation of the map-style syntax of cmake.configureSettings. If you use cmake.configureArgs, you should be able to pass in the switches exactly as you like.

@bobbrow bobbrow added enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure Feature: settings labels Oct 12, 2020
@andreeis andreeis added this to the Backlog milestone Oct 19, 2020
@ishipachev
Copy link

ishipachev commented Nov 30, 2020

@bobbrow
But the documentation explicitly says that you SHOULDN'T pass -D flags with cmake.configureArgs. Like NEVER, NEVER.
Links:
Some CMake doc
Official doc:

cmake.configureArgs -> Arguments to CMake that will be passed during the configure process. Prefer to use cmake.configureSettings or CMake variants.Do not pass -D arguments using this setting.

To be honest, after reading documentation for two hours I'm still struggle to understand how should I pass CMake flags with -D, for an example I have such cmake command to run which is generated by other python script:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/some_path_2/colmap_build/__install__ -DCMAKE_INSTALL_PREFIX=/some_path_1/__install__ -DBOOST_ROOT=/some_path_3/software/Boost/1.67.0-fosscuda-2018b -DBoost_NO_BOOST_CMAKE=TRUE -DCUDA_ENABLED=ON -DCUDA_ARCHS=Auto -DOPENGL_ENABLED=OFF -DTESTS_ENABLED=OFF /some_path_4/colmap

So I would like to pass it somehow to configuration settings. But I have no idea what to use. Some flags have special fields for them, like CMAKE_INSTALL_PREFIX, some of them are not. I've tried to understand the connection between
cmake.configureSettings and cmake.configureArgs, but this issue with comments and its contradiction with documentation confused me completely.

May I ask you for a help here? What is the meaning behind cmake.configureSettings and cmake.configureArgs, why do we need both and how should be process those -D flags?

I also found probably the same issue on Stack Overflow: check the answer and the discussion below it about setting path to Qt

@bobbrow
Copy link
Member

bobbrow commented Nov 30, 2020

There's actually no technical reason prohibiting you from passing -D with configureArgs. I believe that warning was written by vector-of-bool when he started this project and we haven't spent much time in the area yet. Based on what I see in the code I think it was to avoid conflicts between some of the "special" settings you mentioned. These conflicts are resolved if you use configureSettings, but not when you use configureArgs. I suspect it is easier to advise not to use configureArgs for -D arguments than to explain all of the potential conflicts.

I think a more correct warning would be not to use configureArgs to set the following properties:

CMAKE_EXPORT_COMPILE_COMMANDS
CMAKE_BUILD_TYPE
CMAKE_INSTALL_PREFIX
CMAKE_[LANGUAGE]_COMPILER
CMAKE_TOOLCHAIN_FILE
BUILD_SHARED_LIBS

@bobbrow
Copy link
Member

bobbrow commented Dec 6, 2022

Starting with version 1.13.28 tomorrow cmake.configureSettings will support objects of type: { "type": "PATH", "value": "/usr/bin/foo" } if you need to set a specific value type. You can also set the type to "" if you don't want any type information appended for your variable.

@bobbrow bobbrow closed this as completed Dec 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure Feature: settings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants