Skip to content

typo in cmake variables that set c++ standard, and weird way of setting teh c++ compiler #68

@weatherhead99

Description

@weatherhead99

The top level CMakeLists sets CMAKE_GXX_STANDARD and CMAKE_GXX_STANDARD_REQUIRED variables but as far as I can see these don't do anything.

The "standard" cmake variables introduced in 3.1 are CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED (see, for example https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html). Setting those variables automatically handles all the "-std=c++17" command line flags that we also for some reason do manually in some places at the moment.

I think we are currently getting lucky that this works since e.g. on ubuntu 24.04 the default gcc 13 will be at least in c++17 mode by default.

In addition, manually setting CMAKE_CXX_COMPILER from a meta-build directly is very much discouraged. If it's needed, it should be done from a toolchain file. As far as I can see it's just there to provide an error message if the compiler isn't installed, which is redundant anyway. Modern cmake supplies what is (IMO) a sufficiently clear error message in this case. (see https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html). If the error message is really wanted it is sufficient to check the variable and emit the error, and not override CMAKE_CXX_COMPILER.

Cheers,
Dan W

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions