cxxmodules: Consuming module from IMPORTED target fails evaluating include directories
Related to the feature merged in: !8535 (merged), which I'm testing using a recent nightly. I appreciate the feature is still unreleased - please disregard this issue report if it's not applicable.
The exporting project has code like this:
add_library(fmt)
target_sources(fmt
PUBLIC
FILE_SET fmt_module TYPE CXX_MODULES FILES src/fmt.cc
)
target_compile_features(fmt PUBLIC cxx_std_20)
target_include_directories(fmt ${FMT_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
The generated fmt-targets.cmake
contains this block:
# Create imported target fmt::fmt
add_library(fmt::fmt STATIC IMPORTED)
set_target_properties(fmt::fmt PROPERTIES
CXX_EXTENSIONS "OFF"
IMPORTED_CXX_MODULES_COMPILE_FEATURES "cxx_std_20;cxx_std_11"
IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES "include"
INTERFACE_COMPILE_FEATURES "cxx_std_20;cxx_std_11"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)
Which causes a consumer with find_package(fmt)
to fail during generation with the following error:
-- Configuring done (0.0s)
CMake Error in CMakeLists.txt:
Found relative path while evaluating include directories of
"fmt__fmt@synth_bd28099aa237":
"include"
-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
Manually editing the file to set IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES
to "${_IMPORT_PREFIX}/include"
fixes the issue - but unsure if this is a bug or if I'm missing or incorrectly setting a property in the exporting project.
Edited by Brad King