Tests: Add inspection step to RunCMake.try_run

This commit is contained in:
Brad King
2023-12-07 10:45:00 -05:00
parent a5de5da9ca
commit 30ab0f576f
3 changed files with 37 additions and 4 deletions

View File

@@ -585,10 +585,10 @@ function(add_RunCMake_test_try_compile)
endfunction()
add_RunCMake_test_try_compile()
add_RunCMake_test(try_run -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
-DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}
-DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID})
if(CMAKE_Fortran_COMPILER)
list(APPEND try_run_ARGS -DCMake_TEST_Fortran=1)
endif()
add_RunCMake_test(try_run)
add_RunCMake_test(set)
add_RunCMake_test(variable_watch)
add_RunCMake_test(while)

View File

@@ -0,0 +1,22 @@
enable_language(C)
enable_language(CXX)
if(CMake_TEST_Fortran)
enable_language(Fortran)
endif()
set(info "")
foreach(var
CMAKE_SYSTEM_NAME
CMAKE_C_COMPILER_ID
CMAKE_C_COMPILER_VERSION
CMAKE_CXX_COMPILER_ID
CMAKE_CXX_COMPILER_VERSION
CMAKE_Fortran_COMPILER_ID
CMAKE_Fortran_COMPILER_VERSION
)
if(DEFINED ${var})
string(APPEND info "set(${var} \"${${var}}\")\n")
endif()
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")

View File

@@ -1,5 +1,16 @@
include(RunCMake)
# Detect information from the toolchain:
# - CMAKE_SYSTEM_NAME
# - CMAKE_C_COMPILER_ID
# - CMAKE_C_COMPILER_VERSION
# - CMAKE_CXX_COMPILER_ID
# - CMAKE_CXX_COMPILER_VERSION
run_cmake_with_options(Inspect
-DCMake_TEST_Fortran=${CMake_TEST_Fortran}
)
include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake")
run_cmake(BinDirEmpty)
run_cmake(BinDirRelative)
run_cmake(NoOutputVariable)