I'm new to CMake in general so hopefully there is something simple I'm doing wrong but I'm pulling my hair out trying to find the solution. I can't get CMake tools to compile even a trivial program with c++11 (or higher features). Ideally I'd like to enable c++17.
For example, if my entire main() function is
int main(int, char**)
{
auto number{9};
return 0;
}
I get the following 2 errors and 1 warning when attempting a build:
error: declaration of variable 'number' with deduced type 'auto' requires an initializer
error: expected ';' at end of declaration
warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
My VSCode C++ settings are set to the C++17 standard, and I don't get any Intellisense errors or warnings when writing the code, just when I try to build using the CMake Tools extension.
I've also tried adding the following to my CMakeLists.txt file:
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
What am I missing? Thanks very much!
Platform and Versions
Operating System: macOS High Sierra 10.13.6
CMake Version: 3.16.2
VSCode Version: 1.41.1
CMake Tools Extension Version: 1.2.3
Compiler/Toolchain: Clang 10.0.0
Aucun commentaire:
Enregistrer un commentaire