Skip to content

Support C++23 #756

Description

@long-recruit2

When we set CXX_standards as 23, hunter raise this error
[hunter ** INTERNAL **] CXX standard 23 not known
I wonder expected CXX_standard is set in below, we should just add 23?
hunter/cmake/modules/hunter_get_lang_standard_flag.cmake

function(hunter_get_lang_standard_flag LANG OUTPUT)
  # https://github.com/Kitware/CMake/blob/9d48d3f61b25400a191f12ea92b8e5496ab47a8f/Source/cmLocalGenerator.cxx#L1766-L1782
  set(CXX_standards 20 17 14 11 98)
  set(C_standards 11 99 90)

it has a comment pointing to a specific version of CMake but not sure where the version is from.

Activity

NeroBurner commented on Apr 29, 2025

@NeroBurner

I want to fix this before releasing v0.26.0. Probably a good idea to support C++23 and C++26?

NeroBurner commented on Apr 29, 2025

@NeroBurner

I don't find the linked code in the current CMake master

  static std::map<std::string, std::vector<std::string>> langStdMap;
  if (langStdMap.empty()) {
    // Maintain sorted order, most recent first.
    langStdMap["CXX"].emplace_back("20");
    langStdMap["CXX"].emplace_back("17");
    langStdMap["CXX"].emplace_back("14");
    langStdMap["CXX"].emplace_back("11");
    langStdMap["CXX"].emplace_back("98");

    langStdMap["C"].emplace_back("11");
    langStdMap["C"].emplace_back("99");
    langStdMap["C"].emplace_back("90");

    langStdMap["CUDA"].emplace_back("14");
    langStdMap["CUDA"].emplace_back("11");
    langStdMap["CUDA"].emplace_back("98");
  }

Maybe we can remove the handling in Hunter as well?


edit: codeblock removed in Kitware/CMake@56cf509

Currently the list is found in https://github.com/Kitware/CMake/blob/v4.0.1/Source/cmStandardLevelResolver.cxx#L491-L517

std::unordered_map<std::string,
                   StandardLevelComputer> const StandardComputerMapping = {
  { "C",
    StandardLevelComputer{
      "C", std::vector<int>{ 90, 99, 11, 17, 23 },
      std::vector<std::string>{ "90", "99", "11", "17", "23" } } },
  { "CXX",
    StandardLevelComputer{
      "CXX", std::vector<int>{ 98, 11, 14, 17, 20, 23, 26 },
      std::vector<std::string>{ "98", "11", "14", "17", "20", "23", "26" } } },
  { "CUDA",
    StandardLevelComputer{
      "CUDA", std::vector<int>{ 03, 11, 14, 17, 20, 23, 26 },
      std::vector<std::string>{ "03", "11", "14", "17", "20", "23", "26" } } },
  { "OBJC",
    StandardLevelComputer{
      "OBJC", std::vector<int>{ 90, 99, 11, 17, 23 },
      std::vector<std::string>{ "90", "99", "11", "17", "23" } } },
  { "OBJCXX",
    StandardLevelComputer{
      "OBJCXX", std::vector<int>{ 98, 11, 14, 17, 20, 23, 26 },
      std::vector<std::string>{ "98", "11", "14", "17", "20", "23", "26" } } },
  { "HIP",
    StandardLevelComputer{
      "HIP", std::vector<int>{ 98, 11, 14, 17, 20, 23, 26 },
      std::vector<std::string>{ "98", "11", "14", "17", "20", "23", "26" } } }
};

edit2: use tag link instead of commit permalink for StandardLevelComputerMapping

added a commit that references this issue on Apr 29, 2025
035f107
added a commit that references this issue on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions