mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Merge topic 'fix-mod-manifest-nested-dirs' into release-4.4
539b097bd8 CPS/c++modules: Use file system root as base directory for module manifests
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12326
This commit is contained in:
@@ -464,13 +464,19 @@ MetaDataProperties CollectMetaProperties(cmCxxModuleMetadata const& meta)
|
|||||||
|
|
||||||
props.MetadataDir = cmSystemTools::GetFilenamePath(meta.MetadataFilePath);
|
props.MetadataDir = cmSystemTools::GetFilenamePath(meta.MetadataFilePath);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
props.BaseDirs.insert("/");
|
||||||
|
#endif
|
||||||
|
|
||||||
for (auto const& module : meta.Modules) {
|
for (auto const& module : meta.Modules) {
|
||||||
std::string sourcePath = props.NormalizePath(module.SourcePath);
|
std::string sourcePath = props.NormalizePath(module.SourcePath);
|
||||||
props.Sources.insert(sourcePath);
|
props.Sources.insert(sourcePath);
|
||||||
|
|
||||||
// Module metadata files can reference files in different roots,
|
#ifdef _WIN32
|
||||||
// just use the immediate parent directory as a base directory
|
std::string root;
|
||||||
props.BaseDirs.insert(cmSystemTools::GetFilenamePath(sourcePath));
|
cmSystemTools::SplitPathRootComponent(sourcePath, &root);
|
||||||
|
props.BaseDirs.insert(root);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (module.LocalArguments) {
|
if (module.LocalArguments) {
|
||||||
for (auto const& incDir : module.LocalArguments->IncludeDirectories) {
|
for (auto const& incDir : module.LocalArguments->IncludeDirectories) {
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ endfunction ()
|
|||||||
|
|
||||||
# Tests which install BMIs
|
# Tests which install BMIs
|
||||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
|
run_cxx_module_test(exp-nested-dirs-build)
|
||||||
run_cxx_module_test(exp-iface-no-props-build)
|
run_cxx_module_test(exp-iface-no-props-build)
|
||||||
run_cxx_module_test(exp-iface-build)
|
run_cxx_module_test(exp-iface-build)
|
||||||
run_cxx_module_test(exp-incdirs-build)
|
run_cxx_module_test(exp-incdirs-build)
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24...3.28)
|
||||||
|
project(cxx_modules_nested_dirs CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(export_nested_dirs STATIC)
|
||||||
|
target_sources(export_nested_dirs
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET modules TYPE CXX_MODULES
|
||||||
|
BASE_DIRS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
FILES
|
||||||
|
nested/alpha.cxx
|
||||||
|
nested/sub/beta.cxx
|
||||||
|
)
|
||||||
|
target_compile_features(export_nested_dirs PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS export_nested_dirs
|
||||||
|
EXPORT CXXModules
|
||||||
|
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||||
|
export(EXPORT CXXModules
|
||||||
|
NAMESPACE CXXModules::
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_nested_dirs-targets.cmake"
|
||||||
|
CXX_MODULES_DIRECTORY "export_nested_dirs-cxx-modules")
|
||||||
|
export(PACKAGE_INFO export_nested_dirs_cps
|
||||||
|
EXPORT CXXModules
|
||||||
|
CXX_MODULES_DIRECTORY "export_nested_dirs-cxx-modules-cps")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_nested_dirs-config.cmake"
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_nested_dirs-targets.cmake\")
|
||||||
|
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
|
||||||
|
")
|
||||||
|
|
||||||
|
set(generator
|
||||||
|
-G "${CMAKE_GENERATOR}")
|
||||||
|
if (CMAKE_GENERATOR_TOOLSET)
|
||||||
|
list(APPEND generator
|
||||||
|
-T "${CMAKE_GENERATOR_TOOLSET}")
|
||||||
|
endif ()
|
||||||
|
if (CMAKE_GENERATOR_PLATFORM)
|
||||||
|
list(APPEND generator
|
||||||
|
-A "${CMAKE_GENERATOR_PLATFORM}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_test(NAME export_nested_dirs_build
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
${generator}
|
||||||
|
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||||
|
-B "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module nested_alpha;
|
||||||
|
|
||||||
|
export int from_alpha()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module nested_sub_beta;
|
||||||
|
|
||||||
|
export int from_beta()
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.28)
|
||||||
|
project(cxx_modules_library NONE)
|
||||||
|
|
||||||
|
find_package(export_nested_dirs REQUIRED)
|
||||||
|
find_package(export_nested_dirs_cps REQUIRED)
|
||||||
Reference in New Issue
Block a user