summaryrefslogtreecommitdiff
path: root/src/csharp/CMakeLists.txt
blob: 10193abb32d7fc891f71e72aa8e7b3d7d931d226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Generate C# wrapper
include_directories(../)

set(KOLAB_SWIG_CSHARP_SOURCE_FILE csharp_kolabformat_wrapper.cpp)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_CSHARP_SOURCE_FILE}
        COMMAND ${SWIG} -v -c++ -csharp -o ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_CSHARP_SOURCE_FILE}  ../kolabformat.i
        COMMENT "Generating C# bindings"
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
        DEPENDS ../kolabformat.i kolabxml
        VERBATIM
    )

SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_CSHARP_SOURCE_FILE} PROPERTIES GENERATED 1)
ADD_CUSTOM_TARGET(generate_CSHARP_bindings ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_CSHARP_SOURCE_FILE})

# Compile CSHARP Bindings
find_program(GMCS gmcs /usr/bin)

if (GMCS_FOUND)
    add_custom_command(OUTPUT kolabformat.dll
            COMMAND ${GMCS} --target:library kolabformat.cs *.cs
            COMMENT "Compiling C# library"
            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
            DEPENDS kolabxml charpbindings
            VERBATIM
        )

    SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/kolabformat.dll PROPERTIES GENERATED 1)
    ADD_CUSTOM_TARGET(generate_CSHARP_bindings ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.dll)

    if (KOLAB_CSHARP_INSTALL_DIR)
        set(CSHARP_INSTALL_DIR ${KOLAB_CSHARP_INSTALL_DIR})
    else (KOLAB_CSHARP_INSTALL_DIR)
        set(CSHARP_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/csharpbindings)
    endif (KOLAB_CSHARP_INSTALL_DIR)

    install(TARGETS csharpbindings LIBRARY DESTINATION ${CSHARP_INCLUDE_DIR})
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.dll LIBRARY DESTINATION ${CSHARP_INSTALL_DIR})

endif (GMCS_FOUND)