Mam wersje cmake 3.26.4.
Mam jak na razie dwa pliki, tak aby sprawdzic czy dziala - main.cxx
i foo.cxx
. main.cxx
importuje module z foo.cxx
i wypisuje "Hello, World!"
Problem mam z plikiem CMakeLists.txt
, jego zawartość:
cmake_minimum_required(VERSION 3.26)
project(modules CXX)
set(CMAKE_CXX_STANDARD 20)# turn on the dynamic depends for ninja
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
# turn on the experimental API
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
add_library(foo STATIC)
target_sources(
foo PRIVATE
FILE_SET cxx_modules TYPE CXX_MODULES FILES
foo.cxx
)
target_compile_features(foo PUBLIC cxx_std_20)
add_executable(hello main.cxx)
target_link_libraries(hello PRIVATE foo)
target_compile_features(hello PRIVATE cxx_std_20)
Niestety, po próbie odpalenia dostaje blad:
CMake Warning (dev) at CMakeLists.txt:11 (target_sources):
CMake's C++ module support is experimental. It is meant only for
experimentation and feedback to CMake developers.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done (0.0s)
CMake Error in CMakeLists.txt:
The "foo" target contains C++ module sources which are not supported by the
generator