I am trying to build the csharp dll from the set of .cs files. I used add_library() function to add the source files(.cs files).But it is giving warning like "add_library for library libname without any source files".Please provide a solution to make it to work.
Thanks in advance.
CMakeLists.txt is:
cmake_minimum_required(VERSION 2.8)
project(MyAddIn)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/MyAdd-In/ MyAddIn_SOURCES)
SET_SOURCE_FILES_PROPERTIES(${MyAddIn_SOURCES} PROPERTIES LANGUAGE CSharp)
ADD_LIBRARY(AddInTrg SHARED ${MyAddIn_SOURCES})
SET_TARGET_PROPERTIES(AddInTrg PROPERTIES
LINKER_LANGUAGE CSharp
RUNTIME_OUTPUT_DIRECTORY bin
RUNTIME_OUTPUT_DIRECTORY_DEBUG bin
RUNTIME_OUTPUT_NAME MyAddIn_Bin
ARCHIVE_OUTPUT_DIRECTORY lib
ARCHIVE_OUTPUT_DIRECTORY_DEBUG lib
OUTPUT_NAME MyAddIn_Bin)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/MyAddIn_Bin.dll
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/MyAdd-In
COMMAND C:/WINDOWS/Microsoft.NET/Framework/v3.5/csc.exe
ARGS
-target:library
-out ${CMAKE_CURRENT_BINARY_DIR}/bin/MyAddIn_Bin.dll
"${CMAKE_CURRENT_SOURCE_DIR}/MyAdd-In/Ribbon.cs" "${CMAKE_CURRENT_SOURCE_DIR}/MyAdd-In/ThisAddIn.cs" "${CMAKE_CURRENT_SOURCE_DIR}/MyAdd-In/Ribbon.xml"
COMMENT "-- Generating AddIn Dll")
CMake currently has no language support for C#.
In particular, the
add_library
command will not work with.cs
source files. You could attempt to handle all of the compilation manually using custom targets, but be aware that this is extremely difficult to pull off and the gains are limited.Also, take a look at CMake's
ExternelProject_Add
. This might be the right choice if all you want is to build an external .csproj using MSBuild from within a bigger CMake environment.