google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
33.77k stars 10k forks source link

CMake Error (dev): uninitialized variable 'cxx_strict_flags'. #4071

Open shrek1402 opened 1 year ago

shrek1402 commented 1 year ago

Describe the bug

I get an error message when building a project

Does the bug persist in the most recent commit? Yes

I use preset:

"configurePresets": [
    {
      "name": "cmake-pedantic",
      "hidden": true,
      "warnings": {
        "dev": true,
        "deprecated": true,
        "uninitialized": true,
        "unusedCli": true,
        "systemVars": false
      },
      "errors": {
        "dev": true,
        "deprecated": true
      }
    },
$ cmake --preset=dev
Preset CMake variables:

  BUILD_MCSS_DOCS="ON"
  CMAKE_CXX_EXTENSIONS="OFF"
  CMAKE_CXX_FLAGS="/utf-8 /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w4503
8 /W4 /permissive- /volatile:iso /Zc:preprocessor /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc"
  CMAKE_CXX_STANDARD="17"
  CMAKE_CXX_STANDARD_REQUIRED="ON"
  super_lib_DEVELOPER_MODE="ON"

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
CMake Error (dev) at build/dev/_deps/googletest-src/googletest/cmake/internal_utils.cmake:144 (set):
  uninitialized variable 'cxx_strict_flags'
Call Stack (most recent call first):
  build/dev/_deps/googletest-src/googletest/CMakeLists.txt:93 (config_compiler_and_linker)
This error is for project developers. Use -Wno-error=dev to suppress it.

CMake Error (dev) at build/dev/_deps/googletest-src/googletest/cmake/internal_utils.cmake:144 (set):
  uninitialized variable 'cxx_strict_flags'
Call Stack (most recent call first):
  build/dev/_deps/googletest-src/googlemock/CMakeLists.txt:70 (config_compiler_and_linker)
This error is for project developers. Use -Wno-error=dev to suppress it.

-- Configuring incomplete, errors occurred!
See also "C:/_Study/a/super_lib/build/dev/CMakeFiles/CMakeOutput.log".
See also "C:/_Study/a/super_lib/build/dev/CMakeFiles/CMakeError.log".
shrek1402 commented 1 year ago

If I understand correctly, then the problem is here. And the solution is very simple - you either need to always define the variable 'cxx_strict_flags', or add a condition to define 'cxx_strict'

zyrkiel commented 7 months ago

Hi, Any news about the fix?