"Whether or not to build the mono plugin loader"
message(FATAL_ERROR "Mono plugin requires GObject Introspection.")
find_program(MONO_MCS NAMES mcs)
message(FATAL_ERROR "Failed to find mcs")
find_program(GAPI3_CODEGEN NAMES gapi3-codegen)
message(FATAL_ERROR "Failed to find gapi3-codegen")
pkg_check_modules(MONO REQUIRED mono-2>=2.6.0)
add_library(gplugin-mono MODULE
set_target_properties(gplugin-mono PROPERTIES PREFIX "")
include_directories(${MONO_INCLUDE_DIRS})
target_link_libraries(gplugin-mono
# create the raw file from the gir
COMMAND ${XSLTPROC} -o ${CMAKE_CURRENT_BINARY_DIR}/gplugin.api
${CMAKE_CURRENT_SOURCE_DIR}/gir2gapi.xslt
DEPENDS ${GPLUGIN_GIR_FILENAME}
add_custom_target(mono-api ALL
DEPENDS ${GPLUGIN_GIR_FILENAME} gplugin.api
configure_file(AssemblyInfo.cs.in ${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cs @ONLY)
add_custom_target(mono-generated
COMMAND ${GAPI3_CODEGEN} --outdir=${CMAKE_CURRENT_BINARY_DIR}/gen --generate ${CMAKE_CURRENT_BINARY_DIR}/gplugin.api
add_dependencies(mono-generated gplugin.api)
# create gplugin-sharp.dll
COMMAND ${MONO_MCS} -out:gplugin-sharp.dll -target:library -pkg:glib-sharp-3.0
-keyfile:${CMAKE_CURRENT_SOURCE_DIR}/gplugin.snk
add_custom_target(mono-library ALL
DEPENDS gplugin-sharp.dll
install(TARGETS gplugin-mono DESTINATION lib/gplugin)