rdong8 / cpp_project

Template for a modern C++ project using CMake.
0 stars 0 forks source link

Use C++23 standard library modules #3

Open rdong8 opened 7 months ago

rdong8 commented 7 months ago

This is going to require Clang 18+, and some future CMake version since the standard library modules are currently unsupported by any version of CMake.

rdong8 commented 1 month ago

Seems broken on CMake 3.30.2.

-- The CXX compiler identification is Clang 18.1.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
CMake Warning (dev) at /var/lib/snapd/snap/cmake/1409/share/cmake-3.30/Modules/Compiler/CMakeCommonCompilerMacros.cmake:248 (cmake_language):
  CMake's support for `import std;` in C++23 and newer is experimental.  It
  is meant only for experimentation and feedback to CMake developers.
Call Stack (most recent call first):
  /var/lib/snapd/snap/cmake/1409/share/cmake-3.30/Modules/CMakeDetermineCompilerSupport.cmake:113 (cmake_create_cxx_import_std)
  /var/lib/snapd/snap/cmake/1409/share/cmake-3.30/Modules/CMakeTestCXXCompiler.cmake:83 (CMAKE_DETERMINE_COMPILER_SUPPORT)
  CMakeLists.txt:14 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Detecting CXX compile features - done
-- Configuring done (0.6s)
CMake Error in CMakeLists.txt:
  The "CXX_MODULE_STD" property on the target "uses_std" requires that the
  "__CMAKE::CXX23" target exist, but it was not provided by the toolchain.
  Reason:

    Only `libc++` is supported

-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
rdong8 commented 4 weeks ago

https://gitlab.kitware.com/cmake/cmake/-/issues/25965

Looks like Clang 19 may fix some of these issues. Currently Fedora 40 ships Clang 18 so I need to wait to check.