cxxmodules: transitive cxx_std_20 missing in synthesized targets
When I have several CMake targets that include each other, PUBLIC
and INTERFACE
target_compile_features
should be propagated to the parent targets. This works for a long time for "old" translation units but not for C++ modules. When I create a target core
that sets it and the main target that just links with it:
add_library(my_library_core)
target_compile_features(my_library_core PUBLIC cxx_std_20)
add_library(my_library)
target_link_libraries(my_library PUBLIC my_library_core)
the property is not propagated properly during installation and I get:
CMake Error in CMakeLists.txt:
The target named "my_library__my_library@synth_6a7393560405" has C++
sources that use modules, but does not include "cxx_std_20" (or newer)
among its `target_compile_features`; no C++ standard found.
See the attached sample project for more details: bug.tgz
To build it:
cd my_library
mkdir build && cd build
cmake .. -DCMAKE_CXX_COMPILER=clang-17 -G "Ninja Multi-Config"
cmake --build . --config Release
cmake --install . --config Release --prefix ../../local
cd ../../application
mkdir build && cd build
cmake .. -DCMAKE_CXX_COMPILER=clang-17 -G "Ninja Multi-Config" -DCMAKE_INSTALL_PREFIX=../../local
cmake --build . --config Release