summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-29 08:41:44 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-29 08:41:44 (GMT)
commit32505d384e74f616e98e072dfd5ca00d1d4ada74 (patch)
tree6fbcc3dceb86ecc94ddc693983dcea50647d20ab
parent1bd3a3d7514df2084ea67c2bdfe011c54f4c578b (diff)
downloadlibkolabxml-32505d384e74f616e98e072dfd5ca00d1d4ada74.tar.gz
Correct C# bindings build process
-rw-r--r--src/csharp/CMakeLists.txt18
-rw-r--r--src/csharp/test.cs16
2 files changed, 31 insertions, 3 deletions
diff --git a/src/csharp/CMakeLists.txt b/src/csharp/CMakeLists.txt
index 8ba7651..b121261 100644
--- a/src/csharp/CMakeLists.txt
+++ b/src/csharp/CMakeLists.txt
@@ -3,6 +3,7 @@ include_directories(../)
set(KOLAB_SWIG_CSHARP_SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/csharp_kolabformat_wrapper.cpp)
set(KOLAB_SWIG_CSHARP_DLL_FILE ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.dll)
+set(KOLAB_SWIG_CSHARP_TEST_FILE ${CMAKE_CURRENT_BINARY_DIR}/test.exe)
add_custom_command(OUTPUT ${KOLAB_SWIG_CSHARP_SOURCE_FILE}
COMMAND ${SWIG} -v -c++ -csharp -o ${KOLAB_SWIG_CSHARP_SOURCE_FILE} ../kolabformat.i
@@ -18,6 +19,8 @@ SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_CSHARP_SOURCE_FILE} PROPERTIES GENERATE
find_program(GMCS NAMES gmcs HINTS /usr/bin/)
if (GMCS)
+ configure_file(test.cs ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+
add_custom_command(OUTPUT ${KOLAB_SWIG_CSHARP_DLL_FILE}
COMMAND ${GMCS} -target:library ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.cs ${CMAKE_CURRENT_BINARY_DIR}/*.cs
COMMENT "Compiling C# library"
@@ -26,9 +29,17 @@ if (GMCS)
VERBATIM
)
+ add_custom_command(OUTPUT ${KOLAB_SWIG_CSHARP_TEST_FILE}
+ COMMAND ${GMCS} -reference:${KOLAB_SWIG_CSHARP_DLL_FILE} ${CMAKE_CURRENT_BINARY_DIR}/test.cs
+ COMMENT "Compiling C# test.exe"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS kolabxml ${KOLAB_SWIG_CSHARP_SOURCE_FILE}
+ VERBATIM
+ )
+
SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_CSHARP_DLL_FILE} PROPERTIES GENERATED 1)
- #One custom target is enough, no need for one per command
- ADD_CUSTOM_TARGET(generate_csharp_bindings ALL DEPENDS ${KOLAB_SWIG_CSHARP_DLL_FILE})
+ SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_CSHARP_TEST_FILE} PROPERTIES GENERATED 1)
+ ADD_CUSTOM_TARGET(generate_csharp_bindings ALL DEPENDS ${KOLAB_SWIG_CSHARP_DLL_FILE} ${KOLAB_SWIG_CSHARP_TEST_FILE})
if (KOLAB_CSHARP_INSTALL_DIR)
set(CSHARP_INSTALL_DIR ${KOLAB_CSHARP_INSTALL_DIR})
@@ -39,7 +50,8 @@ if (GMCS)
#there is no target "csharpbindings" so you can't install it, just install plain files.
# install(TARGETS csharpbindings LIBRARY DESTINATION ${CSHARP_INCLUDE_DIR})
#not sure about the LIBRARY here, but might work
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.dll LIBRARY DESTINATION ${CSHARP_INSTALL_DIR})
+ install(FILES ${KOLAB_SWIG_CSHARP_DLL_FILE} LIBRARY DESTINATION ${CSHARP_INSTALL_DIR})
+ install(FILES ${KOLAB_SWIG_CSHARP_TEST_FILE} RUNTIME DESTINATION ${CSHARP_INSTALL_DIR})
else(GMCS)
message("gmcs not found, not building csharp bindings")
endif (GMCS)
diff --git a/src/csharp/test.cs b/src/csharp/test.cs
new file mode 100644
index 0000000..6a25adc
--- /dev/null
+++ b/src/csharp/test.cs
@@ -0,0 +1,16 @@
+using System;
+
+class MyEvent {
+
+ static void Main() {
+ Console.WriteLine("Hello World!");
+
+ Event myEvent = new Event();
+
+ ContactReference myContactReference = new ContactReference("john.doe@example.org");
+ myContactReference.setName("John Doe");
+
+ myEvent.setOrganizer(myContactReference);
+
+ }
+}