blob: 384507bf608f87b1273ab2d800018b1714d714c4 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# generate JNI library and create a jar
# Make from within Eclipse fails miserably with the whole thing
if (WIN32)
LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v3.5") # CSharp compiler
LIST(APPEND CMAKE_PROGRAM_PATH "C:/Windows/Microsoft.NET/Framework/v4.0.30319") # CSharp compiler
endif()
FIND_PROGRAM(DMCS_EXECUTABLE dmcs PATHS $ENV{DMCS_HOME} ENV PATH ) # Mono compiler
FIND_PROGRAM(CSC_EXECUTABLE csc PATHS $ENV{CSC_HOME} ENV PATH ) # CSharp compiler
if (DMCS_EXECUTABLE OR CSC_EXECUTABLE)
# unset all library suffixes as swig will hardcode a library without
SET(LIB_POSTFIX ${CMAKE_LIBRARY_POSTFIX})
SET(CMAKE_DEBUG_POSTFIX "")
SET(CMAKE_RELEASE_POSTFIX "")
SET(CMAKE_RELWITHDEBINFO_POSTFIX "")
SET(CMAKE_MINSIZEREL_POSTFIX "")
SET(CMAKE_LIBRARY_POSTFIX "")
if (MSVC)
# MSVC does not include inttypes.h but SWIG needs it
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../msvc)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
SET(CMAKE_SWIG_FLAGS "")
SET(USCXML_CSHARP_NAMESPACE "org.uscxml")
SET(USCXML_CSHARP_DIR "org/uscxml")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND CMAKE_SWIG_FLAGS "-DDEBUG")
endif()
# we need ; to produce a space with the package .. weird
SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES SWIG_FLAGS "-w401;-namespace;${USCXML_CSHARP_NAMESPACE}")
SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES CPLUSPLUS ON)
SET(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/${USCXML_CSHARP_DIR}")
set(USCXML_LANGUAGE_BINDINGS "csharp ${USCXML_LANGUAGE_BINDINGS}")
SWIG_ADD_MODULE(uscxmlNativeCSharp csharp uscxml.i)
set_target_properties(uscxmlNativeCSharp PROPERTIES FOLDER "Bindings")
set_target_properties(uscxmlNativeCSharp
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp${LIB_POSTFIX}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp${LIB_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp${LIB_POSTFIX}"
)
set_target_properties(uscxmlNativeCSharp PROPERTIES COMPILE_FLAGS "-DSWIG")
swig_link_libraries(uscxmlNativeCSharp uscxml)
# build managed code part
if (CSC_EXECUTABLE)
ADD_CUSTOM_TARGET(csharp
COMMAND ${CMAKE_COMMAND} -E
copy ${CMAKE_CURRENT_SOURCE_DIR}/org/uscxml/InterpreterException.cs ${PROJECT_BINARY_DIR}/src/bindings/swig/csharp/org/uscxml
COMMAND ${CSC_EXECUTABLE}
/target:library
/out:${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/uscxmlCSharp.dll
*.cs
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/bindings/swig/csharp/org/uscxml
COMMENT "Creating umundoCSharp.dll for C# ...")
else()
ADD_CUSTOM_TARGET(csharp
COMMAND ${CMAKE_COMMAND} -E
copy ${CMAKE_CURRENT_SOURCE_DIR}/org/uscxml/InterpreterException.cs ${PROJECT_BINARY_DIR}/src/bindings/swig/csharp/org/uscxml
COMMAND ${DMCS_EXECUTABLE}
-target:library
/out:${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/uscxmlCSharp.dll
*.cs
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/bindings/swig/csharp/org/uscxml
COMMENT "Creating umundoCSharp.dll for Mono ...")
endif()
add_dependencies(csharp uscxmlNativeCSharp)
if (BUILD_TESTS)
add_dependencies(ALL_TESTS csharp)
endif()
set_target_properties(csharp PROPERTIES FOLDER "Bindings")
set(USCXML_LANGUAGE_BINDINGS ${USCXML_LANGUAGE_BINDINGS} PARENT_SCOPE)
endif()
|