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 -H to generate build files? #2053

Closed
wermos opened this issue Aug 13, 2021 · 5 comments · Fixed by #2059 or #2292
Closed

cmake -H to generate build files? #2053

wermos opened this issue Aug 13, 2021 · 5 comments · Fixed by #2059 or #2292
Labels
bug a bug in the product Feature: configure
Milestone

Comments

@wermos
Copy link

wermos commented Aug 13, 2021

Brief Issue Summary

The extension uses cmake -H/path/to/source to generate the build files. However, this flag is not documented in the CMake Docs as far as I know.

Expected:

The extension should use cmake -S/path/to/source/ to generate the build files. The -H flag is documented here and is only for printing the help text. See here for the question I asked about it on Stack Overflow.

CMake Tools Log

With Clang 10.0.0 x86_64-pc-linux-gnu kit:

[main] Building folder: Light 
[main] Configuring folder: Light 
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/bin/clang-10 -DCMAKE_CXX_COMPILER:FILEPATH=/bin/clang++-10 -H/home/tirthankar/projects/physicc/Light -B/home/tirthankar/projects/physicc/Light/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is Clang 10.0.0
[cmake] -- The CXX compiler identification is Clang 10.0.0
[cmake] -- Check for working C compiler: /bin/clang-10
[cmake] -- Check for working C compiler: /bin/clang-10 -- works
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Check for working CXX compiler: /bin/clang++-10
[cmake] -- Check for working CXX compiler: /bin/clang++-10 -- 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] -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
[cmake] -- Looking for pthread.h
[cmake] -- Looking for pthread.h - found
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
[cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
[cmake] -- Looking for pthread_create in pthreads
[cmake] -- Looking for pthread_create in pthreads - not found
[cmake] -- Looking for pthread_create in pthread
[cmake] -- Looking for pthread_create in pthread - found
[cmake] -- Found Threads: TRUE  
[cmake] -- Using X11 for window creation
[cmake] -- Found X11: /usr/include   
[cmake] -- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
[cmake] -- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
[cmake] -- Looking for gethostbyname
[cmake] -- Looking for gethostbyname - found
[cmake] -- Looking for connect
[cmake] -- Looking for connect - found
[cmake] -- Looking for remove
[cmake] -- Looking for remove - found
[cmake] -- Looking for shmat
[cmake] -- Looking for shmat - found
[cmake] -- Looking for IceConnectionNumber in ICE
[cmake] -- Looking for IceConnectionNumber in ICE - found
[cmake] -- Build spdlog: 1.8.5
[cmake] -- Build type: Debug
[cmake] -- Found Python: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter 
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/tirthankar/projects/physicc/Light/build

With GCC 10.2.0 x86_64-pc-linux-gnu kit:

[variant] Loaded new set of variants
[kit] Successfully loaded 3 kits from /home/tirthankar/.local/share/CMakeTools/cmake-tools-kits.json
[main] Configuring folder: Light 
[proc] Executing command: /bin/x86_64-linux-gnu-gcc-10 -v
[cmakefileapi-driver] This version of CMake does not support the "toolchains" object kind. Compiler paths will be determined by reading CMakeCache.txt.
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/bin/x86_64-linux-gnu-gcc-10 -DCMAKE_CXX_COMPILER:FILEPATH=/bin/x86_64-linux-gnu-g++-10 -H/home/tirthankar/projects/physicc/Light -B/home/tirthankar/projects/physicc/Light/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Using X11 for window creation
[cmake] -- Build spdlog: 1.8.5
[cmake] -- Build type: Debug
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/tirthankar/projects/physicc/Light/build

Platform and Versions

  • Operating System: Windows_NT x64 10.0.19043 (Copied from the output of "About" from the "Help" drop down) with WSL2 (Ubuntu 20.04 LTS)
  • CMake Version: 3.16.3
  • VSCode Version: Version: 1.59.0 (user setup) (Copied from the output of "About" from the "Help" drop down)
  • CMake Tools Extension Version: 1.7.3
  • Compiler/Toolchain: Clang and GCC
@elahehrashedi
Copy link
Contributor

it looks like it should have been replaced by -S. For some reason using -H was not creating any bug so far.

Options
  -S <path-to-source>          = Explicitly specify a source directory.   
  -B <path-to-build>           = Explicitly specify a build directory.  

@elahehrashedi
Copy link
Contributor

Actually, -S was added to CMake later. We need to revert the PR.
it doesn't exist in 3.10 which is still in use by lots of people.
We can come up with a different fix later.

@alexreinking
Copy link

alexreinking commented Sep 16, 2021

it doesn't exist in 3.10 which is still in use by lots of people.

First of all, those people should upgrade. Second of all, you shouldn't penalize responsible users who keep their tools up to date (reverting that patch broke 3.21).

We can come up with a different fix later.

Finally, if you want something documented that will work on every version, use this command:

(mkdir -p /path/to/build && cd /path/to/build && cmake [...] /path/to/source)

@bobbrow
Copy link
Member

bobbrow commented Sep 16, 2021

First of all, those people should upgrade

I agree, but it doesn't change the fact that tons of people use the default Ubuntu packages.

you shouldn't penalize responsible users who keep their tools up to date

This didn't seem to be broken in our testing even with the newer CMake version. Are you experiencing a problem with it?

It shouldn't be too hard to check the version of CMake before choosing which switch to use. We'd accept a PR if someone wants to do it now. But because we didn't see it broken in our testing, we didn't do it immediately.

@alexreinking
Copy link

I agree, but it doesn't change the fact that tons of people use the default Ubuntu packages.

On Ubuntu apt remove cmake && snap install cmake is enough to fix the issue.

It shouldn't be too hard to check the version of CMake before choosing which switch to use. We'd accept a PR if someone wants to do it now. But because we didn't see it broken in our testing, we didn't do it immediately.

I have some bandwidth to fix this... -H is liable to break at any time without warning.

friendlyanon added a commit to friendlyanon/vscode-cmake-tools that referenced this issue Dec 17, 2021
The -H flag is an undocumented feature that was never supposed to be
used by the public. This commit makes the drivers use the appropriate
methods of configuring depending on the CMake version they handle:

Legacy: The binary directory has to be created first and CMake must be
invoked with that folder as its working directory. The source directory
is passed without any flags.

ServerAPI: The binary directory was already ensured to exist. No changes
necessary.

FileAPI: The driver for this assumes CMake >= 3.15, so the -S and -B
flags can be used. These flags were introduced in CMake 3.13.

Fixes: microsoft#2053
friendlyanon added a commit to friendlyanon/vscode-cmake-tools that referenced this issue Dec 17, 2021
The -H flag is an undocumented feature that was never supposed to be
used by the public. This commit makes the drivers use the appropriate
methods of configuring depending on the CMake version they handle:

Legacy: The binary directory has to be created first and CMake must be
invoked with that folder as its working directory. The source directory
is passed without any flags.

ServerAPI: The binary directory was already ensured to exist. No changes
necessary.

FileAPI: The driver for this assumes CMake >= 3.15, so the -S and -B
flags can be used. These flags were introduced in CMake 3.13.

Fixes: microsoft#2053
bobbrow pushed a commit that referenced this issue Dec 20, 2021
The -H flag is an undocumented feature that was never supposed to be
used by the public. This commit makes the drivers use the appropriate
methods of configuring depending on the CMake version they handle:

Legacy: The binary directory has to be created first and CMake must be
invoked with that folder as its working directory. The source directory
is passed without any flags.

ServerAPI: The binary directory was already ensured to exist. No changes
necessary.

FileAPI: The driver for this assumes CMake >= 3.15, so the -S and -B
flags can be used. These flags were introduced in CMake 3.13.

Fixes: #2053

Co-authored-by: friendlyanon <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: configure
Projects
None yet
4 participants