mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-10 11:29:09 -05:00
RunCMake/CXXModules: test installation of BMIs and interfaces
This commit is contained in:
@@ -104,12 +104,22 @@ function (run_cxx_module_test directory)
|
|||||||
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
|
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (RunCMake_CXXModules_INSTALL)
|
||||||
|
set(prefix "${RunCMake_BINARY_DIR}/examples/${test_name}-install")
|
||||||
|
file(REMOVE_RECURSE "${prefix}")
|
||||||
|
list(APPEND RunCMake_TEST_OPTIONS
|
||||||
|
"-DCMAKE_INSTALL_PREFIX=${prefix}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
list(APPEND RunCMake_TEST_OPTIONS
|
list(APPEND RunCMake_TEST_OPTIONS
|
||||||
"-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}"
|
"-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}"
|
||||||
${ARGN})
|
${ARGN})
|
||||||
run_cmake("examples/${test_name}")
|
run_cmake("examples/${test_name}")
|
||||||
set(RunCMake_TEST_NO_CLEAN 1)
|
set(RunCMake_TEST_NO_CLEAN 1)
|
||||||
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug)
|
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug)
|
||||||
|
if (RunCMake_CXXModules_INSTALL)
|
||||||
|
run_cmake_command("examples/${test_name}-install" "${CMAKE_COMMAND}" --build . --target install --config Debug)
|
||||||
|
endif ()
|
||||||
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
|
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
@@ -136,3 +146,12 @@ endif ()
|
|||||||
if ("internal_partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
if ("internal_partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
run_cxx_module_test(internal-partitions)
|
run_cxx_module_test(internal-partitions)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
# All of the following tests perform installation.
|
||||||
|
set(RunCMake_CXXModules_INSTALL 1)
|
||||||
|
|
||||||
|
# Tests which install BMIs
|
||||||
|
if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
|
run_cxx_module_test(install-bmi)
|
||||||
|
run_cxx_module_test(install-bmi-and-interfaces)
|
||||||
|
endif ()
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
function (check_for_bmi prefix destination name)
|
||||||
|
set(found 0)
|
||||||
|
foreach (ext IN ITEMS gcm)
|
||||||
|
if (EXISTS "${prefix}/${destination}/${name}.${ext}")
|
||||||
|
set(found 1)
|
||||||
|
break ()
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
if (NOT found)
|
||||||
|
message(SEND_ERROR
|
||||||
|
"Failed to find the ${name} BMI")
|
||||||
|
endif ()
|
||||||
|
endfunction ()
|
||||||
|
|
||||||
|
function (check_for_interface prefix destination subdir name)
|
||||||
|
set(found 0)
|
||||||
|
if (NOT EXISTS "${prefix}/${destination}/${subdir}/${name}")
|
||||||
|
message(SEND_ERROR
|
||||||
|
"Failed to find the ${name} module interface")
|
||||||
|
endif ()
|
||||||
|
endfunction ()
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
function (check_for_bmi prefix destination name)
|
||||||
|
set(found 0)
|
||||||
|
foreach (ext IN ITEMS gcm)
|
||||||
|
if (EXISTS "${prefix}/${destination}/${name}.${ext}")
|
||||||
|
set(found 1)
|
||||||
|
break ()
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
if (NOT found)
|
||||||
|
message(SEND_ERROR
|
||||||
|
"Failed to find the ${name} BMI")
|
||||||
|
endif ()
|
||||||
|
endfunction ()
|
||||||
|
|
||||||
|
function (check_for_interface prefix destination subdir name)
|
||||||
|
set(found 0)
|
||||||
|
if (NOT EXISTS "${prefix}/${destination}/${subdir}/${name}")
|
||||||
|
message(SEND_ERROR
|
||||||
|
"Failed to find the ${name} module interface")
|
||||||
|
endif ()
|
||||||
|
endfunction ()
|
||||||
|
|
||||||
|
function (report_dirs prefix destination)
|
||||||
|
message("prefix: ${prefix}")
|
||||||
|
message("destination: ${destination}")
|
||||||
|
endfunction ()
|
||||||
@@ -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,27 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_install_bmi_and_interfaces CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(install_bmi_and_interfaces STATIC)
|
||||||
|
target_sources(install_bmi_and_interfaces
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET CXX_MODULES
|
||||||
|
BASE_DIRS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
FILES
|
||||||
|
importable.cxx)
|
||||||
|
target_compile_features(install_bmi_and_interfaces PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS install_bmi_and_interfaces
|
||||||
|
ARCHIVE DESTINATION "lib"
|
||||||
|
CXX_MODULES_BMI DESTINATION "lib/cxx/bmi"
|
||||||
|
FILE_SET CXX_MODULES DESTINATION "lib/cxx/miu")
|
||||||
|
|
||||||
|
add_test(NAME check-for-bmi
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-Dprefix=${CMAKE_INSTALL_PREFIX}"
|
||||||
|
"-Dbmi_destination=lib/cxx/bmi"
|
||||||
|
"-Dfs_destination=lib/cxx/miu"
|
||||||
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/check-for-bmi.cmake")
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/../cxx-modules-find-bmi.cmake")
|
||||||
|
|
||||||
|
report_dirs("${prefix}" "${bmi_destination}")
|
||||||
|
check_for_bmi("${prefix}" "${bmi_destination}" importable)
|
||||||
|
|
||||||
|
report_dirs("${prefix}" "${fs_destination}")
|
||||||
|
check_for_interface("${prefix}" "${fs_destination}" "" importable.cxx)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -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,25 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_install_bmi CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(install_bmi STATIC)
|
||||||
|
target_sources(install_bmi
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET CXX_MODULES
|
||||||
|
BASE_DIRS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
FILES
|
||||||
|
importable.cxx)
|
||||||
|
target_compile_features(install_bmi PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
install(TARGETS install_bmi
|
||||||
|
ARCHIVE DESTINATION "lib"
|
||||||
|
CXX_MODULES_BMI DESTINATION "lib/cxx/bmi")
|
||||||
|
|
||||||
|
add_test(NAME check-for-bmi
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}"
|
||||||
|
"-Dprefix=${CMAKE_INSTALL_PREFIX}"
|
||||||
|
"-Ddestination=lib/cxx/bmi"
|
||||||
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/check-for-bmi.cmake")
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/../cxx-modules-find-bmi.cmake")
|
||||||
|
|
||||||
|
report_dirs("${prefix}" "${destination}")
|
||||||
|
check_for_bmi("${prefix}" "${destination}" importable)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user