mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-09 23:59:53 -05:00
Tests/RunCMake/CXXModules: add tests which don't export C++ module properties
The existing `export-interfaces-{build,install}` tests were actually
doing this, but make those test exporting the interfaces and copy the
existing tests to tests which explicitly test the "no properties"
condition.
This commit is contained in:
@@ -174,6 +174,7 @@ endif ()
|
||||
|
||||
# Tests which install BMIs
|
||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-interface-no-properties-build)
|
||||
run_cxx_module_test(export-interface-build)
|
||||
run_cxx_module_test(export-bmi-and-interface-build)
|
||||
endif ()
|
||||
@@ -187,6 +188,7 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(install-bmi-and-interfaces)
|
||||
|
||||
if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||
run_cxx_module_test(export-interface-no-properties-install)
|
||||
run_cxx_module_test(export-interface-install)
|
||||
run_cxx_module_test(export-bmi-and-interface-install)
|
||||
endif ()
|
||||
|
||||
@@ -26,7 +26,8 @@ install(TARGETS export_interfaces
|
||||
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||
export(EXPORT CXXModules
|
||||
NAMESPACE CXXModules::
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-targets.cmake")
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-targets.cmake"
|
||||
CXX_MODULES_DIRECTORY "export_interfaces-cxx-modules")
|
||||
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)
|
||||
@@ -46,7 +47,8 @@ endif ()
|
||||
add_test(NAME export_interfaces_build
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-Dexpected_dir=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"-Dexpected_source_dir=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"-Dexpected_binary_dir=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"-Dexport_interfaces_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
${generator}
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||
|
||||
@@ -19,14 +19,14 @@ 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")
|
||||
if (NOT file_set_files STREQUAL "${expected_source_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)
|
||||
get_property(imported_modules TARGET CXXModules::export_interfaces
|
||||
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
|
||||
if (NOT imported_modules MATCHES "importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/CMakeFiles/export_interfaces.dir(/Debug)?/importable.(gcm|pcm|ifc)")
|
||||
message(FATAL_ERROR
|
||||
"Unexpected C++ modules specified.")
|
||||
"Incorrect exported modules in CXXModules::export_interfaces`: `${imported_modules}`\n`importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/CMakeFiles/export_interfaces.dir(/Debug)?/importable.(gcm|pcm|ifc)`")
|
||||
endif ()
|
||||
|
||||
@@ -27,7 +27,8 @@ install(TARGETS export_interfaces
|
||||
install(EXPORT CXXModules
|
||||
NAMESPACE CXXModules::
|
||||
DESTINATION "lib/cmake/export_interfaces"
|
||||
FILE "export_interfaces-targets.cmake")
|
||||
FILE "export_interfaces-targets.cmake"
|
||||
CXX_MODULES_DIRECTORY "export_interfaces-cxx-modules")
|
||||
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)
|
||||
@@ -49,7 +50,8 @@ endif ()
|
||||
add_test(NAME export_interfaces_build
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
|
||||
"-Dexpected_source_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
|
||||
"-Dexpected_binary_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/bmi"
|
||||
"-Dexport_interfaces_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_interfaces"
|
||||
${generator}
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||
|
||||
@@ -19,14 +19,14 @@ 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")
|
||||
if (NOT file_set_files STREQUAL "${expected_source_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)
|
||||
get_property(imported_modules TARGET CXXModules::export_interfaces
|
||||
PROPERTY IMPORTED_CXX_MODULES_DEBUG)
|
||||
if (NOT imported_modules STREQUAL "importable=${expected_source_dir}/importable.cxx")
|
||||
message(FATAL_ERROR
|
||||
"Unexpected C++ modules specified.")
|
||||
"Incorrect exported modules in CXXModules::export_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.
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(cxx_modules_export_interfaces_no_properties CXX)
|
||||
|
||||
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||
|
||||
add_library(export_interfaces_no_properties STATIC)
|
||||
target_sources(export_interfaces_no_properties
|
||||
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_no_properties PUBLIC cxx_std_20)
|
||||
|
||||
install(TARGETS export_interfaces_no_properties
|
||||
EXPORT CXXModules
|
||||
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||
export(EXPORT CXXModules
|
||||
NAMESPACE CXXModules::
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces_no_properties-targets.cmake")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces_no_properties-config.cmake"
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interfaces_no_properties-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_no_properties_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;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(cxx_modules_library NONE)
|
||||
|
||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
|
||||
|
||||
find_package(export_interfaces_no_properties REQUIRED)
|
||||
|
||||
if (NOT TARGET CXXModules::export_interfaces_no_properties)
|
||||
message(FATAL_ERROR
|
||||
"Missing imported target")
|
||||
endif ()
|
||||
|
||||
get_property(file_sets TARGET CXXModules::export_interfaces_no_properties
|
||||
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||
if (NOT file_sets STREQUAL "modules")
|
||||
message(FATAL_ERROR
|
||||
"Incorrect exported file sets in `CXXModules::export_interfaces_no_properties`: `${file_sets}`")
|
||||
endif ()
|
||||
|
||||
get_property(file_set_files TARGET CXXModules::export_interfaces_no_properties
|
||||
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_no_properties`: `${file_set_files}`")
|
||||
endif ()
|
||||
|
||||
get_property(imported_modules_set TARGET CXXModules::export_interfaces_no_properties
|
||||
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.
|
||||
+56
@@ -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_no_properties STATIC)
|
||||
target_sources(export_interfaces_no_properties
|
||||
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_no_properties PUBLIC cxx_std_20)
|
||||
|
||||
install(TARGETS export_interfaces_no_properties
|
||||
EXPORT CXXModules
|
||||
FILE_SET modules DESTINATION "lib/cxx/miu")
|
||||
install(EXPORT CXXModules
|
||||
NAMESPACE CXXModules::
|
||||
DESTINATION "lib/cmake/export_interfaces_no_properties"
|
||||
FILE "export_interfaces_no_properties-targets.cmake")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces_no_properties-config.cmake"
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interfaces_no_properties-targets.cmake\")
|
||||
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
|
||||
")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces_no_properties-config.cmake"
|
||||
DESTINATION "lib/cmake/export_interfaces_no_properties")
|
||||
|
||||
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_no_properties_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_interfaces_no_properties"
|
||||
${generator}
|
||||
-S "${CMAKE_CURRENT_SOURCE_DIR}/test"
|
||||
-B "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||
@@ -0,0 +1,6 @@
|
||||
import priv;
|
||||
|
||||
int forwarding()
|
||||
{
|
||||
return from_private();
|
||||
}
|
||||
+8
@@ -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;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(cxx_modules_library NONE)
|
||||
|
||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
|
||||
|
||||
find_package(export_interfaces_no_properties REQUIRED)
|
||||
|
||||
if (NOT TARGET CXXModules::export_interfaces_no_properties)
|
||||
message(FATAL_ERROR
|
||||
"Missing imported target")
|
||||
endif ()
|
||||
|
||||
get_property(file_sets TARGET CXXModules::export_interfaces_no_properties
|
||||
PROPERTY INTERFACE_CXX_MODULE_SETS)
|
||||
if (NOT file_sets STREQUAL "modules")
|
||||
message(FATAL_ERROR
|
||||
"Incorrect exported file sets in `CXXModules::export_interfaces_no_properties`: `${file_sets}`")
|
||||
endif ()
|
||||
|
||||
get_property(file_set_files TARGET CXXModules::export_interfaces_no_properties
|
||||
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_no_properties`: `${file_set_files}`")
|
||||
endif ()
|
||||
|
||||
get_property(imported_modules_set TARGET CXXModules::export_interfaces_no_properties
|
||||
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