cxxmodules: Fix exported path to installed module sources in subdirs

When generating the `IMPORTED_CXX_MODULES_[CONFIG]` target property,
there was a missing path separator after a non-empty relative directory
part of the path to a module source file.

Co-authored-by: Brad King <brad.king@kitware.com>
This commit is contained in:
Tyler 2023-05-12 18:58:35 -06:00 committed by Brad King
parent f2a699261b
commit 28ece63fee
19 changed files with 68 additions and 6 deletions

View File

@ -358,6 +358,10 @@ cmDyndepCollation::ParseExportInfo(Json::Value const& tdi)
fsi.Name = tdi_cxx_module_info["name"].asString();
fsi.RelativeDirectory =
tdi_cxx_module_info["relative-directory"].asString();
if (!fsi.RelativeDirectory.empty() &&
fsi.RelativeDirectory.back() != '/') {
fsi.RelativeDirectory = cmStrCat(fsi.RelativeDirectory, '/');
}
fsi.SourcePath = tdi_cxx_module_info["source"].asString();
fsi.Type = tdi_cxx_module_info["type"].asString();
fsi.Visibility = cmFileSetVisibilityFromName(

View File

@ -18,7 +18,9 @@ target_sources(export_bmi_and_interfaces
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
importable.cxx
subdir/importable.cxx
)
target_compile_features(export_bmi_and_interfaces PUBLIC cxx_std_20)
add_library(no_modules STATIC no_modules.cxx)

View File

@ -0,0 +1,6 @@
export module subdir_importable;
export int from_subdir()
{
return 0;
}

View File

@ -21,6 +21,7 @@ get_property(file_set_files TARGET CXXModules::export_bmi_and_interfaces
PROPERTY CXX_MODULE_SET_modules)
set(expected_file_set_files
"${expected_source_dir}/importable.cxx"
"${expected_source_dir}/subdir/importable.cxx"
)
if (NOT file_set_files STREQUAL "${expected_file_set_files}")
message(FATAL_ERROR
@ -31,6 +32,7 @@ get_property(imported_modules TARGET CXXModules::export_bmi_and_interfaces
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
set(expected_imported_modules
"importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/CMakeFiles/export_bmi_and_interfaces.dir(/Debug)?/importable.(gcm|pcm|ifc)"
"subdir_importable=${expected_source_dir}/subdir/importable.cxx,${expected_binary_dir}/CMakeFiles/export_bmi_and_interfaces.dir(/Debug)?/subdir_importable.(gcm|pcm|ifc)"
)
if (NOT imported_modules MATCHES "^${expected_imported_modules}$")
message(FATAL_ERROR

View File

@ -18,7 +18,9 @@ target_sources(export_bmi_and_interfaces
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
importable.cxx
subdir/importable.cxx
)
target_compile_features(export_bmi_and_interfaces PUBLIC cxx_std_20)
add_library(no_modules STATIC no_modules.cxx)

View File

@ -0,0 +1,6 @@
export module subdir_importable;
export int from_subdir()
{
return 0;
}

View File

@ -21,6 +21,7 @@ get_property(file_set_files TARGET CXXModules::export_bmi_and_interfaces
PROPERTY CXX_MODULE_SET_modules)
set(expected_file_set_files
"${expected_source_dir}/importable.cxx"
"${expected_source_dir}/subdir/importable.cxx"
)
if (NOT file_set_files STREQUAL "${expected_file_set_files}")
message(FATAL_ERROR
@ -31,6 +32,7 @@ get_property(imported_modules TARGET CXXModules::export_bmi_and_interfaces
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
set(expected_imported_modules
"importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/importable.(gcm|pcm|ifc)"
"subdir_importable=${expected_source_dir}/subdir/importable.cxx,${expected_binary_dir}/subdir_importable.(gcm|pcm|ifc)"
)
if (NOT imported_modules MATCHES "^${expected_imported_modules}$")
message(FATAL_ERROR

View File

@ -18,7 +18,9 @@ target_sources(export_interfaces
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
importable.cxx
subdir/importable.cxx
)
target_compile_features(export_interfaces PUBLIC cxx_std_20)
add_library(no_modules STATIC no_modules.cxx)

View File

@ -0,0 +1,6 @@
export module subdir_importable;
export int from_subdir()
{
return 0;
}

View File

@ -21,6 +21,7 @@ get_property(file_set_files TARGET CXXModules::export_interfaces
PROPERTY CXX_MODULE_SET_modules)
set(expected_file_set_files
"${expected_source_dir}/importable.cxx"
"${expected_source_dir}/subdir/importable.cxx"
)
if (NOT file_set_files STREQUAL "${expected_file_set_files}")
message(FATAL_ERROR
@ -31,6 +32,7 @@ get_property(imported_modules TARGET CXXModules::export_interfaces
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
set(expected_imported_modules
"importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/CMakeFiles/export_interfaces.dir(/Debug)?/importable.(gcm|pcm|ifc)"
"subdir_importable=${expected_source_dir}/subdir/importable.cxx,${expected_binary_dir}/CMakeFiles/export_interfaces.dir(/Debug)?/subdir_importable.(gcm|pcm|ifc)"
)
if (NOT imported_modules MATCHES "^${expected_imported_modules}$")
message(FATAL_ERROR

View File

@ -18,7 +18,9 @@ target_sources(export_interfaces
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
importable.cxx
subdir/importable.cxx
)
target_compile_features(export_interfaces PUBLIC cxx_std_20)
add_library(no_modules STATIC no_modules.cxx)

View File

@ -0,0 +1,6 @@
export module subdir_importable;
export int from_subdir()
{
return 0;
}

View File

@ -21,6 +21,7 @@ get_property(file_set_files TARGET CXXModules::export_interfaces
PROPERTY CXX_MODULE_SET_modules)
set(expected_file_set_files
"${expected_source_dir}/importable.cxx"
"${expected_source_dir}/subdir/importable.cxx"
)
if (NOT file_set_files STREQUAL "${expected_file_set_files}")
message(FATAL_ERROR
@ -31,6 +32,7 @@ get_property(imported_modules TARGET CXXModules::export_interfaces
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
set(expected_imported_modules
"importable=${expected_source_dir}/importable.cxx"
"subdir_importable=${expected_source_dir}/subdir/importable.cxx"
)
if (NOT imported_modules STREQUAL "${expected_imported_modules}")
message(FATAL_ERROR

View File

@ -18,7 +18,9 @@ target_sources(export_interfaces_no_properties
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
importable.cxx
subdir/importable.cxx
)
target_compile_features(export_interfaces_no_properties PUBLIC cxx_std_20)
add_library(no_modules STATIC no_modules.cxx)

View File

@ -0,0 +1,6 @@
export module subdir_importable;
export int from_subdir()
{
return 0;
}

View File

@ -21,6 +21,7 @@ get_property(file_set_files TARGET CXXModules::export_interfaces_no_properties
PROPERTY CXX_MODULE_SET_modules)
set(expected_file_set_files
"${expected_dir}/importable.cxx"
"${expected_dir}/subdir/importable.cxx"
)
if (NOT file_set_files STREQUAL "${expected_file_set_files}")
message(FATAL_ERROR

View File

@ -18,7 +18,9 @@ target_sources(export_interfaces_no_properties
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
importable.cxx
subdir/importable.cxx
)
target_compile_features(export_interfaces_no_properties PUBLIC cxx_std_20)
add_library(no_modules STATIC no_modules.cxx)

View File

@ -0,0 +1,6 @@
export module subdir_importable;
export int from_subdir()
{
return 0;
}

View File

@ -21,6 +21,7 @@ get_property(file_set_files TARGET CXXModules::export_interfaces_no_properties
PROPERTY CXX_MODULE_SET_modules)
set(expected_file_set_files
"${expected_dir}/importable.cxx"
"${expected_dir}/subdir/importable.cxx"
)
if (NOT file_set_files STREQUAL "${expected_file_set_files}")
message(FATAL_ERROR