mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-14 05:20:50 -05:00
RunCMake/CXXModules: add tests which export BMIs
This commit is contained in:
@@ -147,6 +147,12 @@ if ("internal_partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
|||||||
run_cxx_module_test(internal-partitions)
|
run_cxx_module_test(internal-partitions)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# Tests which install BMIs
|
||||||
|
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
|
run_cxx_module_test(export-interface-build)
|
||||||
|
run_cxx_module_test(export-bmi-and-interface-build)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# All of the following tests perform installation.
|
# All of the following tests perform installation.
|
||||||
set(RunCMake_CXXModules_INSTALL 1)
|
set(RunCMake_CXXModules_INSTALL 1)
|
||||||
|
|
||||||
@@ -154,4 +160,9 @@ set(RunCMake_CXXModules_INSTALL 1)
|
|||||||
if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
run_cxx_module_test(install-bmi)
|
run_cxx_module_test(install-bmi)
|
||||||
run_cxx_module_test(install-bmi-and-interfaces)
|
run_cxx_module_test(install-bmi-and-interfaces)
|
||||||
|
|
||||||
|
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
|
run_cxx_module_test(export-interface-install)
|
||||||
|
run_cxx_module_test(export-bmi-and-interface-install)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
|
||||||
|
CMake's C\+\+ module support is experimental. It is meant only for
|
||||||
|
experimentation and feedback to CMake developers.
|
||||||
|
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.
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_export_bmi_and_interfaces CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(export_bmi_and_interfaces STATIC)
|
||||||
|
target_sources(export_bmi_and_interfaces
|
||||||
|
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)
|
||||||
|
target_compile_features(export_bmi_and_interfaces PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS export_bmi_and_interfaces
|
||||||
|
EXPORT CXXModules
|
||||||
|
FILE_SET modules DESTINATION "lib/cxx/miu"
|
||||||
|
CXX_MODULES_BMI DESTINATION "lib/cxx/bmi")
|
||||||
|
export(EXPORT CXXModules
|
||||||
|
NAMESPACE CXXModules::
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_bmi_and_interfaces-targets.cmake"
|
||||||
|
CXX_MODULES_DIRECTORY "export_bmi_and_interfaces-cxx-modules")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_bmi_and_interfaces-config.cmake"
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_bmi_and_interfaces-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_bmi_and_interfaces_build
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-Dexpected_source_dir=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
"-Dexpected_binary_dir=${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
"-Dexport_bmi_and_interfaces_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
${generator}
|
||||||
|
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||||
|
-B "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import priv;
|
||||||
|
|
||||||
|
int forwarding()
|
||||||
|
{
|
||||||
|
return from_private();
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
int forwarding();
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return forwarding();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module priv;
|
||||||
|
|
||||||
|
export int from_private()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_library NONE)
|
||||||
|
|
||||||
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
|
||||||
|
|
||||||
|
find_package(export_bmi_and_interfaces REQUIRED)
|
||||||
|
|
||||||
|
if (NOT TARGET CXXModules::export_bmi_and_interfaces)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Missing imported target")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_sets TARGET CXXModules::export_bmi_and_interfaces
|
||||||
|
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||||
|
if (NOT file_sets STREQUAL "modules")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file sets in `CXXModules::export_bmi_and_interfaces`: `${file_sets}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_set_files TARGET CXXModules::export_bmi_and_interfaces
|
||||||
|
PROPERTY CXX_MODULE_SET_modules)
|
||||||
|
if (NOT file_set_files STREQUAL "${expected_source_dir}/importable.cxx")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file set paths in CXXModules::export_bmi_and_interfaces`: `${file_set_files}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(imported_modules TARGET CXXModules::export_bmi_and_interfaces
|
||||||
|
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
|
||||||
|
if (NOT imported_modules MATCHES "importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/CMakeFiles/export_bmi_and_interfaces.dir(/Debug)?/importable.(gcm|pcm|ifc)")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported modules in CXXModules::export_bmi_and_interfaces`: `${imported_modules}`")
|
||||||
|
endif ()
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
|
||||||
|
CMake's C\+\+ module support is experimental. It is meant only for
|
||||||
|
experimentation and feedback to CMake developers.
|
||||||
|
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.
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_export_bmi_and_interfaces CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(export_bmi_and_interfaces STATIC)
|
||||||
|
target_sources(export_bmi_and_interfaces
|
||||||
|
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)
|
||||||
|
target_compile_features(export_bmi_and_interfaces PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS export_bmi_and_interfaces
|
||||||
|
EXPORT CXXModules
|
||||||
|
FILE_SET modules DESTINATION "lib/cxx/miu"
|
||||||
|
CXX_MODULES_BMI DESTINATION "lib/cxx/bmi")
|
||||||
|
install(EXPORT CXXModules
|
||||||
|
NAMESPACE CXXModules::
|
||||||
|
DESTINATION "lib/cmake/export_bmi_and_interfaces"
|
||||||
|
FILE "export_bmi_and_interfaces-targets.cmake"
|
||||||
|
CXX_MODULES_DIRECTORY "export_bmi_and_interfaces-cxx-modules")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_bmi_and_interfaces-config.cmake"
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_bmi_and_interfaces-targets.cmake\")
|
||||||
|
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
|
||||||
|
")
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_bmi_and_interfaces-config.cmake"
|
||||||
|
DESTINATION "lib/cmake/export_bmi_and_interfaces")
|
||||||
|
|
||||||
|
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_bmi_and_interfaces_build
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-Dexpected_source_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
|
||||||
|
"-Dexpected_binary_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/bmi"
|
||||||
|
"-Dexport_bmi_and_interfaces_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_bmi_and_interfaces"
|
||||||
|
${generator}
|
||||||
|
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||||
|
-B "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import priv;
|
||||||
|
|
||||||
|
int forwarding()
|
||||||
|
{
|
||||||
|
return from_private();
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
int forwarding();
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return forwarding();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module priv;
|
||||||
|
|
||||||
|
export int from_private()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_library NONE)
|
||||||
|
|
||||||
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
|
||||||
|
|
||||||
|
find_package(export_bmi_and_interfaces REQUIRED)
|
||||||
|
|
||||||
|
if (NOT TARGET CXXModules::export_bmi_and_interfaces)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Missing imported target")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_sets TARGET CXXModules::export_bmi_and_interfaces
|
||||||
|
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||||
|
if (NOT file_sets STREQUAL "modules")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file sets in `CXXModules::export_bmi_and_interfaces`: `${file_sets}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_set_files TARGET CXXModules::export_bmi_and_interfaces
|
||||||
|
PROPERTY CXX_MODULE_SET_modules)
|
||||||
|
if (NOT file_set_files STREQUAL "${expected_source_dir}/importable.cxx")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file set paths in CXXModules::export_bmi_and_interfaces`: `${file_set_files}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(imported_modules TARGET CXXModules::export_bmi_and_interfaces
|
||||||
|
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
|
||||||
|
if (NOT imported_modules MATCHES "importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/importable.(gcm|pcm|ifc)")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported modules in CXXModules::export_bmi_and_interfaces`: `${imported_modules}`")
|
||||||
|
endif ()
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
|
||||||
|
CMake's C\+\+ module support is experimental. It is meant only for
|
||||||
|
experimentation and feedback to CMake developers.
|
||||||
|
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.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_export_interfaces CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(export_interfaces STATIC)
|
||||||
|
target_sources(export_interfaces
|
||||||
|
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)
|
||||||
|
target_compile_features(export_interfaces PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS export_interfaces
|
||||||
|
EXPORT CXXModules
|
||||||
|
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||||
|
export(EXPORT CXXModules
|
||||||
|
NAMESPACE CXXModules::
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-targets.cmake")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-config.cmake"
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interfaces-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_interfaces_build
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-Dexpected_dir=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
"-Dexport_interfaces_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
${generator}
|
||||||
|
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||||
|
-B "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import priv;
|
||||||
|
|
||||||
|
int forwarding()
|
||||||
|
{
|
||||||
|
return from_private();
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
int forwarding();
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return forwarding();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module priv;
|
||||||
|
|
||||||
|
export int from_private()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_library NONE)
|
||||||
|
|
||||||
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
|
||||||
|
|
||||||
|
find_package(export_interfaces REQUIRED)
|
||||||
|
|
||||||
|
if (NOT TARGET CXXModules::export_interfaces)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Missing imported target")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_sets TARGET CXXModules::export_interfaces
|
||||||
|
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||||
|
if (NOT file_sets STREQUAL "modules")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file sets in `CXXModules::export_interfaces`: `${file_sets}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_set_files TARGET CXXModules::export_interfaces
|
||||||
|
PROPERTY CXX_MODULE_SET_modules)
|
||||||
|
if (NOT file_set_files STREQUAL "${expected_dir}/importable.cxx")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file set paths in CXXModules::export_interfaces`: `${file_set_files}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(imported_modules_set TARGET CXXModules::export_interfaces
|
||||||
|
PROPERTY IMPORTED_CXX_MODULES_DEBUG SET)
|
||||||
|
if (imported_modules_set)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Unexpected C++ modules specified.")
|
||||||
|
endif ()
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
|
||||||
|
CMake's C\+\+ module support is experimental. It is meant only for
|
||||||
|
experimentation and feedback to CMake developers.
|
||||||
|
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.
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_export_interfaces CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(export_interfaces STATIC)
|
||||||
|
target_sources(export_interfaces
|
||||||
|
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)
|
||||||
|
target_compile_features(export_interfaces PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS export_interfaces
|
||||||
|
EXPORT CXXModules
|
||||||
|
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||||
|
install(EXPORT CXXModules
|
||||||
|
NAMESPACE CXXModules::
|
||||||
|
DESTINATION "lib/cmake/export_interfaces"
|
||||||
|
FILE "export_interfaces-targets.cmake")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-config.cmake"
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interfaces-targets.cmake\")
|
||||||
|
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
|
||||||
|
")
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-config.cmake"
|
||||||
|
DESTINATION "lib/cmake/export_interfaces")
|
||||||
|
|
||||||
|
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_interfaces_build
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
|
||||||
|
"-Dexport_interfaces_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_interfaces"
|
||||||
|
${generator}
|
||||||
|
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||||
|
-B "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import priv;
|
||||||
|
|
||||||
|
int forwarding()
|
||||||
|
{
|
||||||
|
return from_private();
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
int forwarding();
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return forwarding();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module priv;
|
||||||
|
|
||||||
|
export int from_private()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_library NONE)
|
||||||
|
|
||||||
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
|
||||||
|
|
||||||
|
find_package(export_interfaces REQUIRED)
|
||||||
|
|
||||||
|
if (NOT TARGET CXXModules::export_interfaces)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Missing imported target")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_sets TARGET CXXModules::export_interfaces
|
||||||
|
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||||
|
if (NOT file_sets STREQUAL "modules")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file sets in `CXXModules::export_interfaces`: `${file_sets}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(file_set_files TARGET CXXModules::export_interfaces
|
||||||
|
PROPERTY CXX_MODULE_SET_modules)
|
||||||
|
if (NOT file_set_files STREQUAL "${expected_dir}/importable.cxx")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Incorrect exported file set paths in CXXModules::export_interfaces`: `${file_set_files}`")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_property(imported_modules_set TARGET CXXModules::export_interfaces
|
||||||
|
PROPERTY IMPORTED_CXX_MODULES_DEBUG SET)
|
||||||
|
if (imported_modules_set)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Unexpected C++ modules specified.")
|
||||||
|
endif ()
|
||||||
Reference in New Issue
Block a user