gplugin/gplugin

abandoning this branch
draft feature/mono
2021-04-28, Gary Kramlich
bb31846ffcb7
abandoning this branch
option(
BUILD_MONO
"Whether or not to build the mono plugin loader"
"On"
)
if(BUILD_MONO)
if(NOT BUILD_GIR)
message(FATAL_ERROR "Mono plugin requires GObject Introspection.")
endif(NOT BUILD_GIR)
find_program(MONO_MCS NAMES mcs)
if(NOT MONO_MCS)
message(FATAL_ERROR "Failed to find mcs")
endif(NOT MONO_MCS)
find_program(GAPI3_CODEGEN NAMES gapi3-codegen)
if(NOT GAPI3_CODEGEN)
message(FATAL_ERROR "Failed to find gapi3-codegen")
endif(NOT GAPI3_CODEGEN)
set(GPLUGIN_MONO_SOURCES
gplugin-mono-core.c
gplugin-mono-loader.c
gplugin-mono-plugin.c
)
set(GPLUGIN_MONO_HEADERS
gplugin-mono-loader.h
gplugin-mono-plugin.c
)
pkg_check_modules(MONO REQUIRED mono-2>=2.6.0)
add_library(gplugin-mono MODULE
${GPLUGIN_MONO_SOURCES}
${GPLUGIN_MONO_HEADERS}
)
set_target_properties(gplugin-mono PROPERTIES PREFIX "")
include_directories(${MONO_INCLUDE_DIRS})
target_link_libraries(gplugin-mono
${MONO_LIBRARIES}
gplugin
)
# create the raw file from the gir
add_custom_command(
COMMAND ${XSLTPROC} -o ${CMAKE_CURRENT_BINARY_DIR}/gplugin.api
${CMAKE_CURRENT_SOURCE_DIR}/gir2gapi.xslt
${GPLUGIN_GIR_FILENAME}
OUTPUT gplugin.api
DEPENDS ${GPLUGIN_GIR_FILENAME}
)
add_custom_target(mono-api ALL
DEPENDS ${GPLUGIN_GIR_FILENAME} gplugin.api
)
# create AssemblyInfo.cs
configure_file(AssemblyInfo.cs.in ${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cs @ONLY)
# generate sources
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
add_custom_command(
COMMAND ${MONO_MCS} -out:gplugin-sharp.dll -target:library -pkg:glib-sharp-3.0
-unsafe
-keyfile:${CMAKE_CURRENT_SOURCE_DIR}/gplugin.snk
AssemblyInfo.cs gen/*.cs
OUTPUT gplugin-sharp.dll
DEPENDS mono-generated
)
add_custom_target(mono-library ALL
DEPENDS gplugin-sharp.dll
)
install(TARGETS gplugin-mono DESTINATION lib/gplugin)
endif(BUILD_MONO)
add_subdirectory(tests)