我正在尝试从.cs
文件集中构建 CSharp DLL。我使用该add_library()
功能添加源文件(.cs
文件)。但它给出了诸如“add_library for library libname without any source files”之类的警告。请提供解决方案以使其正常工作。
提前致谢。
CMakeLists.txt 是:
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")