CMakeGenerate! does not define CMAKE_BUILD_TYPE if the target build dir already has a build config
Bug description
If my notes are correct from my testing...
If the build config directory that CMakeGenerate! [<config>] would use (i.e. <g:cmake_build_dir_location>/<g:cmake_default_config> or <g:cmake_build_dir_location>/<config> resp.) already exists and has a build config (e.g. by previous :CMakeClean then :CMakeGenerate [<same_config>]), then:
-
:CMakeGenerate!does NOT pass-D CMAKE_BUILD_TYPE=<g:cmake_default_config>to cmake; -
:CMakeGenerate! <config>does NOT pass-D CMAKE_BUILD_TYPE=<config>to cmake;
For comparison, in initial state (no build config) or after :CMakeClean -- all as expected --:
-
:CMakeGeneratedoes pass-D CMAKE_BUILD_TYPE=<g:cmake_default_config>to cmake; -
:CMakeGenerate!does pass-D CMAKE_BUILD_TYPE=<g:cmake_default_config>to cmake; -
:CMakeGenerate <config>does pass-D CMAKE_BUILD_TYPE=<config>to cmake, for bothconfig==g:cmake_default_configandconfig!=g:cmake_default_config; -
:CMakeGenerate! <config>does pass-D CMAKE_BUILD_TYPE=<config>to cmake, for bothconfig==g:cmake_default_configandconfig!=g:cmake_default_config.
Note, in my testing scenario, let g:cmake_build_dir_location="./build", let g:cmake_default_config="Debug" was applied, so the default config path was ./build/Debug.
To Reproduce
Case: default config
- Ensure you have no project build dir for the default configuration (or do
CMakeClean,rm -Rf ./build/etc. -- adjust to your situation). - In project root dir (with main
CMakeLists.txt) openvim, run:CMakeGenerate. - Observe
CMAKE_BUILD_TYPEbeing passed as a cli argument to cmake in the output. - Run
:CMakeGenerate!. - Observe
CMAKE_BUILD_TYPENOT being passed as a cli argument to cmake in the output.
Case: specified config
Note, tested for <config> := Debug and <config> := Release.
- Ensure you have no project build dir for the
configuration (or do :CMakeSwitch <config>thenCMakeClean, orrm -Rf ./build/etc. -- adjust to your situation). - In project root dir (with main
CMakeLists.txt) openvim, run:CMakeGenerate <config>. - Observe
CMAKE_BUILD_TYPEbeing passed as a cli argument to cmake in the output. - Run
:CMakeGenerate! <config>. - Observe
CMAKE_BUILD_TYPENOT being passed as a cli argument to cmake in the output.
Expected behavior
CMakeGenerate! should work exactly as if CMakeClean then CMakeGenerate would have been executed for the given config, even if...or -- given the purpose of the command -- especially if the build config dir already exists. That includes passing the build config type to cmake in CMAKE_BUILD_TYPE, which is currently not happening.
Behavior with minimal .vimrc
Absolute minimum .vimrc not tested.
Used vim-cmake config in .vimrc:
let g:cmake_build_dir_location = './build'
let g:cmake_link_compile_commands = 1
let g:cmake_default_config = 'Debug'
Screenshots
Not deemed important.
Other info
- OS: Lubuntu 18.04
- Vim/Neovim version: 9.0 (2022 Jun 28, compiled May 10 2022 08:40:37), Included patches: 1-749 (from binary package
2:9.0.0749-0york0~18.04from "deb http://ppa.launchpad.net/jonathonf/vim/ubuntu bionic main") - Vim-CMake version (
:echo cmake#GetInfo().version):0.16.0 - CMake version (
cmake --version):3.25.1(from binary package3.25.1-12ppa1~ubuntu18.04from "deb http://ppa.launchpad.net/ecal/cmake-3.25/ubuntu bionic main")
Additional context
None.