diff options
Diffstat (limited to 'hello')
| -rw-r--r-- | hello/CMakeLists.txt | 25 | ||||
| -rw-r--r-- | hello/Program.cs | 10 |
2 files changed, 35 insertions, 0 deletions
diff --git a/hello/CMakeLists.txt b/hello/CMakeLists.txt new file mode 100644 index 0000000..3d1427d --- /dev/null +++ b/hello/CMakeLists.txt @@ -0,0 +1,25 @@ +set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Program.cs) +set(TARGET HelloCMake) +set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/${TARGET}.dll) + +add_custom_command( + OUTPUT ${OUTPUT_FILE} + COMMAND dotnet ${CSC_DLL} + -target:exe + -out:${OUTPUT_FILE} + -lib:${RUNTIME_DIR} + -reference:System.Private.CoreLib.dll + -reference:System.Runtime.dll + -reference:System.Console.dll + -reference:${CMAKE_BINARY_DIR}/FooBar.dll + -main:Program + ${SOURCES} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_SOURCE_DIR}/HelloCMake.runtimeconfig.json + ${CMAKE_BINARY_DIR}/${TARGET}.runtimeconfig.json + DEPENDS ${SOURCES} ${CMAKE_BINARY_DIR}/FooBar.dll + COMMENT "Compiling ${TARGET} with Roslyn csc..." +) + +add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILE}) +add_dependencies(${TARGET} FooBar) diff --git a/hello/Program.cs b/hello/Program.cs new file mode 100644 index 0000000..33e286c --- /dev/null +++ b/hello/Program.cs @@ -0,0 +1,10 @@ +using System; + +class Program +{ + static void Main() + { + Console.WriteLine("Hello, CMake + C#!"); + FooBar.Print(); + } +} |
