diff --git a/.gitignore b/.gitignore index bc983be9..091e2742 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # CMake build/ +_buildconfig.py # Cargo target/ diff --git a/CMakeLists.txt b/CMakeLists.txt index ae53fbda..893bf808 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,9 @@ execute_process( ) message(STATUS ${CLANG_OUTPUT}) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate-buildconfig-py.cmake) +generate_buildconfig_py("${CMAKE_CURRENT_SOURCE_DIR}/tests/lit/lit") + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/rust-toolchain.cmake) set(RUST_STAMP_FILE "${CMAKE_BINARY_DIR}/.rust-toolchain.stamp") diff --git a/cmake/generate-buildconfig-py.cmake b/cmake/generate-buildconfig-py.cmake new file mode 100644 index 00000000..a5a5a778 --- /dev/null +++ b/cmake/generate-buildconfig-py.cmake @@ -0,0 +1,15 @@ +function(generate_buildconfig_py outdir) + file(CONFIGURE + OUTPUT "${outdir}/_buildconfig.py" + CONTENT [[ +"""Generated by CMake, do not edit.""" + +from pathlib import Path + +CXX = Path(r"@CMAKE_CXX_COMPILER@") +CC = Path(r"@CMAKE_C_COMPILER@") +]] + ESCAPE_QUOTES + @ONLY + ) +endfunction() diff --git a/tests/lit/lit/formats/Cpp2RustTest.py b/tests/lit/lit/formats/Cpp2RustTest.py index f13cff6b..dca891d3 100644 --- a/tests/lit/lit/formats/Cpp2RustTest.py +++ b/tests/lit/lit/formats/Cpp2RustTest.py @@ -3,6 +3,7 @@ import lit.Test import lit.util +from .._buildconfig import CXX, CC from .base import TestFormat from dataclasses import dataclass from pathlib import Path @@ -177,12 +178,7 @@ def build_cpp(self): self.cpp_bin = self.build_dir / "app" return None - ## FIXME: these must use the detected/chosen compiler in cmake - cc = ( - os.environ.get("CC", "clang") - if self.cc_input.suffix == ".c" - else os.environ.get("CXX", "clang++") - ) + cc = CC if self.cc_input.suffix == ".c" else CXX self.cpp_bin = self.tmp_dir / "cpp" cmd = [ cc,