fix: add support for C++20 modules for CMake 3.27.0/3.27.1 (#1632)
authorStephan Seitz <sseitz@nvidia.com>
Mon, 7 Aug 2023 06:56:36 +0000 (23:56 -0700)
committerGitHub <noreply@github.com>
Mon, 7 Aug 2023 06:56:36 +0000 (08:56 +0200)
commitcf70eb8efbc2513594d988d47bd75a7a3781e776
treeb37719e79ed5e06c0dd2c33bc5780d1c8ec83707
parent68052d9343e864129616753cfe62047b05d8a47e
fix: add support for C++20 modules for CMake 3.27.0/3.27.1 (#1632)

When using VULKAN_HPP_ENABLE_EXPERIMENTAL_CPP20_MODULES=ON with CMake 3.27.0 or 3.27.1,
you will get a very confusing error message:
```
CMake Error at CMakeLists.txt:346 (target_sources):
  target_sources File set TYPE may only be "HEADERS"
```

This is because the value of `CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API`
is not update to the correct value, disabling all experimental CMake
features.

This PR adds the value for 3.27.X and triggers an error for higher CMake
versions where this feature needs to be revised and
CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API if the feature is still
experimental.

The error message will look similar to this one (simulated for CMake
3.27.1)
```
CMake Error at CMakeLists.txt:30 (message):
  VULKAN_HPP_ENABLE_EXPERIMENTAL_CPP20_MODULES is currently not supported for
  CMake version 3.27.1! To add support inform yourself about the state of the
  feature at
  https://github.com/Kitware/CMake/blob/master/Help/dev/experimental.rst and
  add the corresponding value of CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API to
  Vulkan-Hpp's CMakeLists.txt
```
CMakeLists.txt