我正在尝试使以下cmake
代码段能够处理用户从cpack
窗口调用cmd
的情况(而不是在Visual Studio中,单击“ PACKAGE”目标)。当前它失败并显示:
c:\tmp>cpack.exe -G ZIP
CPack: Create package using ZIP
CPack: Install projects
CPack: - Install project: GDCM
CMake Error at C:/tmp/gdcm-swig-x64/Wrapping/Csharp/cmake_install.cmake:60 (file):
file INSTALL cannot find
"C:/tmp/gdcm-swig-x64/bin//gdcm-sharp.dll".
Call Stack (most recent call first):
C:/tmp/gdcm-swig-x64/cmake_install.cmake:51 (include
)
CPack Error: Error when generating package: GDCM
set(GDCM_LIBRARY_DIR2 ${LIBRARY_OUTPUT_PATH}/\${BUILD_TYPE})
install(FILES ${GDCM_LIBRARY_DIR2}/gdcm_csharp.dll
DESTINATION ${GDCM_INSTALL_LIB_DIR} COMPONENT Runtime
)
其中gdcm_csharp.dll
是通过add_custom_command
生成的,例如:
add_custom_command(
OUTPUT ${GDCM_LIBRARY_DIR}/gdcm_csharp.dll
COMMAND ${CMAKE_CSHARP_COMPILER} ARGS "/t:library" "/out:${GDCM_LIBRARY_DIR}/gdcm_csharp.dll" "*.cs"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS "${swig_generated_file_fullname}" ${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cs
COMMENT "csc *.cs"
)
是否有一种方法可以修复install(FILES)
command来处理两种情况(在Visual Studio内和外部)?
答案 0 :(得分:0)
要在不显式运行Visual Studio的情况下执行PACKAGE目标,可以执行以下操作:
cmake --build C:/tmp/gdcm-swig-x64/ --config Release --target PACKAGE