1cmake_minimum_required(VERSION 2.8.7) 2project(libiio-sharp NONE) 3 4if (WIN32) 5 set(MCS_EXECUTABLE_NAME csc) 6else() 7 set(MCS_EXECUTABLE_NAME mcs) 8endif() 9 10find_program(MCS_EXECUTABLE 11 NAMES ${MCS_EXECUTABLE_NAME} 12 HINTS "C:/Windows/Microsoft.NET/Framework/v4.0.30319" 13 PATHS ENV MCS_EXECUTABLE_PATH 14 DOC "C# compiler") 15mark_as_advanced(MCS_EXECUTABLE) 16 17if (MCS_EXECUTABLE) 18 option(CSHARP_BINDINGS "Install C# bindings" ON) 19 20 if (CSHARP_BINDINGS) 21 set(LIBIIO_CS_PC_IN "${CMAKE_CURRENT_SOURCE_DIR}/libiio-sharp.pc.cmakein") 22 set(LIBIIO_CS_PC "${CMAKE_CURRENT_BINARY_DIR}/libiio-sharp-${VERSION}.pc") 23 configure_file(${LIBIIO_CS_PC_IN} ${LIBIIO_CS_PC} @ONLY) 24 if(NOT SKIP_INSTALL_ALL) 25 install(FILES ${LIBIIO_CS_PC} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") 26 endif() 27 28 set(LIBIIO_CS_DLL_CONFIG_IN "${CMAKE_CURRENT_SOURCE_DIR}/libiio-sharp.dll.config.cmakein") 29 set(LIBIIO_CS_DLL_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/libiio-sharp.dll.config") 30 configure_file(${LIBIIO_CS_DLL_CONFIG_IN} ${LIBIIO_CS_DLL_CONFIG} @ONLY) 31 if(NOT SKIP_INSTALL_ALL) 32 install(FILES ${LIBIIO_CS_DLL_CONFIG} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cli/libiio-sharp-${VERSION}) 33 endif() 34 35 set(LIBIIO_CS_VERSION ${VERSION}.0.0) 36 set(LIBIIO_CS_INFO_IN ${CMAKE_CURRENT_SOURCE_DIR}/AssemblyInfo.cs.in) 37 set(LIBIIO_CS_INFO ${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cs) 38 configure_file(${LIBIIO_CS_INFO_IN} ${LIBIIO_CS_INFO} @ONLY) 39 40 set(LIBIIO_CS_DLL "${CMAKE_CURRENT_BINARY_DIR}/libiio-sharp.dll") 41 set(LIBIIO_CS_SOURCES 42 ${CMAKE_CURRENT_SOURCE_DIR}/Attr.cs 43 ${CMAKE_CURRENT_SOURCE_DIR}/Channel.cs 44 ${CMAKE_CURRENT_SOURCE_DIR}/Context.cs 45 ${CMAKE_CURRENT_SOURCE_DIR}/Device.cs 46 ${CMAKE_CURRENT_SOURCE_DIR}/IOBuffer.cs 47 ${CMAKE_CURRENT_SOURCE_DIR}/Trigger.cs 48 ${LIBIIO_CS_INFO} 49 ) 50 51 foreach(SRC ${LIBIIO_CS_SOURCES}) 52 file(TO_NATIVE_PATH ${SRC} TMP) 53 set(LIBIIO_CS_SOURCES_REALPATH ${LIBIIO_CS_SOURCES_REALPATH} ${TMP}) 54 endforeach(SRC) 55 56 file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/key.snk SIGN_KEY) 57 file(TO_NATIVE_PATH ${LIBIIO_CS_DLL} LIBIIO_CS_DLL_OUT) 58 59 add_custom_command(OUTPUT ${LIBIIO_CS_DLL} 60 COMMAND ${MCS_EXECUTABLE} /target:library /out:${LIBIIO_CS_DLL_OUT} /debug /keyfile:${SIGN_KEY} ${LIBIIO_CS_SOURCES_REALPATH} 61 DEPENDS ${LIBIIO_CS_SOURCES} 62 ) 63 64 add_custom_target(libiio-sharp ALL DEPENDS ${LIBIIO_CS_DLL}) 65 66 if(NOT SKIP_INSTALL_ALL) 67 install(FILES ${LIBIIO_CS_DLL} ${LIBIIO_CS_DLL}.mdb DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cli/libiio-sharp-${VERSION}) 68 endif() 69 endif() 70endif() 71