mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-01 11:50:11 -05:00
Tests/CXXModules: add a test importing from a Ninja install
This ensures that consuming from a single configuration generator works in all generators. See: #25568
This commit is contained in:
@@ -335,3 +335,7 @@ endfunction ()
|
|||||||
|
|
||||||
# Installation happens within `run_cxx_module_test_ninja`.
|
# Installation happens within `run_cxx_module_test_ninja`.
|
||||||
set(RunCMake_CXXModules_INSTALL 0)
|
set(RunCMake_CXXModules_INSTALL 0)
|
||||||
|
|
||||||
|
set(test_set modules-from-ninja)
|
||||||
|
run_cxx_module_test_ninja("export-${test_set}")
|
||||||
|
run_cxx_module_test(import-modules "import-${test_set}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-${test_set}-ninja-install" -DFROM_NINJA=1)
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24...3.28)
|
||||||
|
project(cxx_modules_export_from_ninja CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(export_from_ninja STATIC)
|
||||||
|
target_sources(export_from_ninja
|
||||||
|
PRIVATE
|
||||||
|
forward.cxx
|
||||||
|
PRIVATE
|
||||||
|
FILE_SET modules_private TYPE CXX_MODULES
|
||||||
|
BASE_DIRS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
FILES
|
||||||
|
private.cxx
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET modules TYPE CXX_MODULES
|
||||||
|
BASE_DIRS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
FILES
|
||||||
|
importable.cxx
|
||||||
|
subdir/importable.cxx
|
||||||
|
)
|
||||||
|
target_compile_features(export_from_ninja PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
add_library(no_modules STATIC no_modules.cxx)
|
||||||
|
|
||||||
|
install(TARGETS export_from_ninja no_modules
|
||||||
|
EXPORT CXXModules
|
||||||
|
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||||
|
install(EXPORT CXXModules
|
||||||
|
NAMESPACE CXXModules::
|
||||||
|
DESTINATION "lib/cmake/export_from_ninja"
|
||||||
|
FILE "export_from_ninja-targets.cmake"
|
||||||
|
CXX_MODULES_DIRECTORY "export_from_ninja-cxx-modules")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_from_ninja-config.cmake"
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_from_ninja-targets.cmake\")
|
||||||
|
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
|
||||||
|
")
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_from_ninja-config.cmake"
|
||||||
|
DESTINATION "lib/cmake/export_from_ninja")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import priv;
|
||||||
|
|
||||||
|
int forwarding()
|
||||||
|
{
|
||||||
|
return from_private();
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
extern "C++" {
|
||||||
|
int forwarding();
|
||||||
|
}
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return forwarding();
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
void no_modules()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module priv;
|
||||||
|
|
||||||
|
export int from_private()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module subdir_importable;
|
||||||
|
|
||||||
|
export int from_subdir()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ elseif (WITH_BMIS)
|
|||||||
set(package_name "export_bmi_and_interfaces")
|
set(package_name "export_bmi_and_interfaces")
|
||||||
elseif (INCLUDE_PROPERTIES)
|
elseif (INCLUDE_PROPERTIES)
|
||||||
set(package_name "export_include_directories")
|
set(package_name "export_include_directories")
|
||||||
|
elseif (FROM_NINJA)
|
||||||
|
set(package_name "export_from_ninja")
|
||||||
else ()
|
else ()
|
||||||
set(package_name "export_interfaces")
|
set(package_name "export_interfaces")
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
Reference in New Issue
Block a user