summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeTestCSharpCompiler.cmake
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-26 16:24:03 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-27 17:29:52 (GMT)
commitdb76876db5c16d610efd08f6deb0e4c9cd0e5603 (patch)
treeaf62cdbbf0860aee9a3b3a249cbfa578cc01aa33 /Modules/CMakeTestCSharpCompiler.cmake
parent98aef0929f4c5ce7bbf7ce9c2dfc5cad382f5a96 (diff)
downloadCMake-db76876db5c16d610efd08f6deb0e4c9cd0e5603.zip
CMake-db76876db5c16d610efd08f6deb0e4c9cd0e5603.tar.gz
CMake-db76876db5c16d610efd08f6deb0e4c9cd0e5603.tar.bz2
Modules: Use new SOURCES_FROM_* try_compile (1/2)
Modify some modules that ship with CMake to use the new SOURCES_FROM_* arguments to try_compile / try_run as added by commits cb14ae2b87 (try_compile: Add SOURCE_FROM_{ARG,VAR}, 2022-09-21) and 611d801790 (try_compile: Add SOURCE_FROM_FILE, 2022-09-22). This covers users which previously either used an existing file (but sometimes needed to rename it), or which wrote out their source in entirety. It does NOT cover users that actually need configure_file functionality, as those will be more involved to update and will thus be tackled in part 2.
Diffstat (limited to 'Modules/CMakeTestCSharpCompiler.cmake')
-rw-r--r--Modules/CMakeTestCSharpCompiler.cmake17
1 files changed, 8 insertions, 9 deletions
diff --git a/Modules/CMakeTestCSharpCompiler.cmake b/Modules/CMakeTestCSharpCompiler.cmake
index d7a0bb5..1c9e249 100644
--- a/Modules/CMakeTestCSharpCompiler.cmake
+++ b/Modules/CMakeTestCSharpCompiler.cmake
@@ -12,8 +12,6 @@ include(CMakeTestCompilerCommon)
unset(CMAKE_CSharp_COMPILER_WORKS CACHE)
-set(test_compile_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCSharpCompiler.cs")
-
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected C# compiler can actually compile
# and link the most basic of programs. If not, a fatal error
@@ -23,20 +21,21 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS)
# Don't call PrintTestCompilerStatus() because the "C#" we want to pass
# as the LANG doesn't match with the variable name "CMAKE_CSharp_COMPILER"
message(CHECK_START "Check for working C# compiler: ${CMAKE_CSharp_COMPILER}")
- file(WRITE "${test_compile_file}"
- "namespace Test {"
- " public class CSharp {"
- " static void Main(string[] args) {}"
- " }"
- "}"
+ string(CONCAT __TestCompiler_testCSharpCompilerSource
+ "namespace Test {\n"
+ " public class CSharp {\n"
+ " static void Main(string[] args) {}\n"
+ " }\n"
+ "}\n"
)
# Clear result from normal variable.
unset(CMAKE_CSharp_COMPILER_WORKS)
# Puts test result in cache variable.
try_compile(CMAKE_CSharp_COMPILER_WORKS
- SOURCES "${test_compile_file}"
+ SOURCE_FROM_VAR testCSharpCompiler.cs __TestCompiler_testCSharpCompilerSource
OUTPUT_VARIABLE __CMAKE_CSharp_COMPILER_OUTPUT
)
+ unset(__TestCompiler_testCSharpCompilerSource)
# Move result from cache to normal variable.
set(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_CSharp_COMPILER_WORKS})
unset(CMAKE_CSharp_COMPILER_WORKS CACHE)