diff options
11 files changed, 254 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ce4248c..86ae45d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -28,6 +28,7 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalNinjaGenerator.h" +#include "cmInstallCxxModuleBmiGenerator.h" #include "cmInstallExportGenerator.h" #include "cmInstallFileSetGenerator.h" #include "cmInstallGenerator.h" @@ -1763,6 +1764,43 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang, Json::Value& tdi_exports = tdi["exports"] = Json::arrayValue; std::string export_name = this->GeneratorTarget->GetExportName(); + cmInstallCxxModuleBmiGenerator const* bmi_gen = nullptr; + for (auto const& ig : this->GetMakefile()->GetInstallGenerators()) { + if (auto const* bmig = + dynamic_cast<cmInstallCxxModuleBmiGenerator const*>(ig.get())) { + if (bmig->GetTarget() == this->GeneratorTarget) { + bmi_gen = bmig; + continue; + } + } + } + if (bmi_gen) { + Json::Value tdi_bmi_info = Json::objectValue; + + tdi_bmi_info["permissions"] = bmi_gen->GetFilePermissions(); + tdi_bmi_info["destination"] = bmi_gen->GetDestination(config); + const char* msg_level = ""; + switch (bmi_gen->GetMessageLevel()) { + case cmInstallGenerator::MessageDefault: + break; + case cmInstallGenerator::MessageAlways: + msg_level = "MESSAGE_ALWAYS"; + break; + case cmInstallGenerator::MessageLazy: + msg_level = "MESSAGE_LAZY"; + break; + case cmInstallGenerator::MessageNever: + msg_level = "MESSAGE_NEVER"; + break; + } + tdi_bmi_info["message-level"] = msg_level; + tdi_bmi_info["script-location"] = bmi_gen->GetScriptLocation(config); + + tdi["bmi-installation"] = tdi_bmi_info; + } else { + tdi["bmi-installation"] = Json::nullValue; + } + auto const& all_install_exports = this->GetGlobalGenerator()->GetExportSets(); for (auto const& exp : all_install_exports) { diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake new file mode 100644 index 0000000..0d08c44 --- /dev/null +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-check.cmake @@ -0,0 +1,34 @@ +include("${CMAKE_CURRENT_LIST_DIR}/check-json.cmake") + +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(have_file 0) + foreach (config IN ITEMS Release Debug RelWithDebInfo MinSizeRel) + if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/${config}/CXXDependInfo.json") + continue () + endif () + set(have_file 1) + + set(CMAKE_BUILD_TYPE "${config}") + + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-public.json" expect_contents) + check_json("${actual_contents}" "${expect_contents}") + + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-private.dir/${config}/CXXDependInfo.json" actual_contents) + file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-private.json" expect_contents) + check_json("${actual_contents}" "${expect_contents}") + endforeach () + + if (NOT have_file) + list(APPEND RunCMake_TEST_FAILED + "No recognized build configurations found.") + endif () +else () + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-public.dir/CXXDependInfo.json" actual_contents) + file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-public.json" expect_contents) + check_json("${actual_contents}" "${expect_contents}") + + file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-bmi-install-private.dir/CXXDependInfo.json" actual_contents) + file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoBMIInstall-private.json" expect_contents) + check_json("${actual_contents}" "${expect_contents}") +endif () diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt new file mode 100644 index 0000000..ebf7be5 --- /dev/null +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall-stderr.txt @@ -0,0 +1,11 @@ +CMake Warning \(dev\) at NinjaDependInfoBMIInstall.cmake:14 \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + CMakeLists.txt:6 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\): + C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is + experimental. It is meant only for compiler developers to try. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall.cmake new file mode 100644 index 0000000..32dc42d --- /dev/null +++ b/Tests/RunCMake/CXXModules/NinjaDependInfoBMIInstall.cmake @@ -0,0 +1,76 @@ +# Fake out that we have dyndep; we only need to generate, not actually build +# here. +set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1) +set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE "") + +enable_language(CXX) + +if (NOT CMAKE_GENERATOR MATCHES "Ninja") + message(FATAL_ERROR + "This test requires a 'Ninja' generator to be used.") +endif () + +add_library(ninja-bmi-install-public) +target_sources(ninja-bmi-install-public + PRIVATE + sources/module-impl.cxx + sources/module-internal-part-impl.cxx + sources/module-part-impl.cxx + sources/module-use.cxx + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}/sources" + FILES + sources/module.cxx + sources/module-part.cxx + FILE_SET internal_partitions TYPE CXX_MODULES FILES + sources/module-internal-part.cxx) +target_compile_features(ninja-bmi-install-public + PRIVATE + cxx_std_20) +set_property(TARGET ninja-bmi-install-public + PROPERTY EXPORT_NAME "with-public") + +install(TARGETS ninja-bmi-install-public + FILE_SET modules + DESTINATION "lib/cxx" + COMPONENT "modules" + FILE_SET internal_partitions + DESTINATION "lib/cxx/internals" + COMPONENT "modules-internal" + CXX_MODULES_BMI + DESTINATION "lib/cxx/modules/$<CONFIG>" + COMPONENT "bmi") + +add_library(ninja-bmi-install-private) +target_sources(ninja-bmi-install-private + PRIVATE + sources/module-impl.cxx + sources/module-internal-part-impl.cxx + sources/module-part-impl.cxx + sources/module-use.cxx + PRIVATE + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}/sources" + FILES + sources/module.cxx + sources/module-part.cxx + FILE_SET internal_partitions TYPE CXX_MODULES FILES + sources/module-internal-part.cxx) +target_compile_features(ninja-bmi-install-private + PRIVATE + cxx_std_20) +set_property(TARGET ninja-bmi-install-private + PROPERTY EXPORT_NAME "with-private") + +set(CMAKE_INSTALL_MESSAGE LAZY) +install(TARGETS ninja-bmi-install-private + CXX_MODULES_BMI + DESTINATION "lib/cxx/modules/private/$<CONFIG>" + PERMISSIONS + OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ + COMPONENT "bmi") diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index d3db1d4..34d9d53 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -78,6 +78,7 @@ run_cmake(ExportInstallCxxModules) if (RunCMake_GENERATOR MATCHES "Ninja") run_cmake(NinjaDependInfoFileSet) run_cmake(NinjaDependInfoExport) + run_cmake(NinjaDependInfoBMIInstall) else () message(FATAL_ERROR "Please add 'DependInfo' tests for the '${RunCMake_GENERATOR}' generator.") diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json new file mode 100644 index 0000000..65f0759 --- /dev/null +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-private.json @@ -0,0 +1,45 @@ +{ + "bmi-installation": { + "destination": "lib/cxx/modules/private/<CONFIG>", + "message-level": "MESSAGE_LAZY", + "permissions": " OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ", + "script-location": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-private.dir/install-cxx-module-bmi-<CONFIG_FORCE>.cmake" + }, + "compiler-id": "<IGNORE>", + "config": "<CONFIG>", + "cxx-modules": { + "CMakeFiles/ninja-bmi-install-private.dir/sources/module-internal-part.cxx.o": { + "destination": null, + "name": "internal_partitions", + "relative-directory": "sources", + "source": "<SOURCE_DIR>/sources/module-internal-part.cxx", + "type": "CXX_MODULES", + "visibility": "PRIVATE" + }, + "CMakeFiles/ninja-bmi-install-private.dir/sources/module-part.cxx.o": { + "destination": null, + "name": "modules", + "relative-directory": "", + "source": "<SOURCE_DIR>/sources/module-part.cxx", + "type": "CXX_MODULES", + "visibility": "PRIVATE" + }, + "CMakeFiles/ninja-bmi-install-private.dir/sources/module.cxx.o": { + "destination": null, + "name": "modules", + "relative-directory": "", + "source": "<SOURCE_DIR>/sources/module.cxx", + "type": "CXX_MODULES", + "visibility": "PRIVATE" + } + }, + "dir-cur-bld": "<BINARY_DIR>", + "dir-cur-src": "<SOURCE_DIR>", + "dir-top-bld": "<BINARY_DIR>", + "dir-top-src": "<SOURCE_DIR>", + "exports": [], + "include-dirs": [], + "language": "CXX", + "linked-target-dirs": [], + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-private.dir" +} diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json new file mode 100644 index 0000000..9c8a895 --- /dev/null +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoBMIInstall-public.json @@ -0,0 +1,45 @@ +{ + "bmi-installation": { + "destination": "lib/cxx/modules/<CONFIG>", + "message-level": "", + "permissions": "", + "script-location": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-public.dir/install-cxx-module-bmi-noconfig.cmake" + }, + "compiler-id": "<IGNORE>", + "config": "<CONFIG>", + "cxx-modules": { + "CMakeFiles/ninja-bmi-install-public.dir/sources/module-internal-part.cxx.o": { + "destination": "lib/cxx/internals", + "name": "internal_partitions", + "relative-directory": "sources", + "source": "<SOURCE_DIR>/sources/module-internal-part.cxx", + "type": "CXX_MODULES", + "visibility": "PUBLIC" + }, + "CMakeFiles/ninja-bmi-install-public.dir/sources/module-part.cxx.o": { + "destination": "lib/cxx", + "name": "modules", + "relative-directory": "", + "source": "<SOURCE_DIR>/sources/module-part.cxx", + "type": "CXX_MODULES", + "visibility": "PUBLIC" + }, + "CMakeFiles/ninja-bmi-install-public.dir/sources/module.cxx.o": { + "destination": "lib/cxx", + "name": "modules", + "relative-directory": "", + "source": "<SOURCE_DIR>/sources/module.cxx", + "type": "CXX_MODULES", + "visibility": "PUBLIC" + } + }, + "dir-cur-bld": "<BINARY_DIR>", + "dir-cur-src": "<SOURCE_DIR>", + "dir-top-bld": "<BINARY_DIR>", + "dir-top-src": "<SOURCE_DIR>", + "exports": [], + "include-dirs": [], + "language": "CXX", + "linked-target-dirs": [], + "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-bmi-install-public.dir" +} diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json index 6bff226..0545981 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json @@ -1,4 +1,5 @@ { + "bmi-installation": null, "compiler-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json index d17c50e..adc3ae3 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json @@ -1,4 +1,5 @@ { + "bmi-installation": null, "compiler-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json index d03cf1c..9ba6568 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json @@ -1,4 +1,5 @@ { + "bmi-installation": null, "compiler-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json index 6afce06..46e2cbf 100644 --- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json +++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json @@ -1,4 +1,5 @@ { + "bmi-installation": null, "compiler-id": "<IGNORE>", "config": "<CONFIG>", "cxx-modules": { |