summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Guillon <Bernhard.Guillon@begu.org>2026-06-30 19:39:10 +0200
committerBernhard Guillon <Bernhard.Guillon@begu.org>2026-06-30 19:39:10 +0200
commitbf63fc33e76773247523d5d973dd4639acb7371a (patch)
tree785e9487ee74f7fdcf67e8be8ca0d2a55d60abc0
downloadcsharp-cmake-bf63fc33e76773247523d5d973dd4639acb7371a.tar.gz
csharp-cmake-bf63fc33e76773247523d5d973dd4639acb7371a.zip
first test
-rw-r--r--CMakeLists.txt21
-rw-r--r--Program.cs9
2 files changed, 30 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..fbd7581
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 4.3)
+project(HelloCMake)
+
+find_program(CSC_EXECUTABLE NAMES csc csc.exe)
+if(NOT CSC_EXECUTABLE)
+ message(FATAL_ERROR "C# compiler (csc) not found!")
+endif()
+
+set(OUTPUT_DIR ${CMAKE_BINARY_DIR})
+set(SOURCES ${CMAKE_SOURCE_DIR}/Program.cs)
+set(TARGET HelloCMake)
+set(OUTPUT_FILE ${OUTPUT_DIR}/${TARGET}.exe)
+
+add_custom_command(
+ OUTPUT ${OUTPUT_FILE}
+ COMMAND ${CSC_EXECUTABLE} /target:exe /out:${OUTPUT_FILE} ${SOURCES}
+ DEPENDS ${SOURCES}
+ COMMENT "Compiling ${TARGET} with csc..."
+)
+
+add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILE})
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..5dd49a9
--- /dev/null
+++ b/Program.cs
@@ -0,0 +1,9 @@
+using System;
+
+class Program
+{
+ static void Main()
+ {
+ Console.WriteLine("Hello, CMake + C#!");
+ }
+}