summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/dotnet.cmake26
-rw-r--r--foobar/CMakeLists.txt1
-rw-r--r--hello/CMakeLists.txt1
-rw-r--r--second/CMakeLists.txt1
4 files changed, 25 insertions, 4 deletions
diff --git a/cmake/dotnet.cmake b/cmake/dotnet.cmake
index 4c5c4ca..cd848e2 100644
--- a/cmake/dotnet.cmake
+++ b/cmake/dotnet.cmake
@@ -1,5 +1,5 @@
function(add_dotnet_library NAME)
- set(multiValueArgs SOURCES REFERENCES)
+ set(multiValueArgs SOURCES REFERENCES DEPENDS)
cmake_parse_arguments(PARSE_ARGV 1 arg
"" "" "${multiValueArgs}"
@@ -16,6 +16,11 @@ function(add_dotnet_library NAME)
list(APPEND CSC_FLAGS "-reference:${ref}")
endforeach()
+ set(DEPS "")
+ foreach(dep IN LISTS arg_DEPENDS)
+ list(APPEND DEPS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${dep}.dll)
+ endforeach()
+
add_custom_command(
OUTPUT ${OUTPUT_FILE}
COMMAND dotnet ${CSC_DLL}
@@ -27,13 +32,17 @@ function(add_dotnet_library NAME)
-reference:System.Runtime.dll
-reference:System.Console.dll
${arg_SOURCES}
- DEPENDS ${arg_SOURCES}
+ DEPENDS ${arg_SOURCES} ${DEPS}
COMMENT "Compiling ${NAME} library with Roslyn csc..."
COMMAND_EXPAND_LISTS
)
add_custom_target(${NAME} ALL DEPENDS ${OUTPUT_FILE})
+ foreach(dep IN LISTS arg_DEPENDS)
+ add_dependencies(${NAME} ${dep})
+ endforeach()
+
set_target_properties(${NAME} PROPERTIES
DOTNET_ALL_REFS ""
DOTNET_PUBLIC_REFS ""
@@ -43,7 +52,7 @@ endfunction()
function(add_dotnet_executable NAME)
set(oneValueArgs MAIN)
- set(multiValueArgs SOURCES REFERENCES)
+ set(multiValueArgs SOURCES REFERENCES DEPENDS)
cmake_parse_arguments(PARSE_ARGV 1 arg
"" "${oneValueArgs}" "${multiValueArgs}"
@@ -71,6 +80,11 @@ function(add_dotnet_executable NAME)
COPYONLY
)
+ set(DEPS ${RUNTIMECONFIG})
+ foreach(dep IN LISTS arg_DEPENDS)
+ list(APPEND DEPS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${dep}.dll)
+ endforeach()
+
add_custom_command(
OUTPUT ${OUTPUT_FILE}
COMMAND dotnet ${CSC_DLL}
@@ -82,13 +96,17 @@ function(add_dotnet_executable NAME)
-reference:System.Runtime.dll
-reference:System.Console.dll
${arg_SOURCES}
- DEPENDS ${arg_SOURCES} ${RUNTIMECONFIG}
+ DEPENDS ${arg_SOURCES} ${DEPS}
COMMENT "Compiling ${NAME} with Roslyn csc..."
COMMAND_EXPAND_LISTS
)
add_custom_target(${NAME} ALL DEPENDS ${OUTPUT_FILE})
+ foreach(dep IN LISTS arg_DEPENDS)
+ add_dependencies(${NAME} ${dep})
+ endforeach()
+
set_target_properties(${NAME} PROPERTIES
DOTNET_ALL_REFS ""
DOTNET_PUBLIC_REFS ""
diff --git a/foobar/CMakeLists.txt b/foobar/CMakeLists.txt
index 7fc83cb..f4ff2a7 100644
--- a/foobar/CMakeLists.txt
+++ b/foobar/CMakeLists.txt
@@ -1,5 +1,6 @@
add_dotnet_library(FooBar
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/FooBar.cs
+ DEPENDS Baz
)
target_link_dotnet_libraries(FooBar PUBLIC Baz)
diff --git a/hello/CMakeLists.txt b/hello/CMakeLists.txt
index b8db38c..a6fb31c 100644
--- a/hello/CMakeLists.txt
+++ b/hello/CMakeLists.txt
@@ -1,6 +1,7 @@
add_dotnet_executable(HelloCMake
MAIN Program
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Program.cs
+ DEPENDS FooBar
)
target_link_dotnet_libraries(HelloCMake PRIVATE FooBar)
diff --git a/second/CMakeLists.txt b/second/CMakeLists.txt
index 20703c6..464ee52 100644
--- a/second/CMakeLists.txt
+++ b/second/CMakeLists.txt
@@ -1,6 +1,7 @@
add_dotnet_executable(Second
MAIN Program
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Program.cs
+ DEPENDS Baz
)
target_link_dotnet_libraries(Second PRIVATE Baz)