mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-27 18:28:20 +00:00
c++modules: Remove remaining restrictions on config-sensitive module paths
This commit is contained in:
committed by
Brad King
parent
cd7328bd29
commit
55f60d918d
@@ -10,11 +10,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/string_view>
|
||||
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmExportSet.h"
|
||||
#include "cmFileSetMetadata.h"
|
||||
#include "cmGenExContext.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
@@ -22,7 +19,6 @@
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
@@ -177,20 +173,6 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetDirectories(
|
||||
auto directories = fileSet->GetDirectories(context, gte);
|
||||
bool const contextSensitive = directories.second;
|
||||
|
||||
auto const& type = fileSet->GetType();
|
||||
// C++ modules do not support interface file sets which are dependent upon
|
||||
// the configuration.
|
||||
if (contextSensitive && type == cm::FileSetMetadata::CXX_MODULES) {
|
||||
auto* mf = this->LG->GetMakefile();
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR,
|
||||
cmStrCat("The \"", gte->GetName(),
|
||||
"\" target's interface file set \"",
|
||||
fileSet->GetName(), "\" of type \"", type,
|
||||
"\" contains context-sensitive base directory "
|
||||
"entries which is not supported."));
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
for (auto const& directory : directories.first) {
|
||||
auto dest = cmOutputConverter::EscapeForCMake(
|
||||
directory, cmOutputConverter::WrapQuotes::NoWrap);
|
||||
@@ -222,20 +204,6 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetFiles(
|
||||
auto files = fileSet->GetFiles(context, gte);
|
||||
bool const contextSensitive = files.second;
|
||||
|
||||
auto const& type = fileSet->GetType();
|
||||
// C++ modules do not support interface file sets which are dependent upon
|
||||
// the configuration.
|
||||
if (contextSensitive && type == cm::FileSetMetadata::CXX_MODULES) {
|
||||
auto* mf = this->LG->GetMakefile();
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR,
|
||||
cmStrCat("The \"", gte->GetName(),
|
||||
"\" target's interface file set \"",
|
||||
fileSet->GetName(), "\" of type \"", type,
|
||||
"\" contains context-sensitive file entries "
|
||||
"which is not supported."));
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
for (auto const& it : files.first) {
|
||||
for (auto const& filename : it.second) {
|
||||
auto escapedFile = cmOutputConverter::EscapeForCMake(
|
||||
|
||||
@@ -10,11 +10,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/string_view>
|
||||
|
||||
#include "cmExportFileGenerator.h"
|
||||
#include "cmExportSet.h"
|
||||
#include "cmFileSetMetadata.h"
|
||||
#include "cmGenExContext.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
@@ -24,7 +21,6 @@
|
||||
#include "cmInstallFileSetGenerator.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
@@ -295,21 +291,6 @@ std::string cmExportInstallCMakeConfigGenerator::GetFileSetDirectories(
|
||||
dest = cmStrCat("${_IMPORT_PREFIX}/", dest);
|
||||
}
|
||||
|
||||
auto const& type = fileSet->GetType();
|
||||
// C++ modules do not support interface file sets which are dependent upon
|
||||
// the configuration.
|
||||
if (result.HadContextSensitiveCondition &&
|
||||
type == cm::FileSetMetadata::CXX_MODULES) {
|
||||
auto* mf = this->IEGen->GetLocalGenerator()->GetMakefile();
|
||||
std::ostringstream e;
|
||||
e << "The \"" << gte->GetName() << "\" target's interface file set \""
|
||||
<< fileSet->GetName() << "\" of type \"" << type
|
||||
<< "\" contains context-sensitive base file entries which is not "
|
||||
"supported.";
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
if (result.HadContextSensitiveCondition && configs.size() != 1) {
|
||||
resultVector.push_back(
|
||||
cmStrCat("\"$<$<CONFIG:", config, ">:", dest, ">\""));
|
||||
@@ -350,20 +331,6 @@ std::string cmExportInstallCMakeConfigGenerator::GetFileSetFiles(
|
||||
|
||||
bool const contextSensitive =
|
||||
destCge->GetHadContextSensitiveCondition() || files.second;
|
||||
auto const& type = fileSet->GetType();
|
||||
// C++ modules do not support interface file sets which are dependent upon
|
||||
// the configuration.
|
||||
if (contextSensitive && type == cm::FileSetMetadata::CXX_MODULES) {
|
||||
auto* mf = this->IEGen->GetLocalGenerator()->GetMakefile();
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR,
|
||||
cmStrCat("The \"", gte->GetName(),
|
||||
"\" target's interface file set \"",
|
||||
fileSet->GetName(), "\" of type \"", type,
|
||||
"\" contains context-sensitive base file "
|
||||
"entries which is not supported."));
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
for (auto const& it : files.first) {
|
||||
auto prefix = it.first.empty() ? "" : cmStrCat(it.first, '/');
|
||||
for (auto const& filename : it.second) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -236,20 +235,6 @@ cmExportInstallPackageInfoGenerator::GetFileSetDirectory(
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string const& type = fileSet->GetType();
|
||||
if (config && (type == cm::FileSetMetadata::CXX_MODULES)) {
|
||||
// C++ modules do not support interface file sets which are dependent
|
||||
// upon the configuration.
|
||||
cmMakefile* mf = gte->LocalGenerator->GetMakefile();
|
||||
std::ostringstream e;
|
||||
e << "The \"" << gte->GetName() << "\" target's interface file set \""
|
||||
<< fileSet->GetName() << "\" of type \"" << type
|
||||
<< "\" contains context-sensitive base file entries which is not "
|
||||
"supported.";
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
||||
return {};
|
||||
}
|
||||
|
||||
cm::optional<std::string> dest = cmOutputConverter::EscapeForCMake(
|
||||
result.UnescapedDestination, cmOutputConverter::WrapQuotes::NoWrap);
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/lib/cmake/export-modules/export-modules-targets.cmake" export_script)
|
||||
|
||||
if (NOT export_script MATCHES [[include\("\${CMAKE_CURRENT_LIST_DIR}/cxx-modules/cxx-modules-exp\.cmake"\)]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module property script inclusion")
|
||||
endif ()
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
if (NOT export_script MATCHES [[\$<\$<CONFIG:Debug>:.*sources/debug]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find config-specific Debug genex in export file")
|
||||
endif ()
|
||||
if (NOT export_script MATCHES [[\$<\$<CONFIG:Release>:.*sources/release]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find config-specific Release genex in export file")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/lib/cmake/export-modules/cxx-modules/cxx-modules-exp.cmake" trampoline_script)
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
if (NOT trampoline_script MATCHES [[include\("\${CMAKE_CURRENT_LIST_DIR}/cxx-modules-exp-[^.]*\.cmake" OPTIONAL\)]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module property per-config script inclusion(s)")
|
||||
endif ()
|
||||
else ()
|
||||
if (NOT trampoline_script MATCHES [[include\("\${CMAKE_CURRENT_LIST_DIR}/cxx-modules-exp-[^.]*\.cmake"\)]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module property per-config script inclusion(s)")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set(any_exists 0)
|
||||
foreach (config IN ITEMS noconfig Debug Release RelWithDebInfo MinSizeRel)
|
||||
if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/lib/cmake/export-modules/cxx-modules/cxx-modules-exp-${config}.cmake")
|
||||
continue ()
|
||||
endif ()
|
||||
set(any_exists 1)
|
||||
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/lib/cmake/export-modules/cxx-modules/cxx-modules-exp-${config}.cmake" config_script)
|
||||
|
||||
if (NOT config_script MATCHES "include\\(\"\\\${CMAKE_CURRENT_LIST_DIR}/target-export-name-${config}\\.cmake\"\\)")
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module per-target property script inclusion")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
if (NOT any_exists)
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"No per-configuration target files exist.")
|
||||
endif ()
|
||||
|
||||
string(REPLACE ";" "; " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")
|
||||
24
Tests/RunCMake/CXXModules/ExportBuildCxxModulesConfig.cmake
Normal file
24
Tests/RunCMake/CXXModules/ExportBuildCxxModulesConfig.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
enable_language(CXX)
|
||||
set(CMAKE_CXX_SCANDEP_SOURCE "")
|
||||
|
||||
add_library(export-modules)
|
||||
target_sources(export-modules
|
||||
PUBLIC
|
||||
FILE_SET fs TYPE CXX_MODULES
|
||||
BASE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,sources/debug,sources/release>"
|
||||
FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,sources/debug,sources/release>/module.cxx")
|
||||
target_compile_features(export-modules
|
||||
PRIVATE
|
||||
cxx_std_20)
|
||||
set_property(TARGET export-modules
|
||||
PROPERTY EXPORT_NAME export-name)
|
||||
|
||||
install(TARGETS export-modules
|
||||
EXPORT exp
|
||||
FILE_SET fs DESTINATION "include/cxx/export-modules")
|
||||
|
||||
export(EXPORT exp
|
||||
FILE "${CMAKE_BINARY_DIR}/lib/cmake/export-modules/export-modules-targets.cmake"
|
||||
CXX_MODULES_DIRECTORY "cxx-modules")
|
||||
@@ -0,0 +1,49 @@
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/eee57a7e91412f1be699e9b63fa9d601/exp.cmake" export_script)
|
||||
|
||||
# Check for C++ module trampoline include.
|
||||
if (NOT export_script MATCHES [[include\("\${CMAKE_CURRENT_LIST_DIR}/cxx-modules/cxx-modules-exp\.cmake"\)]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module property script inclusion")
|
||||
endif ()
|
||||
|
||||
# Verify config-specific generator expressions for multi-config generators.
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
if (NOT export_script MATCHES [[\$<\$<CONFIG:Debug>:.*cxx/debug]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find config-specific Debug genex in export file")
|
||||
endif ()
|
||||
if (NOT export_script MATCHES [[\$<\$<CONFIG:Release>:.*cxx/release]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find config-specific Release genex in export file")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Verify per-config C++ module script inclusion exists.
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/eee57a7e91412f1be699e9b63fa9d601/cxx-modules/cxx-modules-exp.cmake" trampoline_script)
|
||||
|
||||
if (NOT trampoline_script MATCHES [[file\(GLOB _cmake_cxx_module_includes "\${CMAKE_CURRENT_LIST_DIR}/cxx-modules-exp-\*\.cmake"\)]])
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module property per-config script inclusion(s)")
|
||||
endif ()
|
||||
|
||||
set(any_exists 0)
|
||||
foreach (config IN ITEMS noconfig Debug Release RelWithDebInfo MinSizeRel)
|
||||
if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/eee57a7e91412f1be699e9b63fa9d601/cxx-modules/cxx-modules-exp-${config}.cmake")
|
||||
continue ()
|
||||
endif ()
|
||||
set(any_exists 1)
|
||||
|
||||
file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/eee57a7e91412f1be699e9b63fa9d601/cxx-modules/cxx-modules-exp-${config}.cmake" config_script)
|
||||
|
||||
if (NOT config_script MATCHES "include\\(\"\\\${CMAKE_CURRENT_LIST_DIR}/target-export-name-${config}\\.cmake\"\\)")
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"Could not find C++ module per-target property script inclusion")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
if (NOT any_exists)
|
||||
list(APPEND RunCMake_TEST_FAILED
|
||||
"No per-configuration target files exist.")
|
||||
endif ()
|
||||
|
||||
string(REPLACE ";" "; " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")
|
||||
@@ -0,0 +1,26 @@
|
||||
set(CMAKE_INTERMEDIATE_DIR_STRATEGY FULL CACHE STRING "" FORCE)
|
||||
|
||||
enable_language(CXX)
|
||||
set(CMAKE_CXX_SCANDEP_SOURCE "")
|
||||
|
||||
add_library(export-modules)
|
||||
target_sources(export-modules
|
||||
PUBLIC
|
||||
FILE_SET fs TYPE CXX_MODULES
|
||||
BASE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,sources/debug,sources/release>"
|
||||
FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,sources/debug,sources/release>/module.cxx")
|
||||
target_compile_features(export-modules
|
||||
PRIVATE
|
||||
cxx_std_20)
|
||||
set_property(TARGET export-modules
|
||||
PROPERTY EXPORT_NAME export-name)
|
||||
|
||||
install(TARGETS export-modules
|
||||
EXPORT exp
|
||||
FILE_SET fs DESTINATION "include/cxx/$<IF:$<CONFIG:Debug>,debug,release>")
|
||||
|
||||
install(EXPORT exp
|
||||
DESTINATION "lib/cmake/export-modules"
|
||||
CXX_MODULES_DIRECTORY "cxx-modules")
|
||||
@@ -122,8 +122,10 @@ if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio ")
|
||||
endif()
|
||||
|
||||
run_cmake(ExportBuildCxxModules)
|
||||
run_cmake(ExportBuildCxxModulesConfig)
|
||||
run_cmake(ExportBuildCxxModulesTargets)
|
||||
run_cmake(ExportInstallCxxModules)
|
||||
run_cmake(ExportInstallCxxModulesConfig)
|
||||
|
||||
# Generator-specific tests.
|
||||
if (RunCMake_GENERATOR MATCHES "Ninja")
|
||||
|
||||
5
Tests/RunCMake/CXXModules/sources/debug/module.cxx
Normal file
5
Tests/RunCMake/CXXModules/sources/debug/module.cxx
Normal file
@@ -0,0 +1,5 @@
|
||||
export module M;
|
||||
export import M:part;
|
||||
import M:internal_part;
|
||||
|
||||
int f();
|
||||
5
Tests/RunCMake/CXXModules/sources/release/module.cxx
Normal file
5
Tests/RunCMake/CXXModules/sources/release/module.cxx
Normal file
@@ -0,0 +1,5 @@
|
||||
export module M;
|
||||
export import M:part;
|
||||
import M:internal_part;
|
||||
|
||||
int f();
|
||||
@@ -109,7 +109,11 @@ function (run_cxx_module_test directory)
|
||||
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${test_name}-build")
|
||||
|
||||
if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)
|
||||
if (RunCMake_CXXModules_CONFIGS)
|
||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=${RunCMake_CXXModules_CONFIGS}")
|
||||
else ()
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)
|
||||
endif ()
|
||||
else ()
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
|
||||
endif ()
|
||||
@@ -338,6 +342,7 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(exp-trans-mods1-build)
|
||||
run_cxx_module_test(exp-trans-mods-build exp-trans-mods-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/exp-trans-mods1-build-build")
|
||||
run_cxx_module_test(exp-with-headers-build)
|
||||
run_cxx_module_test(exp-iface-config-build)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
|
||||
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
@@ -349,6 +354,7 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_import_test(build exp-trans-targets-build -DTRANSITIVE_TARGETS=1)
|
||||
run_cxx_module_import_test(build exp-trans-mods-build -DTRANSITIVE_MODULES=1)
|
||||
run_cxx_module_import_test(build exp-with-headers-build -DWITH_HEADERS=1)
|
||||
run_cxx_module_import_test(build exp-iface-config-build -DCONFIG_MODULES=1)
|
||||
|
||||
if ("build_database" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
setup_export_build_database_targets()
|
||||
@@ -380,6 +386,11 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(exp-trans-mods1-install)
|
||||
run_cxx_module_test(exp-trans-mods-install exp-trans-mods-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/exp-trans-mods1-install-install" "-Dexport_transitive_modules1_cps_DIR=${RunCMake_BINARY_DIR}/exp-trans-mods1-install-install/lib/cmake/export_transitive_modules1_cps")
|
||||
run_cxx_module_test(exp-with-headers-install)
|
||||
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(RunCMake_CXXModules_CONFIGS "Debug\\;Release")
|
||||
endif()
|
||||
run_cxx_module_test(exp-iface-config-install)
|
||||
unset(RunCMake_CXXModules_CONFIGS)
|
||||
|
||||
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
|
||||
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
@@ -391,6 +402,7 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_import_test(install exp-trans-targets-install -DTRANSITIVE_TARGETS=1)
|
||||
run_cxx_module_import_test(install exp-trans-mods-install -DTRANSITIVE_MODULES=1)
|
||||
run_cxx_module_import_test(install exp-with-headers-install -DWITH_HEADERS=1)
|
||||
run_cxx_module_import_test(install exp-iface-config-install -DCONFIG_MODULES=1)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
cmake_minimum_required(VERSION 4.3)
|
||||
project(cxx_modules_export_interface_config CXX)
|
||||
|
||||
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||
|
||||
add_library(export_interface_config STATIC)
|
||||
target_sources(export_interface_config
|
||||
PUBLIC
|
||||
FILE_SET modules TYPE CXX_MODULES
|
||||
BASE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>"
|
||||
FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/module.cxx"
|
||||
)
|
||||
target_compile_features(export_interface_config PUBLIC cxx_std_20)
|
||||
|
||||
install(TARGETS export_interface_config
|
||||
EXPORT CXXModules
|
||||
FILE_SET modules DESTINATION "lib/cxx/miu"
|
||||
)
|
||||
|
||||
export(EXPORT CXXModules
|
||||
NAMESPACE CXXModules::
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_interface_config-targets.cmake"
|
||||
CXX_MODULES_DIRECTORY "export_interface_config-cxx-modules"
|
||||
)
|
||||
export(PACKAGE_INFO export_interface_config_cps
|
||||
EXPORT CXXModules
|
||||
CXX_MODULES_DIRECTORY "export_interface_config-cxx-modules-cps"
|
||||
)
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interface_config-config.cmake"
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interface_config-targets.cmake\")\n"
|
||||
"set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)\n"
|
||||
)
|
||||
|
||||
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_interface_config_build
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-Dexpected_source_dir=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"-Dexpected_binary_dir=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"-DCMAKE_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
${generator}
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||
-B "${CMAKE_CURRENT_BINARY_DIR}/test"
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
export module importable;
|
||||
export int from_import()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export module importable;
|
||||
export int from_import()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
cmake_minimum_required(VERSION 4.3)
|
||||
project(cxx_modules_config_import NONE)
|
||||
|
||||
find_package(export_interface_config REQUIRED)
|
||||
find_package(export_interface_config_cps CONFIG REQUIRED)
|
||||
|
||||
function(test_target target set_name)
|
||||
set(check_genex "${ARGV2}")
|
||||
if (NOT TARGET ${target})
|
||||
message(FATAL_ERROR "Missing imported target")
|
||||
endif ()
|
||||
|
||||
get_property(file_sets TARGET ${target}
|
||||
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||
if (NOT file_sets STREQUAL set_name)
|
||||
message(FATAL_ERROR
|
||||
"Incorrect exported file sets in ${target}:\n ${file_sets}")
|
||||
endif ()
|
||||
|
||||
get_property(file_set_files TARGET ${target}
|
||||
PROPERTY CXX_MODULE_SET_${set_name})
|
||||
|
||||
get_property(_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
# Verify the Debug module file is present in the file set.
|
||||
if (NOT file_set_files MATCHES "debug/module\.cxx")
|
||||
message(FATAL_ERROR
|
||||
"Expected debug module in file set:\n ${file_set_files}")
|
||||
endif ()
|
||||
|
||||
# For CMakeConfig, verify genex wrapping for both configs.
|
||||
if (check_genex AND _multi_config)
|
||||
if (NOT file_set_files MATCHES [[\$<\$<CONFIG:Debug>:.*debug/module\.cxx]])
|
||||
message(FATAL_ERROR
|
||||
"Missing Debug genex entry in file set:\n ${file_set_files}")
|
||||
endif ()
|
||||
if (NOT file_set_files MATCHES [[\$<\$<CONFIG:Release>:.*release/module\.cxx]])
|
||||
message(FATAL_ERROR
|
||||
"Missing Release genex entry in file set:\n ${file_set_files}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Verify IMPORTED_CXX_MODULES_DEBUG points to the Debug module.
|
||||
get_property(imported_modules_debug TARGET ${target}
|
||||
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
|
||||
if (NOT imported_modules_debug MATCHES "importable=.*debug/module\.cxx")
|
||||
message(FATAL_ERROR
|
||||
"Incorrect Debug module entry in IMPORTED_CXX_MODULES_DEBUG:\n ${imported_modules_debug}")
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
test_target(CXXModules::export_interface_config "modules" FALSE)
|
||||
test_target(export_interface_config_cps::export_interface_config "CXX_MODULES" FALSE)
|
||||
@@ -0,0 +1,63 @@
|
||||
cmake_minimum_required(VERSION 4.3)
|
||||
project(cxx_modules_export_interface_config CXX)
|
||||
|
||||
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||
|
||||
add_library(export_interface_config STATIC)
|
||||
target_sources(export_interface_config
|
||||
PUBLIC
|
||||
FILE_SET modules TYPE CXX_MODULES
|
||||
BASE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>"
|
||||
FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/module.cxx"
|
||||
)
|
||||
target_compile_features(export_interface_config PUBLIC cxx_std_20)
|
||||
|
||||
install(TARGETS export_interface_config
|
||||
EXPORT CXXModules
|
||||
FILE_SET modules DESTINATION "lib/cxx/miu"
|
||||
)
|
||||
|
||||
install(EXPORT CXXModules
|
||||
NAMESPACE CXXModules::
|
||||
DESTINATION "lib/cmake/export_interface_config"
|
||||
FILE "export_interface_config-targets.cmake"
|
||||
CXX_MODULES_DIRECTORY "export_interface_config-cxx-modules"
|
||||
)
|
||||
install(PACKAGE_INFO "export_interface_config_cps"
|
||||
EXPORT CXXModules
|
||||
DESTINATION "lib/cmake/export_interface_config_cps"
|
||||
CXX_MODULES_DIRECTORY "export_interface_config-cxx-modules-cps"
|
||||
)
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interface_config-config.cmake"
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interface_config-targets.cmake\")\n"
|
||||
"set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)\n"
|
||||
)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_interface_config-config.cmake"
|
||||
DESTINATION "lib/cmake/export_interface_config"
|
||||
)
|
||||
|
||||
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_interface_config_build
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-Dexpected_source_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
|
||||
"-Dexpected_binary_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/bmi"
|
||||
"-Dexport_interface_config_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_interface_config"
|
||||
"-Dexport_interface_config_cps_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_interface_config_cps"
|
||||
${generator}
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||
-B "${CMAKE_CURRENT_BINARY_DIR}/test"
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
export module importable;
|
||||
export int from_import()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export module importable;
|
||||
export int from_import()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
cmake_minimum_required(VERSION 4.3)
|
||||
project(cxx_modules_config_import NONE)
|
||||
|
||||
find_package(export_interface_config REQUIRED)
|
||||
find_package(export_interface_config_cps CONFIG REQUIRED)
|
||||
|
||||
get_property(_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
function(test_target target set_name)
|
||||
set(check_genex "${ARGV2}")
|
||||
if (NOT TARGET ${target})
|
||||
message(FATAL_ERROR "Missing imported target")
|
||||
endif ()
|
||||
|
||||
get_property(file_sets TARGET ${target}
|
||||
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||
if (NOT file_sets STREQUAL set_name)
|
||||
message(FATAL_ERROR
|
||||
"Incorrect exported file sets in ${target}:\n ${file_sets}")
|
||||
endif ()
|
||||
|
||||
get_property(file_set_files TARGET ${target}
|
||||
PROPERTY CXX_MODULE_SET_${set_name})
|
||||
|
||||
# Verify module.cxx is present in the file set.
|
||||
if (NOT file_set_files MATCHES "module\.cxx")
|
||||
message(FATAL_ERROR
|
||||
"Expected module.cxx in file set:\n ${file_set_files}")
|
||||
endif ()
|
||||
|
||||
# For CMakeConfig, verify genex wrapping for both configs.
|
||||
if (check_genex AND _multi_config)
|
||||
if (NOT file_set_files MATCHES [[\$<\$<CONFIG:Debug>:.*module\.cxx]])
|
||||
message(FATAL_ERROR
|
||||
"Missing Debug genex entry in file set:\n ${file_set_files}")
|
||||
endif ()
|
||||
if (NOT file_set_files MATCHES [[\$<\$<CONFIG:Release>:.*module\.cxx]])
|
||||
message(FATAL_ERROR
|
||||
"Missing Release genex entry in file set:\n ${file_set_files}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Verify IMPORTED_CXX_MODULES_DEBUG points to the module.
|
||||
get_property(imported_modules_debug TARGET ${target}
|
||||
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
|
||||
if (NOT imported_modules_debug MATCHES "importable=.*module\.cxx")
|
||||
message(FATAL_ERROR
|
||||
"Incorrect Debug module entry in IMPORTED_CXX_MODULES_DEBUG:\n ${imported_modules_debug}")
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
test_target(CXXModules::export_interface_config "modules" TRUE)
|
||||
test_target(export_interface_config_cps::export_interface_config "CXX_MODULES" FALSE)
|
||||
@@ -19,6 +19,8 @@ elseif (TRANSITIVE_MODULES)
|
||||
set(package_name "export_transitive_modules")
|
||||
elseif (WITH_HEADERS)
|
||||
set(package_name "export_with_headers")
|
||||
elseif (CONFIG_MODULES)
|
||||
set(package_name "export_interface_config")
|
||||
elseif (BUILD_DATABASE)
|
||||
include("${CMAKE_SOURCE_DIR}/../export-build-database-setup.cmake")
|
||||
set(package_name "export_build_database")
|
||||
|
||||
Reference in New Issue
Block a user