网上看到的一些教程,比如import CMake; C++20 Modules都要使用下面的黑魔法:
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
# Default to C++ extensions being off. Clang's modules support have trouble
# with extensions right now.
set(CMAKE_CXX_EXTENSIONS OFF)
特别是第一行的 218 那堆数字,真不禁黑人问号脸。CMake 这是正常人设计出来的工具?还不如传统的 Make 直观。
1
zsxzy 2023-10-14 11:03:22 +08:00
Features are gated behind CMAKE_EXPERIMENTAL_ variables which must be set
to specific values in order to enable their gated behaviors. Note that the specific values will change over time to reinforce their experimental nature. cmake 特意这样设计的.. |
2
xiaopanzi OP @zsxzy 设计成类似`CMAKE_EXPERIMENTAL_CXX_MODULE ON`也好理解吧。搞那个 218 的字符串的逻辑就很反人类。
|
3
nightwitch 2023-10-14 12:56:46 +08:00 1
因为不同的 CMake 会带不同的这个值,用来标识不同版本的实现,https://github.com/Kitware/CMake/commit/48ee946fdcb8a610653e7ba42e9b8dba6942dbfb
本身这个特性是不稳定的,CMake 也要迭代他的实现 |