diff options
| author | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-06-30 20:47:33 +0200 |
|---|---|---|
| committer | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-06-30 20:47:33 +0200 |
| commit | 914c5024e9005d06bb3f784c2bc230a58483fb9a (patch) | |
| tree | 911c22fae9e35f3208603103d8afb950ad21d9ac /hello/CMakeLists.txt | |
| parent | 2c74c8a08becb4cc12f3b7b280e46e9816a5dc21 (diff) | |
| download | csharp-cmake-914c5024e9005d06bb3f784c2bc230a58483fb9a.tar.gz csharp-cmake-914c5024e9005d06bb3f784c2bc230a58483fb9a.zip | |
Add cmake/dotnet.cmake with add_dotnet_library, add_dotnet_executable, and target_link_dotnet_libraries
Diffstat (limited to 'hello/CMakeLists.txt')
| -rw-r--r-- | hello/CMakeLists.txt | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/hello/CMakeLists.txt b/hello/CMakeLists.txt index 3d1427d..d726950 100644 --- a/hello/CMakeLists.txt +++ b/hello/CMakeLists.txt @@ -1,25 +1,8 @@ -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_dotnet_executable(HelloCMake + MAIN Program + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Program.cs ) -add_custom_target(${TARGET} ALL DEPENDS ${OUTPUT_FILE}) -add_dependencies(${TARGET} FooBar) +target_link_dotnet_libraries(HelloCMake + LIBRARIES FooBar +) |
